From a3a8ec42718584b70b5be388537a441ca74fd4c3 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 31 Aug 2022 08:01:28 +0000 Subject: [PATCH] CodeGen from PR 19652 in Azure/azure-rest-api-specs Merge 6e7d042975f3823c483ac775fc736e5ca059c1c6 into 049107d4b086d4bfbcc6c94846e834cadb3886a6 --- sdk/monitor/azure-mgmt-monitor/_meta.json | 10 +- .../azure/mgmt/monitor/_configuration.py | 12 +- .../monitor/_monitor_management_client.py | 17 +- .../azure/mgmt/monitor/_serialization.py | 2006 +++++++++++++++++ .../azure/mgmt/monitor/aio/_configuration.py | 4 +- .../monitor/aio/_monitor_management_client.py | 8 +- .../mgmt/monitor/v2015_04_01/__init__.py | 3 +- .../monitor/v2015_04_01/_configuration.py | 40 +- .../mgmt/monitor/v2015_04_01/_metadata.json | 18 +- .../v2015_04_01/_monitor_management_client.py | 44 +- .../azure/mgmt/monitor/v2015_04_01/_patch.py | 2 +- .../azure/mgmt/monitor/v2015_04_01/_vendor.py | 6 +- .../mgmt/monitor/v2015_04_01/_version.py | 2 +- .../mgmt/monitor/v2015_04_01/aio/__init__.py | 3 +- .../monitor/v2015_04_01/aio/_configuration.py | 42 +- .../aio/_monitor_management_client.py | 44 +- .../mgmt/monitor/v2015_04_01/aio/_patch.py | 2 +- .../v2015_04_01/aio/operations/__init__.py | 15 +- .../operations/_activity_logs_operations.py | 71 +- .../aio/operations/_alert_rules_operations.py | 422 ++-- .../_autoscale_settings_operations.py | 426 ++-- .../_event_categories_operations.py | 63 +- .../v2015_04_01/aio/operations/_operations.py | 48 +- .../v2015_04_01/aio/operations/_patch.py | 1 + .../_tenant_activity_logs_operations.py | 68 +- .../monitor/v2015_04_01/models/__init__.py | 128 +- .../monitor/v2015_04_01/models/_models_py3.py | 1352 +++++------ .../_monitor_management_client_enums.py | 32 +- .../mgmt/monitor/v2015_04_01/models/_patch.py | 1 + .../v2015_04_01/operations/__init__.py | 15 +- .../operations/_activity_logs_operations.py | 108 +- .../operations/_alert_rules_operations.py | 659 +++--- .../_autoscale_settings_operations.py | 639 +++--- .../_event_categories_operations.py | 87 +- .../v2015_04_01/operations/_operations.py | 72 +- .../monitor/v2015_04_01/operations/_patch.py | 1 + .../_tenant_activity_logs_operations.py | 100 +- .../mgmt/monitor/v2015_07_01/__init__.py | 3 +- .../monitor/v2015_07_01/_configuration.py | 40 +- .../mgmt/monitor/v2015_07_01/_metadata.json | 18 +- .../v2015_07_01/_monitor_management_client.py | 38 +- .../azure/mgmt/monitor/v2015_07_01/_patch.py | 2 +- .../azure/mgmt/monitor/v2015_07_01/_vendor.py | 6 +- .../mgmt/monitor/v2015_07_01/_version.py | 2 +- .../mgmt/monitor/v2015_07_01/aio/__init__.py | 3 +- .../monitor/v2015_07_01/aio/_configuration.py | 42 +- .../aio/_monitor_management_client.py | 38 +- .../mgmt/monitor/v2015_07_01/aio/_patch.py | 2 +- .../v2015_07_01/aio/operations/__init__.py | 11 +- .../aio/operations/_alert_rules_operations.py | 422 ++-- .../_metric_definitions_operations.py | 71 +- .../v2015_07_01/aio/operations/_operations.py | 48 +- .../v2015_07_01/aio/operations/_patch.py | 1 + ..._service_diagnostic_settings_operations.py | 146 +- .../monitor/v2015_07_01/models/__init__.py | 92 +- .../monitor/v2015_07_01/models/_models_py3.py | 842 ++++--- .../_monitor_management_client_enums.py | 15 +- .../mgmt/monitor/v2015_07_01/models/_patch.py | 1 + .../v2015_07_01/operations/__init__.py | 11 +- .../operations/_alert_rules_operations.py | 659 +++--- .../_metric_definitions_operations.py | 102 +- .../v2015_07_01/operations/_operations.py | 72 +- .../monitor/v2015_07_01/operations/_patch.py | 1 + ..._service_diagnostic_settings_operations.py | 213 +- .../mgmt/monitor/v2016_03_01/__init__.py | 3 +- .../monitor/v2016_03_01/_configuration.py | 42 +- .../mgmt/monitor/v2016_03_01/_metadata.json | 18 +- .../v2016_03_01/_monitor_management_client.py | 38 +- .../azure/mgmt/monitor/v2016_03_01/_patch.py | 2 +- .../azure/mgmt/monitor/v2016_03_01/_vendor.py | 6 +- .../mgmt/monitor/v2016_03_01/_version.py | 2 +- .../mgmt/monitor/v2016_03_01/aio/__init__.py | 3 +- .../monitor/v2016_03_01/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 38 +- .../mgmt/monitor/v2016_03_01/aio/_patch.py | 2 +- .../v2016_03_01/aio/operations/__init__.py | 11 +- .../_alert_rule_incidents_operations.py | 110 +- .../aio/operations/_alert_rules_operations.py | 413 ++-- .../operations/_log_profiles_operations.py | 319 ++- .../_metric_definitions_operations.py | 73 +- .../v2016_03_01/aio/operations/_patch.py | 1 + .../monitor/v2016_03_01/models/__init__.py | 76 +- .../monitor/v2016_03_01/models/_models_py3.py | 744 +++--- .../_monitor_management_client_enums.py | 15 +- .../mgmt/monitor/v2016_03_01/models/_patch.py | 1 + .../v2016_03_01/operations/__init__.py | 11 +- .../_alert_rule_incidents_operations.py | 190 +- .../operations/_alert_rules_operations.py | 650 +++--- .../operations/_log_profiles_operations.py | 493 ++-- .../_metric_definitions_operations.py | 106 +- .../monitor/v2016_03_01/operations/_patch.py | 1 + .../mgmt/monitor/v2016_09_01/__init__.py | 3 +- .../monitor/v2016_09_01/_configuration.py | 39 +- .../mgmt/monitor/v2016_09_01/_metadata.json | 12 +- .../v2016_09_01/_monitor_management_client.py | 26 +- .../azure/mgmt/monitor/v2016_09_01/_patch.py | 2 +- .../azure/mgmt/monitor/v2016_09_01/_vendor.py | 6 +- .../mgmt/monitor/v2016_09_01/_version.py | 2 +- .../mgmt/monitor/v2016_09_01/aio/__init__.py | 3 +- .../monitor/v2016_09_01/aio/_configuration.py | 41 +- .../aio/_monitor_management_client.py | 26 +- .../mgmt/monitor/v2016_09_01/aio/_patch.py | 2 +- .../v2016_09_01/aio/operations/__init__.py | 7 +- .../aio/operations/_metrics_operations.py | 72 +- .../v2016_09_01/aio/operations/_patch.py | 1 + ..._service_diagnostic_settings_operations.py | 246 +- .../monitor/v2016_09_01/models/__init__.py | 32 +- .../monitor/v2016_09_01/models/_models_py3.py | 303 ++- .../_monitor_management_client_enums.py | 3 +- .../mgmt/monitor/v2016_09_01/models/_patch.py | 1 + .../v2016_09_01/operations/__init__.py | 7 +- .../operations/_metrics_operations.py | 106 +- .../monitor/v2016_09_01/operations/_patch.py | 1 + ..._service_diagnostic_settings_operations.py | 345 +-- .../monitor/v2017_03_01_preview/__init__.py | 3 +- .../v2017_03_01_preview/_configuration.py | 42 +- .../v2017_03_01_preview/_metadata.json | 18 +- .../_monitor_management_client.py | 23 +- .../monitor/v2017_03_01_preview/_patch.py | 2 +- .../monitor/v2017_03_01_preview/_vendor.py | 6 +- .../monitor/v2017_03_01_preview/_version.py | 2 +- .../v2017_03_01_preview/aio/__init__.py | 3 +- .../v2017_03_01_preview/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 23 +- .../monitor/v2017_03_01_preview/aio/_patch.py | 2 +- .../aio/operations/__init__.py | 5 +- .../_activity_log_alerts_operations.py | 422 ++-- .../aio/operations/_patch.py | 1 + .../v2017_03_01_preview/models/__init__.py | 22 +- .../v2017_03_01_preview/models/_models_py3.py | 250 +- .../v2017_03_01_preview/models/_patch.py | 1 + .../operations/__init__.py | 5 +- .../_activity_log_alerts_operations.py | 635 +++--- .../v2017_03_01_preview/operations/_patch.py | 1 + .../mgmt/monitor/v2017_04_01/__init__.py | 3 +- .../monitor/v2017_04_01/_configuration.py | 42 +- .../mgmt/monitor/v2017_04_01/_metadata.json | 18 +- .../v2017_04_01/_monitor_management_client.py | 27 +- .../azure/mgmt/monitor/v2017_04_01/_patch.py | 2 +- .../azure/mgmt/monitor/v2017_04_01/_vendor.py | 6 +- .../mgmt/monitor/v2017_04_01/_version.py | 2 +- .../mgmt/monitor/v2017_04_01/aio/__init__.py | 3 +- .../monitor/v2017_04_01/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 27 +- .../mgmt/monitor/v2017_04_01/aio/_patch.py | 2 +- .../v2017_04_01/aio/operations/__init__.py | 7 +- .../operations/_action_groups_operations.py | 518 +++-- .../_activity_log_alerts_operations.py | 420 ++-- .../v2017_04_01/aio/operations/_patch.py | 1 + .../monitor/v2017_04_01/models/__init__.py | 48 +- .../monitor/v2017_04_01/models/_models_py3.py | 592 +++-- .../mgmt/monitor/v2017_04_01/models/_patch.py | 1 + .../v2017_04_01/operations/__init__.py | 7 +- .../operations/_action_groups_operations.py | 775 ++++--- .../_activity_log_alerts_operations.py | 633 +++--- .../monitor/v2017_04_01/operations/_patch.py | 1 + .../monitor/v2017_05_01_preview/__init__.py | 3 +- .../v2017_05_01_preview/_configuration.py | 42 +- .../v2017_05_01_preview/_metadata.json | 18 +- .../_monitor_management_client.py | 35 +- .../monitor/v2017_05_01_preview/_patch.py | 2 +- .../monitor/v2017_05_01_preview/_vendor.py | 6 +- .../monitor/v2017_05_01_preview/_version.py | 2 +- .../v2017_05_01_preview/aio/__init__.py | 3 +- .../v2017_05_01_preview/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 35 +- .../monitor/v2017_05_01_preview/aio/_patch.py | 2 +- .../aio/operations/__init__.py | 13 +- ...diagnostic_settings_category_operations.py | 86 +- .../_diagnostic_settings_operations.py | 225 +- .../_metric_definitions_operations.py | 69 +- .../aio/operations/_metrics_operations.py | 47 +- .../aio/operations/_patch.py | 1 + ...cription_diagnostic_settings_operations.py | 221 +- .../v2017_05_01_preview/models/__init__.py | 66 +- .../v2017_05_01_preview/models/_models_py3.py | 514 ++--- .../_monitor_management_client_enums.py | 13 +- .../v2017_05_01_preview/models/_patch.py | 1 + .../operations/__init__.py | 13 +- ...diagnostic_settings_category_operations.py | 139 +- .../_diagnostic_settings_operations.py | 344 ++- .../_metric_definitions_operations.py | 98 +- .../operations/_metrics_operations.py | 85 +- .../v2017_05_01_preview/operations/_patch.py | 1 + ...cription_diagnostic_settings_operations.py | 352 ++- .../monitor/v2017_12_01_preview/__init__.py | 3 +- .../v2017_12_01_preview/_configuration.py | 39 +- .../v2017_12_01_preview/_metadata.json | 12 +- .../_monitor_management_client.py | 22 +- .../monitor/v2017_12_01_preview/_patch.py | 2 +- .../monitor/v2017_12_01_preview/_vendor.py | 6 +- .../monitor/v2017_12_01_preview/_version.py | 2 +- .../v2017_12_01_preview/aio/__init__.py | 3 +- .../v2017_12_01_preview/aio/_configuration.py | 41 +- .../aio/_monitor_management_client.py | 22 +- .../monitor/v2017_12_01_preview/aio/_patch.py | 2 +- .../aio/operations/__init__.py | 5 +- .../_metric_namespaces_operations.py | 73 +- .../aio/operations/_patch.py | 1 + .../v2017_12_01_preview/models/__init__.py | 18 +- .../v2017_12_01_preview/models/_models_py3.py | 74 +- .../_monitor_management_client_enums.py | 3 +- .../v2017_12_01_preview/models/_patch.py | 1 + .../operations/__init__.py | 5 +- .../_metric_namespaces_operations.py | 106 +- .../v2017_12_01_preview/operations/_patch.py | 1 + .../mgmt/monitor/v2018_01_01/__init__.py | 3 +- .../monitor/v2018_01_01/_configuration.py | 39 +- .../mgmt/monitor/v2018_01_01/_metadata.json | 12 +- .../v2018_01_01/_monitor_management_client.py | 26 +- .../azure/mgmt/monitor/v2018_01_01/_patch.py | 2 +- .../azure/mgmt/monitor/v2018_01_01/_vendor.py | 6 +- .../mgmt/monitor/v2018_01_01/_version.py | 2 +- .../mgmt/monitor/v2018_01_01/aio/__init__.py | 3 +- .../monitor/v2018_01_01/aio/_configuration.py | 41 +- .../aio/_monitor_management_client.py | 26 +- .../mgmt/monitor/v2018_01_01/aio/_patch.py | 2 +- .../v2018_01_01/aio/operations/__init__.py | 7 +- .../_metric_definitions_operations.py | 73 +- .../aio/operations/_metrics_operations.py | 47 +- .../v2018_01_01/aio/operations/_patch.py | 1 + .../monitor/v2018_01_01/models/__init__.py | 42 +- .../monitor/v2018_01_01/models/_models_py3.py | 259 +-- .../_monitor_management_client_enums.py | 13 +- .../mgmt/monitor/v2018_01_01/models/_patch.py | 1 + .../v2018_01_01/operations/__init__.py | 7 +- .../_metric_definitions_operations.py | 106 +- .../operations/_metrics_operations.py | 87 +- .../monitor/v2018_01_01/operations/_patch.py | 1 + .../mgmt/monitor/v2018_03_01/__init__.py | 3 +- .../monitor/v2018_03_01/_configuration.py | 42 +- .../mgmt/monitor/v2018_03_01/_metadata.json | 18 +- .../v2018_03_01/_monitor_management_client.py | 31 +- .../azure/mgmt/monitor/v2018_03_01/_patch.py | 2 +- .../azure/mgmt/monitor/v2018_03_01/_vendor.py | 6 +- .../mgmt/monitor/v2018_03_01/_version.py | 2 +- .../mgmt/monitor/v2018_03_01/aio/__init__.py | 3 +- .../monitor/v2018_03_01/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 31 +- .../mgmt/monitor/v2018_03_01/aio/_patch.py | 2 +- .../v2018_03_01/aio/operations/__init__.py | 9 +- .../operations/_action_groups_operations.py | 518 +++-- .../operations/_metric_alerts_operations.py | 420 ++-- .../_metric_alerts_status_operations.py | 90 +- .../v2018_03_01/aio/operations/_patch.py | 1 + .../monitor/v2018_03_01/models/__init__.py | 96 +- .../monitor/v2018_03_01/models/_models_py3.py | 1244 +++++----- .../_monitor_management_client_enums.py | 33 +- .../mgmt/monitor/v2018_03_01/models/_patch.py | 1 + .../v2018_03_01/operations/__init__.py | 9 +- .../operations/_action_groups_operations.py | 775 ++++--- .../operations/_metric_alerts_operations.py | 651 +++--- .../_metric_alerts_status_operations.py | 169 +- .../monitor/v2018_03_01/operations/_patch.py | 1 + .../mgmt/monitor/v2018_04_16/__init__.py | 3 +- .../monitor/v2018_04_16/_configuration.py | 42 +- .../mgmt/monitor/v2018_04_16/_metadata.json | 18 +- .../v2018_04_16/_monitor_management_client.py | 23 +- .../azure/mgmt/monitor/v2018_04_16/_patch.py | 2 +- .../azure/mgmt/monitor/v2018_04_16/_vendor.py | 6 +- .../mgmt/monitor/v2018_04_16/_version.py | 2 +- .../mgmt/monitor/v2018_04_16/aio/__init__.py | 3 +- .../monitor/v2018_04_16/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 23 +- .../mgmt/monitor/v2018_04_16/aio/_patch.py | 2 +- .../v2018_04_16/aio/operations/__init__.py | 5 +- .../v2018_04_16/aio/operations/_patch.py | 1 + .../_scheduled_query_rules_operations.py | 422 ++-- .../monitor/v2018_04_16/models/__init__.py | 66 +- .../monitor/v2018_04_16/models/_models_py3.py | 468 ++-- .../_monitor_management_client_enums.py | 27 +- .../mgmt/monitor/v2018_04_16/models/_patch.py | 1 + .../v2018_04_16/operations/__init__.py | 5 +- .../monitor/v2018_04_16/operations/_patch.py | 1 + .../_scheduled_query_rules_operations.py | 655 +++--- .../monitor/v2018_06_01_preview/__init__.py | 3 +- .../v2018_06_01_preview/_configuration.py | 42 +- .../v2018_06_01_preview/_metadata.json | 18 +- .../_monitor_management_client.py | 23 +- .../monitor/v2018_06_01_preview/_patch.py | 2 +- .../monitor/v2018_06_01_preview/_vendor.py | 6 +- .../monitor/v2018_06_01_preview/_version.py | 2 +- .../v2018_06_01_preview/aio/__init__.py | 3 +- .../v2018_06_01_preview/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 23 +- .../monitor/v2018_06_01_preview/aio/_patch.py | 2 +- .../aio/operations/__init__.py | 7 +- ...nostics_settings_association_operations.py | 419 ++-- .../_guest_diagnostics_settings_operations.py | 411 ++-- .../aio/operations/_patch.py | 1 + .../v2018_06_01_preview/models/__init__.py | 48 +- .../v2018_06_01_preview/models/_models_py3.py | 326 ++- .../_monitor_management_client_enums.py | 9 +- .../v2018_06_01_preview/models/_patch.py | 1 + .../operations/__init__.py | 7 +- ...nostics_settings_association_operations.py | 649 +++--- .../_guest_diagnostics_settings_operations.py | 634 +++--- .../v2018_06_01_preview/operations/_patch.py | 1 + .../mgmt/monitor/v2018_09_01/__init__.py | 3 +- .../monitor/v2018_09_01/_configuration.py | 42 +- .../mgmt/monitor/v2018_09_01/_metadata.json | 18 +- .../v2018_09_01/_monitor_management_client.py | 31 +- .../azure/mgmt/monitor/v2018_09_01/_patch.py | 2 +- .../azure/mgmt/monitor/v2018_09_01/_vendor.py | 6 +- .../mgmt/monitor/v2018_09_01/_version.py | 2 +- .../mgmt/monitor/v2018_09_01/aio/__init__.py | 3 +- .../monitor/v2018_09_01/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 31 +- .../mgmt/monitor/v2018_09_01/aio/_patch.py | 2 +- .../v2018_09_01/aio/operations/__init__.py | 7 +- .../operations/_action_groups_operations.py | 518 +++-- .../aio/operations/_baselines_operations.py | 76 +- .../v2018_09_01/aio/operations/_patch.py | 1 + .../monitor/v2018_09_01/models/__init__.py | 62 +- .../monitor/v2018_09_01/models/_models_py3.py | 794 +++---- .../_monitor_management_client_enums.py | 6 +- .../mgmt/monitor/v2018_09_01/models/_patch.py | 1 + .../v2018_09_01/operations/__init__.py | 7 +- .../operations/_action_groups_operations.py | 775 ++++--- .../operations/_baselines_operations.py | 116 +- .../monitor/v2018_09_01/operations/_patch.py | 1 + .../monitor/v2018_11_27_preview/__init__.py | 3 +- .../v2018_11_27_preview/_configuration.py | 39 +- .../v2018_11_27_preview/_metadata.json | 12 +- .../_monitor_management_client.py | 26 +- .../monitor/v2018_11_27_preview/_patch.py | 2 +- .../monitor/v2018_11_27_preview/_vendor.py | 6 +- .../monitor/v2018_11_27_preview/_version.py | 2 +- .../v2018_11_27_preview/aio/__init__.py | 3 +- .../v2018_11_27_preview/aio/_configuration.py | 41 +- .../aio/_monitor_management_client.py | 26 +- .../monitor/v2018_11_27_preview/aio/_patch.py | 2 +- .../aio/operations/__init__.py | 5 +- .../aio/operations/_patch.py | 1 + .../aio/operations/_vm_insights_operations.py | 48 +- .../v2018_11_27_preview/models/__init__.py | 26 +- .../v2018_11_27_preview/models/_models_py3.py | 157 +- .../_monitor_management_client_enums.py | 1 + .../v2018_11_27_preview/models/_patch.py | 1 + .../operations/__init__.py | 5 +- .../v2018_11_27_preview/operations/_patch.py | 1 + .../operations/_vm_insights_operations.py | 81 +- .../mgmt/monitor/v2019_03_01/__init__.py | 3 +- .../monitor/v2019_03_01/_configuration.py | 42 +- .../mgmt/monitor/v2019_03_01/_metadata.json | 18 +- .../v2019_03_01/_monitor_management_client.py | 31 +- .../azure/mgmt/monitor/v2019_03_01/_patch.py | 2 +- .../azure/mgmt/monitor/v2019_03_01/_vendor.py | 6 +- .../mgmt/monitor/v2019_03_01/_version.py | 2 +- .../mgmt/monitor/v2019_03_01/aio/__init__.py | 3 +- .../monitor/v2019_03_01/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 31 +- .../mgmt/monitor/v2019_03_01/aio/_patch.py | 2 +- .../v2019_03_01/aio/operations/__init__.py | 7 +- .../operations/_action_groups_operations.py | 518 +++-- .../aio/operations/_baselines_operations.py | 76 +- .../v2019_03_01/aio/operations/_patch.py | 1 + .../monitor/v2019_03_01/models/__init__.py | 62 +- .../monitor/v2019_03_01/models/_models_py3.py | 811 +++---- .../_monitor_management_client_enums.py | 6 +- .../mgmt/monitor/v2019_03_01/models/_patch.py | 1 + .../v2019_03_01/operations/__init__.py | 7 +- .../operations/_action_groups_operations.py | 775 ++++--- .../operations/_baselines_operations.py | 116 +- .../monitor/v2019_03_01/operations/_patch.py | 1 + .../mgmt/monitor/v2019_06_01/__init__.py | 3 +- .../monitor/v2019_06_01/_configuration.py | 42 +- .../mgmt/monitor/v2019_06_01/_metadata.json | 18 +- .../v2019_06_01/_monitor_management_client.py | 27 +- .../azure/mgmt/monitor/v2019_06_01/_patch.py | 2 +- .../azure/mgmt/monitor/v2019_06_01/_vendor.py | 6 +- .../mgmt/monitor/v2019_06_01/_version.py | 2 +- .../mgmt/monitor/v2019_06_01/aio/__init__.py | 3 +- .../monitor/v2019_06_01/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 27 +- .../mgmt/monitor/v2019_06_01/aio/_patch.py | 2 +- .../v2019_06_01/aio/operations/__init__.py | 5 +- .../operations/_action_groups_operations.py | 518 +++-- .../v2019_06_01/aio/operations/_patch.py | 1 + .../monitor/v2019_06_01/models/__init__.py | 42 +- .../monitor/v2019_06_01/models/_models_py3.py | 613 +++-- .../mgmt/monitor/v2019_06_01/models/_patch.py | 1 + .../v2019_06_01/operations/__init__.py | 5 +- .../operations/_action_groups_operations.py | 775 ++++--- .../monitor/v2019_06_01/operations/_patch.py | 1 + .../mgmt/monitor/v2019_10_17/__init__.py | 3 +- .../monitor/v2019_10_17/_configuration.py | 42 +- .../mgmt/monitor/v2019_10_17/_metadata.json | 18 +- .../v2019_10_17/_monitor_management_client.py | 31 +- .../azure/mgmt/monitor/v2019_10_17/_patch.py | 2 +- .../azure/mgmt/monitor/v2019_10_17/_vendor.py | 6 +- .../mgmt/monitor/v2019_10_17/_version.py | 2 +- .../mgmt/monitor/v2019_10_17/aio/__init__.py | 3 +- .../monitor/v2019_10_17/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 31 +- .../mgmt/monitor/v2019_10_17/aio/_patch.py | 2 +- .../v2019_10_17/aio/operations/__init__.py | 13 +- .../v2019_10_17/aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 380 ++-- .../_private_link_resources_operations.py | 115 +- ..._link_scope_operation_status_operations.py | 50 +- ...rivate_link_scoped_resources_operations.py | 383 ++-- .../_private_link_scopes_operations.py | 471 ++-- .../monitor/v2019_10_17/models/__init__.py | 38 +- .../monitor/v2019_10_17/models/_models_py3.py | 416 ++-- .../mgmt/monitor/v2019_10_17/models/_patch.py | 1 + .../v2019_10_17/operations/__init__.py | 13 +- .../monitor/v2019_10_17/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 526 +++-- .../_private_link_resources_operations.py | 192 +- ..._link_scope_operation_status_operations.py | 88 +- ...rivate_link_scoped_resources_operations.py | 547 ++--- .../_private_link_scopes_operations.py | 687 +++--- .../monitor/v2019_11_01_preview/__init__.py | 3 +- .../v2019_11_01_preview/_configuration.py | 42 +- .../v2019_11_01_preview/_metadata.json | 18 +- .../_monitor_management_client.py | 23 +- .../monitor/v2019_11_01_preview/_patch.py | 2 +- .../monitor/v2019_11_01_preview/_vendor.py | 6 +- .../monitor/v2019_11_01_preview/_version.py | 2 +- .../v2019_11_01_preview/aio/__init__.py | 3 +- .../v2019_11_01_preview/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 23 +- .../monitor/v2019_11_01_preview/aio/_patch.py | 2 +- .../aio/operations/__init__.py | 7 +- ...collection_rule_associations_operations.py | 334 +-- .../_data_collection_rules_operations.py | 437 ++-- .../aio/operations/_patch.py | 1 + .../v2019_11_01_preview/models/__init__.py | 94 +- .../v2019_11_01_preview/models/_models_py3.py | 622 +++-- .../_monitor_management_client_enums.py | 25 +- .../v2019_11_01_preview/models/_patch.py | 1 + .../operations/__init__.py | 7 +- ...collection_rule_associations_operations.py | 500 ++-- .../_data_collection_rules_operations.py | 660 +++--- .../v2019_11_01_preview/operations/_patch.py | 1 + .../monitor/v2020_01_01_preview/__init__.py | 3 +- .../v2020_01_01_preview/_configuration.py | 39 +- .../v2020_01_01_preview/_metadata.json | 12 +- .../_monitor_management_client.py | 22 +- .../monitor/v2020_01_01_preview/_patch.py | 2 +- .../monitor/v2020_01_01_preview/_vendor.py | 6 +- .../monitor/v2020_01_01_preview/_version.py | 2 +- .../v2020_01_01_preview/aio/__init__.py | 3 +- .../v2020_01_01_preview/aio/_configuration.py | 41 +- .../aio/_monitor_management_client.py | 22 +- .../monitor/v2020_01_01_preview/aio/_patch.py | 2 +- .../aio/operations/__init__.py | 5 +- ...nt_group_diagnostic_settings_operations.py | 254 ++- .../aio/operations/_patch.py | 1 + .../v2020_01_01_preview/models/__init__.py | 14 +- .../v2020_01_01_preview/models/_models_py3.py | 124 +- .../v2020_01_01_preview/models/_patch.py | 1 + .../operations/__init__.py | 5 +- ...nt_group_diagnostic_settings_operations.py | 395 ++-- .../v2020_01_01_preview/operations/_patch.py | 1 + .../monitor/v2020_05_01_preview/__init__.py | 3 +- .../v2020_05_01_preview/_configuration.py | 42 +- .../v2020_05_01_preview/_metadata.json | 18 +- .../_monitor_management_client.py | 23 +- .../monitor/v2020_05_01_preview/_patch.py | 2 +- .../monitor/v2020_05_01_preview/_vendor.py | 6 +- .../monitor/v2020_05_01_preview/_version.py | 2 +- .../v2020_05_01_preview/aio/__init__.py | 3 +- .../v2020_05_01_preview/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 23 +- .../monitor/v2020_05_01_preview/aio/_patch.py | 2 +- .../aio/operations/__init__.py | 5 +- .../aio/operations/_patch.py | 1 + .../_scheduled_query_rules_operations.py | 426 ++-- .../v2020_05_01_preview/models/__init__.py | 48 +- .../v2020_05_01_preview/models/_models_py3.py | 400 ++-- .../_monitor_management_client_enums.py | 15 +- .../v2020_05_01_preview/models/_patch.py | 1 + .../operations/__init__.py | 5 +- .../v2020_05_01_preview/operations/_patch.py | 1 + .../_scheduled_query_rules_operations.py | 655 +++--- .../mgmt/monitor/v2020_10_01/__init__.py | 3 +- .../monitor/v2020_10_01/_configuration.py | 42 +- .../mgmt/monitor/v2020_10_01/_metadata.json | 18 +- .../v2020_10_01/_monitor_management_client.py | 23 +- .../azure/mgmt/monitor/v2020_10_01/_patch.py | 2 +- .../azure/mgmt/monitor/v2020_10_01/_vendor.py | 6 +- .../mgmt/monitor/v2020_10_01/_version.py | 2 +- .../mgmt/monitor/v2020_10_01/aio/__init__.py | 3 +- .../monitor/v2020_10_01/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 23 +- .../mgmt/monitor/v2020_10_01/aio/_patch.py | 2 +- .../v2020_10_01/aio/operations/__init__.py | 5 +- .../_activity_log_alerts_operations.py | 426 ++-- .../v2020_10_01/aio/operations/_patch.py | 1 + .../monitor/v2020_10_01/models/__init__.py | 24 +- .../monitor/v2020_10_01/models/_models_py3.py | 274 +-- .../mgmt/monitor/v2020_10_01/models/_patch.py | 1 + .../v2020_10_01/operations/__init__.py | 5 +- .../_activity_log_alerts_operations.py | 639 +++--- .../monitor/v2020_10_01/operations/_patch.py | 1 + .../mgmt/monitor/v2021_04_01/__init__.py | 3 +- .../monitor/v2021_04_01/_configuration.py | 42 +- .../mgmt/monitor/v2021_04_01/_metadata.json | 18 +- .../v2021_04_01/_monitor_management_client.py | 29 +- .../azure/mgmt/monitor/v2021_04_01/_patch.py | 2 +- .../azure/mgmt/monitor/v2021_04_01/_vendor.py | 6 +- .../mgmt/monitor/v2021_04_01/_version.py | 2 +- .../mgmt/monitor/v2021_04_01/aio/__init__.py | 3 +- .../monitor/v2021_04_01/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 29 +- .../mgmt/monitor/v2021_04_01/aio/_patch.py | 2 +- .../v2021_04_01/aio/operations/__init__.py | 9 +- .../_data_collection_endpoints_operations.py | 436 ++-- ...collection_rule_associations_operations.py | 334 +-- .../_data_collection_rules_operations.py | 436 ++-- .../v2021_04_01/aio/operations/_patch.py | 1 + .../monitor/v2021_04_01/models/__init__.py | 138 +- .../monitor/v2021_04_01/models/_models_py3.py | 945 ++++---- .../_monitor_management_client_enums.py | 38 +- .../mgmt/monitor/v2021_04_01/models/_patch.py | 1 + .../v2021_04_01/operations/__init__.py | 9 +- .../_data_collection_endpoints_operations.py | 667 +++--- ...collection_rule_associations_operations.py | 500 ++-- .../_data_collection_rules_operations.py | 659 +++--- .../monitor/v2021_04_01/operations/_patch.py | 1 + .../monitor/v2021_05_01_preview/__init__.py | 3 +- .../v2021_05_01_preview/_configuration.py | 42 +- .../v2021_05_01_preview/_metadata.json | 18 +- .../_monitor_management_client.py | 32 +- .../monitor/v2021_05_01_preview/_patch.py | 2 +- .../monitor/v2021_05_01_preview/_vendor.py | 6 +- .../monitor/v2021_05_01_preview/_version.py | 2 +- .../v2021_05_01_preview/aio/__init__.py | 3 +- .../v2021_05_01_preview/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 32 +- .../monitor/v2021_05_01_preview/aio/_patch.py | 2 +- .../aio/operations/__init__.py | 15 +- .../_autoscale_settings_operations.py | 418 ++-- ...diagnostic_settings_category_operations.py | 108 +- .../_diagnostic_settings_operations.py | 245 +- ...nt_group_diagnostic_settings_operations.py | 254 ++- .../aio/operations/_patch.py | 1 + .../_predictive_metric_operations.py | 57 +- ...cription_diagnostic_settings_operations.py | 241 +- .../v2021_05_01_preview/models/__init__.py | 118 +- .../v2021_05_01_preview/models/_models_py3.py | 1100 +++++---- .../_monitor_management_client_enums.py | 32 +- .../v2021_05_01_preview/models/_patch.py | 1 + .../operations/__init__.py | 15 +- .../_autoscale_settings_operations.py | 631 +++--- ...diagnostic_settings_category_operations.py | 163 +- .../_diagnostic_settings_operations.py | 366 ++- ...nt_group_diagnostic_settings_operations.py | 395 ++-- .../v2021_05_01_preview/operations/_patch.py | 1 + .../_predictive_metric_operations.py | 102 +- ...cription_diagnostic_settings_operations.py | 374 ++- .../mgmt/monitor/v2021_09_01/__init__.py | 3 +- .../monitor/v2021_09_01/_configuration.py | 42 +- .../mgmt/monitor/v2021_09_01/_metadata.json | 18 +- .../v2021_09_01/_monitor_management_client.py | 27 +- .../azure/mgmt/monitor/v2021_09_01/_patch.py | 2 +- .../azure/mgmt/monitor/v2021_09_01/_vendor.py | 6 +- .../mgmt/monitor/v2021_09_01/_version.py | 2 +- .../mgmt/monitor/v2021_09_01/aio/__init__.py | 3 +- .../monitor/v2021_09_01/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 27 +- .../mgmt/monitor/v2021_09_01/aio/_patch.py | 2 +- .../v2021_09_01/aio/operations/__init__.py | 5 +- .../operations/_action_groups_operations.py | 1127 +++++---- .../v2021_09_01/aio/operations/_patch.py | 1 + .../monitor/v2021_09_01/models/__init__.py | 52 +- .../monitor/v2021_09_01/models/_models_py3.py | 743 +++--- .../mgmt/monitor/v2021_09_01/models/_patch.py | 1 + .../v2021_09_01/operations/__init__.py | 5 +- .../operations/_action_groups_operations.py | 1623 +++++++------ .../monitor/v2021_09_01/operations/_patch.py | 1 + .../monitor/v2022_02_01_preview/__init__.py | 3 +- .../v2022_02_01_preview/_configuration.py | 42 +- .../v2022_02_01_preview/_metadata.json | 18 +- .../_monitor_management_client.py | 29 +- .../monitor/v2022_02_01_preview/_patch.py | 2 +- .../monitor/v2022_02_01_preview/_vendor.py | 6 +- .../monitor/v2022_02_01_preview/_version.py | 2 +- .../v2022_02_01_preview/aio/__init__.py | 3 +- .../v2022_02_01_preview/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 29 +- .../monitor/v2022_02_01_preview/aio/_patch.py | 2 +- .../aio/operations/__init__.py | 9 +- .../_data_collection_endpoints_operations.py | 437 ++-- ...collection_rule_associations_operations.py | 401 ++-- .../_data_collection_rules_operations.py | 437 ++-- .../aio/operations/_patch.py | 1 + .../v2022_02_01_preview/models/__init__.py | 172 +- .../v2022_02_01_preview/models/_models_py3.py | 1191 +++++----- .../_monitor_management_client_enums.py | 50 +- .../v2022_02_01_preview/models/_patch.py | 1 + .../operations/__init__.py | 9 +- .../_data_collection_endpoints_operations.py | 668 +++--- ...collection_rule_associations_operations.py | 602 +++-- .../_data_collection_rules_operations.py | 660 +++--- .../v2022_02_01_preview/operations/_patch.py | 1 + .../mgmt/monitor/v2022_04_01/__init__.py | 3 +- .../monitor/v2022_04_01/_configuration.py | 42 +- .../mgmt/monitor/v2022_04_01/_metadata.json | 18 +- .../v2022_04_01/_monitor_management_client.py | 27 +- .../azure/mgmt/monitor/v2022_04_01/_patch.py | 1 + .../azure/mgmt/monitor/v2022_04_01/_vendor.py | 6 +- .../mgmt/monitor/v2022_04_01/_version.py | 2 +- .../mgmt/monitor/v2022_04_01/aio/__init__.py | 3 +- .../monitor/v2022_04_01/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 27 +- .../mgmt/monitor/v2022_04_01/aio/_patch.py | 1 + .../v2022_04_01/aio/operations/__init__.py | 5 +- .../operations/_action_groups_operations.py | 911 +++++--- .../v2022_04_01/aio/operations/_patch.py | 1 + .../monitor/v2022_04_01/models/__init__.py | 52 +- .../monitor/v2022_04_01/models/_models_py3.py | 743 +++--- .../mgmt/monitor/v2022_04_01/models/_patch.py | 1 + .../v2022_04_01/operations/__init__.py | 5 +- .../operations/_action_groups_operations.py | 1323 ++++++----- .../monitor/v2022_04_01/operations/_patch.py | 1 + .../mgmt/monitor/v2022_06_01/__init__.py | 3 +- .../monitor/v2022_06_01/_configuration.py | 42 +- .../mgmt/monitor/v2022_06_01/_metadata.json | 18 +- .../v2022_06_01/_monitor_management_client.py | 27 +- .../azure/mgmt/monitor/v2022_06_01/_patch.py | 1 + .../azure/mgmt/monitor/v2022_06_01/_vendor.py | 6 +- .../mgmt/monitor/v2022_06_01/_version.py | 2 +- .../mgmt/monitor/v2022_06_01/aio/__init__.py | 3 +- .../monitor/v2022_06_01/aio/_configuration.py | 44 +- .../aio/_monitor_management_client.py | 27 +- .../mgmt/monitor/v2022_06_01/aio/_patch.py | 1 + .../v2022_06_01/aio/operations/__init__.py | 5 +- .../operations/_action_groups_operations.py | 1127 +++++---- .../v2022_06_01/aio/operations/_patch.py | 1 + .../monitor/v2022_06_01/models/__init__.py | 52 +- .../monitor/v2022_06_01/models/_models_py3.py | 743 +++--- .../mgmt/monitor/v2022_06_01/models/_patch.py | 1 + .../v2022_06_01/operations/__init__.py | 5 +- .../operations/_action_groups_operations.py | 1623 +++++++------ .../monitor/v2022_06_01/operations/_patch.py | 1 + 638 files changed, 40909 insertions(+), 33980 deletions(-) create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_serialization.py diff --git a/sdk/monitor/azure-mgmt-monitor/_meta.json b/sdk/monitor/azure-mgmt-monitor/_meta.json index 05469ca29a65..10ae4ec91eb5 100644 --- a/sdk/monitor/azure-mgmt-monitor/_meta.json +++ b/sdk/monitor/azure-mgmt-monitor/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "autorest": "3.8.4", "use": [ - "@autorest/python@5.16.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.0.1", + "@autorest/modelerfour@4.23.5" ], - "commit": "0a4e1e98112a37f70e46a26ec1598d41d8c4b363", + "commit": "f1279806892fbe2439867762216047042e4da504", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/monitor/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/monitor/resource-manager/readme.md --models-mode=msrest --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.0.1 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False", "readme": "specification/monitor/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py index 7a92a65b34c6..57808e3f861c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py @@ -8,7 +8,7 @@ # 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 @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class MonitorManagementClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class MonitorManagementClientConfiguration(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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py index 431823c7e802..5fa704e3848e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +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 ._configuration import MonitorManagementClientConfiguration +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 class _SDKClient(object): @@ -43,9 +40,9 @@ class MonitorManagementClient(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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. 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 @@ -100,10 +97,10 @@ class MonitorManagementClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_serialization.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_serialization.py new file mode 100644 index 000000000000..2e44d8666b2b --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# 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 + +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 +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +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, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> 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, headers): + # type: (Optional[Union[AnyStr, IO]], 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 # type: ignore + unicode_str = str # type: ignore + +_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 +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 # type: ignore +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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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) + 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) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _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 = [ + 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): + # 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) + return result + except ValueError: + for enum_value in enum_obj: + 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 + 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 + 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.warning( + "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) + 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) + 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): + 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)) + + @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) + attr = attr + padding + 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) + 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) + + @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): + 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): + 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) + 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() + 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) + 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 \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py index d1088d0ae2a5..fdcdf086fd99 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py @@ -26,9 +26,9 @@ class MonitorManagementClientConfiguration(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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py index 9f48f75a56f5..ddc1418236b6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class MonitorManagementClient(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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py index b152f1a01ba7..cdc7a049c1d9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py @@ -25,18 +25,13 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,23 +40,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json index b271c6f03d5c..32646c78f4e3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py index f5dd17d46833..221fd063eb4c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py @@ -9,20 +9,27 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import ActivityLogsOperations, AlertRulesOperations, AutoscaleSettingsOperations, EventCategoriesOperations, Operations, TenantActivityLogsOperations +from .operations import ( + ActivityLogsOperations, + AlertRulesOperations, + AutoscaleSettingsOperations, + EventCategoriesOperations, + Operations, + TenantActivityLogsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar activity_logs: ActivityLogsOperations operations @@ -40,9 +47,9 @@ class MonitorManagementClient: $(python-base-namespace).v2015_04_01.operations.TenantActivityLogsOperations :ivar alert_rules: AlertRulesOperations operations :vartype alert_rules: $(python-base-namespace).v2015_04_01.operations.AlertRulesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -55,38 +62,29 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.activity_logs = ActivityLogsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.activity_logs = ActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) self.autoscale_settings = AutoscaleSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) self.event_categories = EventCategoriesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.tenant_activity_logs = TenantActivityLogsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.alert_rules = AlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -95,7 +93,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py index fe42fc99d8d7..ff77a05cbd87 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py @@ -25,18 +25,13 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,22 +40,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py index b9409ed878ba..e0c4dedc5c97 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py @@ -9,20 +9,27 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import ActivityLogsOperations, AlertRulesOperations, AutoscaleSettingsOperations, EventCategoriesOperations, Operations, TenantActivityLogsOperations +from .operations import ( + ActivityLogsOperations, + AlertRulesOperations, + AutoscaleSettingsOperations, + EventCategoriesOperations, + Operations, + TenantActivityLogsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar activity_logs: ActivityLogsOperations operations @@ -41,9 +48,9 @@ class MonitorManagementClient: $(python-base-namespace).v2015_04_01.aio.operations.TenantActivityLogsOperations :ivar alert_rules: AlertRulesOperations operations :vartype alert_rules: $(python-base-namespace).v2015_04_01.aio.operations.AlertRulesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -56,38 +63,29 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.activity_logs = ActivityLogsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.activity_logs = ActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) self.autoscale_settings = AutoscaleSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) self.event_categories = EventCategoriesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.tenant_activity_logs = TenantActivityLogsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.alert_rules = AlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -96,7 +94,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/__init__.py index 3f665d258d3a..4c1cd2bf4a61 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/__init__.py @@ -16,13 +16,14 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActivityLogsOperations', - 'AutoscaleSettingsOperations', - 'EventCategoriesOperations', - 'Operations', - 'TenantActivityLogsOperations', - 'AlertRulesOperations', + "ActivityLogsOperations", + "AutoscaleSettingsOperations", + "EventCategoriesOperations", + "Operations", + "TenantActivityLogsOperations", + "AlertRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py index 0fc2c29a2b19..fe807d6b7657 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py @@ -9,7 +9,13 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +26,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._activity_logs_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ActivityLogsOperations: """ .. warning:: @@ -42,14 +50,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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: str, - select: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[_models.EventDataCollection]: + def list(self, filter: str, select: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.EventData"]: """Provides the list of records from the activity logs. :param filter: Reduces the set of data collected.:code:`
`This argument is required and it @@ -66,7 +68,7 @@ def list( '2014-07-20T04:36:37.6407898Z' and resourceProvider eq 'resourceProviderName'.:code:`
`- *List events for a correlation Id*\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq - 'correlationID'.:code:`
`:code:`
`\ **NOTE**\ : No other syntax is allowed. + 'correlationID'.:code:`
`:code:`
`\ **NOTE**\ : No other syntax is allowed. Required. :type filter: str :param select: Used to fetch events with only the given properties.:code:`
`The **$select** argument is a comma separated list of property names to be returned. Possible values are: @@ -76,34 +78,30 @@ def list( *resourceId*\ , *status*\ , *submissionTimestamp*\ , *subStatus*\ , *subscriptionId*. Default value is None. :type select: str - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventDataCollection or the result of cls(response) + :return: An iterator like instance of either EventData or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventData] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventDataCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventDataCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, select=select, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -111,16 +109,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - select=select, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -136,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -150,8 +137,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py index 3c42ca8e8a12..355371c2e9d2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +26,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._alert_rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._alert_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AlertRulesOperations: """ .. warning:: @@ -43,44 +58,101 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, rule_name: str, parameters: _models.AlertRuleResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AlertRuleResource: """Creates or updates a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. + :param parameters: The parameters of the rule to create or update. Required. :type parameters: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Creates or updates a classic metric alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, rule_name: str, parameters: Union[_models.AlertRuleResource, IO], **kwargs: Any + ) -> _models.AlertRuleResource: + """Creates or updates a classic metric alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a model type or a + IO type. Required. + :type parameters: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - _json = self._serialize.body(parameters, 'AlertRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AlertRuleResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -89,7 +161,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -97,10 +170,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -109,58 +181,49 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, **kwargs: Any ) -> None: """Deletes a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -168,10 +231,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -182,48 +244,37 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.AlertRuleResource: + async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: """Gets a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - request = build_get_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -231,10 +282,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -242,63 +292,128 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + alert_rules_resource: _models.AlertRuleResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Updates an existing classic metric AlertRuleResource. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param alert_rules_resource: Parameters supplied to the operation. Required. + :type alert_rules_resource: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + alert_rules_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Updates an existing classic metric AlertRuleResource. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param alert_rules_resource: Parameters supplied to the operation. Required. + :type alert_rules_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, rule_name: str, - alert_rules_resource: _models.AlertRuleResourcePatch, + alert_rules_resource: Union[_models.AlertRuleResourcePatch, IO], **kwargs: Any ) -> _models.AlertRuleResource: """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. + :param alert_rules_resource: Parameters supplied to the operation. Is either a model type or a + IO type. Required. :type alert_rules_resource: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResourcePatch - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(alert_rules_resource, (IO, bytes)): + _content = alert_rules_resource + else: + _json = self._serialize.body(alert_rules_resource, "AlertRuleResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -306,10 +421,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -318,57 +432,50 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.AlertRuleResourceCollection]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AlertRuleResource"]: """List the classic metric alert rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AlertRuleResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -376,15 +483,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -400,10 +499,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -414,46 +511,36 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.AlertRuleResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AlertRuleResource"]: """List the classic metric alert rules within a subscription. - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AlertRuleResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -461,14 +548,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -484,10 +564,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -498,8 +576,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py index 920885d30077..87cfecc102f1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +26,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._autoscale_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._autoscale_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AutoscaleSettingsOperations: """ .. warning:: @@ -43,45 +58,39 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.AutoscaleSettingResourceCollection]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AutoscaleSettingResource"]: """Lists the autoscale settings for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either AutoscaleSettingResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -89,15 +98,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -113,10 +114,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,49 +126,109 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, autoscale_setting_name: str, parameters: _models.AutoscaleSettingResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AutoscaleSettingResource: """Creates or updates an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: Union[_models.AutoscaleSettingResource, IO], + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AutoscaleSettingResource, or the result of cls(response) + :return: AutoscaleSettingResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] - _json = self._serialize.body(parameters, 'AutoscaleSettingResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AutoscaleSettingResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -178,7 +237,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -186,10 +246,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -198,58 +257,49 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - autoscale_setting_name: str, - **kwargs: Any + self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any ) -> None: """Deletes and autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -257,10 +307,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -271,48 +320,39 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - autoscale_setting_name: str, - **kwargs: Any + self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any ) -> _models.AutoscaleSettingResource: """Gets an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource, or the result of cls(response) + :return: AutoscaleSettingResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] - request = build_get_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -320,10 +360,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -331,64 +370,129 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, autoscale_setting_name: str, autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AutoscaleSettingResource: """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. + :param autoscale_setting_resource: Parameters supplied to the operation. Required. :type autoscale_setting_resource: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourcePatch - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Required. + :type autoscale_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AutoscaleSettingResource, or the result of cls(response) + :return: AutoscaleSettingResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: Union[_models.AutoscaleSettingResourcePatch, IO], + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Is either a model type + or a IO type. Required. + :type autoscale_setting_resource: + ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] - _json = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(autoscale_setting_resource, (IO, bytes)): + _content = autoscale_setting_resource + else: + _json = self._serialize.body(autoscale_setting_resource, "AutoscaleSettingResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -396,10 +500,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,50 +510,42 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.AutoscaleSettingResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AutoscaleSettingResource"]: """Lists the autoscale settings for a subscription. - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either AutoscaleSettingResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -458,14 +553,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -481,10 +569,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -495,8 +581,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py index 2700dcfb9c68..49e07feb5eae 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py @@ -9,7 +9,13 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +26,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._event_categories_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EventCategoriesOperations: """ .. warning:: @@ -42,42 +50,33 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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.EventCategoryCollection]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.LocalizableString"]: """Get the list of available event categories supported in the Activity Logs Service.:code:`
`The current list includes the following: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventCategoryCollection or the result of - cls(response) + :return: An iterator like instance of either LocalizableString or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventCategoryCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.LocalizableString] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventCategoryCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventCategoryCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -85,13 +84,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -107,10 +100,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -121,8 +112,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Insights/eventcategories"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Insights/eventcategories"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py index 0f242211eeda..74a4d2a2f574 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -41,37 +49,27 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 list( - self, - **kwargs: Any - ) -> _models.OperationListResult: + async def list(self, **kwargs: Any) -> _models.OperationListResult: """Lists all of the available operations from Microsoft.Insights provider. - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult, or the result of cls(response) + :return: OperationListResult or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.OperationListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,22 +77,20 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/providers/Microsoft.Insights/operations"} # type: ignore - + list.metadata = {"url": "/providers/Microsoft.Insights/operations"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py index b567f1c75f68..4b1650a920b4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py @@ -9,7 +9,13 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +26,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._tenant_activity_logs_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TenantActivityLogsOperations: """ .. warning:: @@ -42,14 +50,10 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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, - select: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[_models.EventDataCollection]: + self, filter: Optional[str] = None, select: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.EventData"]: """Gets the Activity Logs for the Tenant.:code:`
`Everything that is applicable to the API to get the Activity Logs for the subscription is applicable to this API (the parameters, $filter, etc.).:code:`
`One thing to point out here is that this API does *not* retrieve the logs at @@ -81,33 +85,29 @@ def list( *resourceId*\ , *status*\ , *submissionTimestamp*\ , *subStatus*\ , *subscriptionId*. Default value is None. :type select: str - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventDataCollection or the result of cls(response) + :return: An iterator like instance of either EventData or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventData] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventDataCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventDataCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - api_version=api_version, filter=filter, select=select, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -115,15 +115,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - filter=filter, - select=select, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -139,10 +131,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +143,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Insights/eventtypes/management/values"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Insights/eventtypes/management/values"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py index f1a5ddd891b9..89233bd86942 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py @@ -48,74 +48,72 @@ from ._models_py3 import TimeWindow from ._models_py3 import WebhookNotification - -from ._monitor_management_client_enums import ( - ComparisonOperationType, - ConditionOperator, - EventLevel, - MetricStatisticType, - RecurrenceFrequency, - ScaleDirection, - ScaleRuleMetricDimensionOperationType, - ScaleType, - TimeAggregationOperator, - TimeAggregationType, -) +from ._monitor_management_client_enums import ComparisonOperationType +from ._monitor_management_client_enums import ConditionOperator +from ._monitor_management_client_enums import EventLevel +from ._monitor_management_client_enums import MetricStatisticType +from ._monitor_management_client_enums import RecurrenceFrequency +from ._monitor_management_client_enums import ScaleDirection +from ._monitor_management_client_enums import ScaleRuleMetricDimensionOperationType +from ._monitor_management_client_enums import ScaleType +from ._monitor_management_client_enums import TimeAggregationOperator +from ._monitor_management_client_enums import TimeAggregationType from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AlertRuleResource', - 'AlertRuleResourceCollection', - 'AlertRuleResourcePatch', - 'AutoscaleNotification', - 'AutoscaleProfile', - 'AutoscaleSettingResource', - 'AutoscaleSettingResourceCollection', - 'AutoscaleSettingResourcePatch', - 'EmailNotification', - 'ErrorResponse', - 'EventCategoryCollection', - 'EventData', - 'EventDataCollection', - 'HttpRequestInfo', - 'LocalizableString', - 'LocationThresholdRuleCondition', - 'ManagementEventAggregationCondition', - 'ManagementEventRuleCondition', - 'MetricTrigger', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Recurrence', - 'RecurrentSchedule', - 'Resource', - 'RuleAction', - 'RuleCondition', - 'RuleDataSource', - 'RuleEmailAction', - 'RuleManagementEventClaimsDataSource', - 'RuleManagementEventDataSource', - 'RuleMetricDataSource', - 'RuleWebhookAction', - 'ScaleAction', - 'ScaleCapacity', - 'ScaleRule', - 'ScaleRuleMetricDimension', - 'SenderAuthorization', - 'ThresholdRuleCondition', - 'TimeWindow', - 'WebhookNotification', - 'ComparisonOperationType', - 'ConditionOperator', - 'EventLevel', - 'MetricStatisticType', - 'RecurrenceFrequency', - 'ScaleDirection', - 'ScaleRuleMetricDimensionOperationType', - 'ScaleType', - 'TimeAggregationOperator', - 'TimeAggregationType', + "AlertRuleResource", + "AlertRuleResourceCollection", + "AlertRuleResourcePatch", + "AutoscaleNotification", + "AutoscaleProfile", + "AutoscaleSettingResource", + "AutoscaleSettingResourceCollection", + "AutoscaleSettingResourcePatch", + "EmailNotification", + "ErrorResponse", + "EventCategoryCollection", + "EventData", + "EventDataCollection", + "HttpRequestInfo", + "LocalizableString", + "LocationThresholdRuleCondition", + "ManagementEventAggregationCondition", + "ManagementEventRuleCondition", + "MetricTrigger", + "Operation", + "OperationDisplay", + "OperationListResult", + "Recurrence", + "RecurrentSchedule", + "Resource", + "RuleAction", + "RuleCondition", + "RuleDataSource", + "RuleEmailAction", + "RuleManagementEventClaimsDataSource", + "RuleManagementEventDataSource", + "RuleMetricDataSource", + "RuleWebhookAction", + "ScaleAction", + "ScaleCapacity", + "ScaleRule", + "ScaleRuleMetricDimension", + "SenderAuthorization", + "ThresholdRuleCondition", + "TimeWindow", + "WebhookNotification", + "ComparisonOperationType", + "ConditionOperator", + "EventLevel", + "MetricStatisticType", + "RecurrenceFrequency", + "ScaleDirection", + "ScaleRuleMetricDimensionOperationType", + "ScaleType", + "TimeAggregationOperator", + "TimeAggregationType", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py index 73f6e817959a..969ead3a7ab5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_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. @@ -9,15 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -30,41 +30,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -72,7 +66,7 @@ def __init__( self.tags = tags -class AlertRuleResource(Resource): +class AlertRuleResource(Resource): # pylint: disable=too-many-instance-attributes """The alert rule resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -85,19 +79,19 @@ class AlertRuleResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar name_properties_name: Required. the name of the alert rule. + :ivar name_properties_name: the name of the alert rule. Required. :vartype name_properties_name: str :ivar description: the description of the alert rule that will be included in the alert email. :vartype description: str :ivar provisioning_state: the provisioning state. :vartype provisioning_state: str - :ivar is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :ivar is_enabled: the flag that indicates whether the alert rule is enabled. Required. :vartype is_enabled: bool - :ivar condition: Required. the condition that results in the alert rule being activated. + :ivar condition: the condition that results in the alert rule being activated. Required. :vartype condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. @@ -110,30 +104,30 @@ class AlertRuleResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'name_properties_name': {'required': True}, - 'is_enabled': {'required': True}, - 'condition': {'required': True}, - 'last_updated_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "name_properties_name": {"required": True}, + "is_enabled": {"required": True}, + "condition": {"required": True}, + "last_updated_time": {"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}'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'RuleCondition'}, - 'action': {'key': 'properties.action', 'type': 'RuleAction'}, - 'actions': {'key': 'properties.actions', 'type': '[RuleAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, + "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}"}, + "name_properties_name": {"key": "properties.name", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, + "condition": {"key": "properties.condition", "type": "RuleCondition"}, + "action": {"key": "properties.action", "type": "RuleAction"}, + "actions": {"key": "properties.actions", "type": "[RuleAction]"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, } def __init__( @@ -151,20 +145,20 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword name_properties_name: Required. the name of the alert rule. + :keyword name_properties_name: the name of the alert rule. Required. :paramtype name_properties_name: str :keyword description: the description of the alert rule that will be included in the alert email. :paramtype description: str :keyword provisioning_state: the provisioning state. :paramtype provisioning_state: str - :keyword is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :keyword is_enabled: the flag that indicates whether the alert rule is enabled. Required. :paramtype is_enabled: bool - :keyword condition: Required. the condition that results in the alert rule being activated. + :keyword condition: the condition that results in the alert rule being activated. Required. :paramtype condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition :keyword action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. @@ -173,7 +167,7 @@ def __init__( and when an alert condition is resolved. :paramtype actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] """ - super(AlertRuleResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.name_properties_name = name_properties_name self.description = description self.provisioning_state = provisioning_state @@ -184,7 +178,7 @@ def __init__( self.last_updated_time = None -class AlertRuleResourceCollection(msrest.serialization.Model): +class AlertRuleResourceCollection(_serialization.Model): """Represents a collection of alert rule resources. :ivar value: the values for the alert rule resources. @@ -192,29 +186,24 @@ class AlertRuleResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AlertRuleResource]'}, + "value": {"key": "value", "type": "[AlertRuleResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.AlertRuleResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs): """ :keyword value: the values for the alert rule resources. :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.AlertRuleResource] """ - super(AlertRuleResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class AlertRuleResourcePatch(msrest.serialization.Model): +class AlertRuleResourcePatch(_serialization.Model): """The alert rule object for patch operations. Variables are only populated by the server, and will be ignored when sending a request. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar name: the name of the alert rule. :vartype name: str @@ -237,19 +226,19 @@ class AlertRuleResourcePatch(msrest.serialization.Model): """ _validation = { - 'last_updated_time': {'readonly': True}, + "last_updated_time": {"readonly": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'properties.name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'RuleCondition'}, - 'action': {'key': 'properties.action', 'type': 'RuleAction'}, - 'actions': {'key': 'properties.actions', 'type': '[RuleAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, + "tags": {"key": "tags", "type": "{str}"}, + "name": {"key": "properties.name", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, + "condition": {"key": "properties.condition", "type": "RuleCondition"}, + "action": {"key": "properties.action", "type": "RuleAction"}, + "actions": {"key": "properties.actions", "type": "[RuleAction]"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, } def __init__( @@ -266,7 +255,7 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword name: the name of the alert rule. :paramtype name: str @@ -286,7 +275,7 @@ def __init__( and when an alert condition is resolved. :paramtype actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] """ - super(AlertRuleResourcePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.name = name self.description = description @@ -298,7 +287,7 @@ def __init__( self.last_updated_time = None -class AutoscaleNotification(msrest.serialization.Model): +class AutoscaleNotification(_serialization.Model): """Autoscale notification. Variables are only populated by the server, and will be ignored when sending a request. @@ -306,7 +295,7 @@ class AutoscaleNotification(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar operation: the operation associated with the notification and its value must be "scale". - Has constant value: "Scale". + Required. Default value is "Scale". :vartype operation: str :ivar email: the email notification. :vartype email: ~$(python-base-namespace).v2015_04_01.models.EmailNotification @@ -315,13 +304,13 @@ class AutoscaleNotification(msrest.serialization.Model): """ _validation = { - 'operation': {'required': True, 'constant': True}, + "operation": {"required": True, "constant": True}, } _attribute_map = { - 'operation': {'key': 'operation', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'EmailNotification'}, - 'webhooks': {'key': 'webhooks', 'type': '[WebhookNotification]'}, + "operation": {"key": "operation", "type": "str"}, + "email": {"key": "email", "type": "EmailNotification"}, + "webhooks": {"key": "webhooks", "type": "[WebhookNotification]"}, } operation = "Scale" @@ -339,22 +328,22 @@ def __init__( :keyword webhooks: the collection of webhook notifications. :paramtype webhooks: list[~$(python-base-namespace).v2015_04_01.models.WebhookNotification] """ - super(AutoscaleNotification, self).__init__(**kwargs) + super().__init__(**kwargs) self.email = email self.webhooks = webhooks -class AutoscaleProfile(msrest.serialization.Model): +class AutoscaleProfile(_serialization.Model): """Autoscale profile. All required parameters must be populated in order to send to Azure. - :ivar name: Required. the name of the profile. + :ivar name: the name of the profile. Required. :vartype name: str - :ivar capacity: Required. the number of instances that can be used during this profile. + :ivar capacity: the number of instances that can be used during this profile. Required. :vartype capacity: ~$(python-base-namespace).v2015_04_01.models.ScaleCapacity - :ivar rules: Required. the collection of rules that provide the triggers and parameters for the - scaling action. A maximum of 10 rules can be specified. + :ivar rules: the collection of rules that provide the triggers and parameters for the scaling + action. A maximum of 10 rules can be specified. Required. :vartype rules: list[~$(python-base-namespace).v2015_04_01.models.ScaleRule] :ivar fixed_date: the specific date-time for the profile. This element is not used if the Recurrence element is used. @@ -365,17 +354,17 @@ class AutoscaleProfile(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'capacity': {'required': True}, - 'rules': {'required': True}, + "name": {"required": True}, + "capacity": {"required": True}, + "rules": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'ScaleCapacity'}, - 'rules': {'key': 'rules', 'type': '[ScaleRule]'}, - 'fixed_date': {'key': 'fixedDate', 'type': 'TimeWindow'}, - 'recurrence': {'key': 'recurrence', 'type': 'Recurrence'}, + "name": {"key": "name", "type": "str"}, + "capacity": {"key": "capacity", "type": "ScaleCapacity"}, + "rules": {"key": "rules", "type": "[ScaleRule]"}, + "fixed_date": {"key": "fixedDate", "type": "TimeWindow"}, + "recurrence": {"key": "recurrence", "type": "Recurrence"}, } def __init__( @@ -389,12 +378,12 @@ def __init__( **kwargs ): """ - :keyword name: Required. the name of the profile. + :keyword name: the name of the profile. Required. :paramtype name: str - :keyword capacity: Required. the number of instances that can be used during this profile. + :keyword capacity: the number of instances that can be used during this profile. Required. :paramtype capacity: ~$(python-base-namespace).v2015_04_01.models.ScaleCapacity - :keyword rules: Required. the collection of rules that provide the triggers and parameters for - the scaling action. A maximum of 10 rules can be specified. + :keyword rules: the collection of rules that provide the triggers and parameters for the + scaling action. A maximum of 10 rules can be specified. Required. :paramtype rules: list[~$(python-base-namespace).v2015_04_01.models.ScaleRule] :keyword fixed_date: the specific date-time for the profile. This element is not used if the Recurrence element is used. @@ -403,7 +392,7 @@ def __init__( if the FixedDate element is used. :paramtype recurrence: ~$(python-base-namespace).v2015_04_01.models.Recurrence """ - super(AutoscaleProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.capacity = capacity self.rules = rules @@ -411,7 +400,7 @@ def __init__( self.recurrence = recurrence -class AutoscaleSettingResource(Resource): +class AutoscaleSettingResource(Resource): # pylint: disable=too-many-instance-attributes """The autoscale setting resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -424,12 +413,12 @@ class AutoscaleSettingResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar profiles: Required. the collection of automatic scaling profiles that specify different - scaling parameters for different time periods. A maximum of 20 profiles can be specified. + :ivar profiles: the collection of automatic scaling profiles that specify different scaling + parameters for different time periods. A maximum of 20 profiles can be specified. Required. :vartype profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] :ivar notifications: the collection of notifications. :vartype notifications: @@ -448,25 +437,25 @@ class AutoscaleSettingResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'profiles': {'required': True, 'max_items': 20, 'min_items': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "profiles": {"required": True, "max_items": 20, "min_items": 0}, } _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}'}, - 'profiles': {'key': 'properties.profiles', 'type': '[AutoscaleProfile]'}, - 'notifications': {'key': 'properties.notifications', 'type': '[AutoscaleNotification]'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'target_resource_uri': {'key': 'properties.targetResourceUri', 'type': 'str'}, - 'target_resource_location': {'key': 'properties.targetResourceLocation', 'type': 'str'}, + "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}"}, + "profiles": {"key": "properties.profiles", "type": "[AutoscaleProfile]"}, + "notifications": {"key": "properties.notifications", "type": "[AutoscaleNotification]"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "name_properties_name": {"key": "properties.name", "type": "str"}, + "target_resource_uri": {"key": "properties.targetResourceUri", "type": "str"}, + "target_resource_location": {"key": "properties.targetResourceLocation", "type": "str"}, } def __init__( @@ -476,20 +465,19 @@ def __init__( profiles: List["_models.AutoscaleProfile"], tags: Optional[Dict[str, str]] = None, notifications: Optional[List["_models.AutoscaleNotification"]] = None, - enabled: Optional[bool] = False, + enabled: bool = False, name_properties_name: Optional[str] = None, target_resource_uri: Optional[str] = None, target_resource_location: Optional[str] = None, **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword profiles: Required. the collection of automatic scaling profiles that specify - different scaling parameters for different time periods. A maximum of 20 profiles can be - specified. + :keyword profiles: the collection of automatic scaling profiles that specify different scaling + parameters for different time periods. A maximum of 20 profiles can be specified. Required. :paramtype profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] :keyword notifications: the collection of notifications. :paramtype notifications: @@ -506,7 +494,7 @@ def __init__( should be added to. :paramtype target_resource_location: str """ - super(AutoscaleSettingResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.profiles = profiles self.notifications = notifications self.enabled = enabled @@ -515,48 +503,42 @@ def __init__( self.target_resource_location = target_resource_location -class AutoscaleSettingResourceCollection(msrest.serialization.Model): +class AutoscaleSettingResourceCollection(_serialization.Model): """Represents a collection of autoscale setting resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the values for the autoscale setting resources. + :ivar value: the values for the autoscale setting resources. Required. :vartype value: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource] :ivar next_link: URL to get the next set of results. :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[AutoscaleSettingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AutoscaleSettingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["_models.AutoscaleSettingResource"], - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs): """ - :keyword value: Required. the values for the autoscale setting resources. + :keyword value: the values for the autoscale setting resources. Required. :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource] :keyword next_link: URL to get the next set of results. :paramtype next_link: str """ - super(AutoscaleSettingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class AutoscaleSettingResourcePatch(msrest.serialization.Model): +class AutoscaleSettingResourcePatch(_serialization.Model): """The autoscale setting object for patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar profiles: the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. @@ -578,17 +560,17 @@ class AutoscaleSettingResourcePatch(msrest.serialization.Model): """ _validation = { - 'profiles': {'max_items': 20, 'min_items': 0}, + "profiles": {"max_items": 20, "min_items": 0}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'profiles': {'key': 'properties.profiles', 'type': '[AutoscaleProfile]'}, - 'notifications': {'key': 'properties.notifications', 'type': '[AutoscaleNotification]'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'name': {'key': 'properties.name', 'type': 'str'}, - 'target_resource_uri': {'key': 'properties.targetResourceUri', 'type': 'str'}, - 'target_resource_location': {'key': 'properties.targetResourceLocation', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "profiles": {"key": "properties.profiles", "type": "[AutoscaleProfile]"}, + "notifications": {"key": "properties.notifications", "type": "[AutoscaleNotification]"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "name": {"key": "properties.name", "type": "str"}, + "target_resource_uri": {"key": "properties.targetResourceUri", "type": "str"}, + "target_resource_location": {"key": "properties.targetResourceLocation", "type": "str"}, } def __init__( @@ -597,14 +579,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, profiles: Optional[List["_models.AutoscaleProfile"]] = None, notifications: Optional[List["_models.AutoscaleNotification"]] = None, - enabled: Optional[bool] = False, + enabled: bool = False, name: Optional[str] = None, target_resource_uri: Optional[str] = None, target_resource_location: Optional[str] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword profiles: the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. @@ -624,7 +606,7 @@ def __init__( should be added to. :paramtype target_resource_location: str """ - super(AutoscaleSettingResourcePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.profiles = profiles self.notifications = notifications @@ -634,7 +616,7 @@ def __init__( self.target_resource_location = target_resource_location -class EmailNotification(msrest.serialization.Model): +class EmailNotification(_serialization.Model): """Email notification of an autoscale event. :ivar send_to_subscription_administrator: a value indicating whether to send email to @@ -649,16 +631,16 @@ class EmailNotification(msrest.serialization.Model): """ _attribute_map = { - 'send_to_subscription_administrator': {'key': 'sendToSubscriptionAdministrator', 'type': 'bool'}, - 'send_to_subscription_co_administrators': {'key': 'sendToSubscriptionCoAdministrators', 'type': 'bool'}, - 'custom_emails': {'key': 'customEmails', 'type': '[str]'}, + "send_to_subscription_administrator": {"key": "sendToSubscriptionAdministrator", "type": "bool"}, + "send_to_subscription_co_administrators": {"key": "sendToSubscriptionCoAdministrators", "type": "bool"}, + "custom_emails": {"key": "customEmails", "type": "[str]"}, } def __init__( self, *, - send_to_subscription_administrator: Optional[bool] = False, - send_to_subscription_co_administrators: Optional[bool] = False, + send_to_subscription_administrator: bool = False, + send_to_subscription_co_administrators: bool = False, custom_emails: Optional[List[str]] = None, **kwargs ): @@ -673,13 +655,13 @@ def __init__( this attribute will be ignored. :paramtype custom_emails: list[str] """ - super(EmailNotification, self).__init__(**kwargs) + super().__init__(**kwargs) self.send_to_subscription_administrator = send_to_subscription_administrator self.send_to_subscription_co_administrators = send_to_subscription_co_administrators self.custom_emails = custom_emails -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -689,60 +671,49 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class EventCategoryCollection(msrest.serialization.Model): +class EventCategoryCollection(_serialization.Model): """A collection of event categories. Currently possible values are: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the list that includes the Azure event categories. + :ivar value: the list that includes the Azure event categories. Required. :vartype value: list[~$(python-base-namespace).v2015_04_01.models.LocalizableString] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[LocalizableString]'}, + "value": {"key": "value", "type": "[LocalizableString]"}, } - def __init__( - self, - *, - value: List["_models.LocalizableString"], - **kwargs - ): + def __init__(self, *, value: List["_models.LocalizableString"], **kwargs): """ - :keyword value: Required. the list that includes the Azure event categories. + :keyword value: the list that includes the Azure event categories. Required. :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.LocalizableString] """ - super(EventCategoryCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class EventData(msrest.serialization.Model): +class EventData(_serialization.Model): # pylint: disable=too-many-instance-attributes """The Azure event log entries are of type EventData. Variables are only populated by the server, and will be ignored when sending a request. @@ -774,7 +745,7 @@ class EventData(msrest.serialization.Model): e.g. PUT). :vartype http_request: ~$(python-base-namespace).v2015_04_01.models.HttpRequestInfo :ivar level: the event level. Known values are: "Critical", "Error", "Warning", - "Informational", "Verbose". + "Informational", and "Verbose". :vartype level: str or ~$(python-base-namespace).v2015_04_01.models.EventLevel :ivar resource_group_name: the resource group name of the impacted resource. :vartype resource_group_name: str @@ -818,66 +789,62 @@ class EventData(msrest.serialization.Model): """ _validation = { - 'authorization': {'readonly': True}, - 'claims': {'readonly': True}, - 'caller': {'readonly': True}, - 'description': {'readonly': True}, - 'id': {'readonly': True}, - 'event_data_id': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'event_name': {'readonly': True}, - 'category': {'readonly': True}, - 'http_request': {'readonly': True}, - 'level': {'readonly': True}, - 'resource_group_name': {'readonly': True}, - 'resource_provider_name': {'readonly': True}, - 'resource_id': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'operation_id': {'readonly': True}, - 'operation_name': {'readonly': True}, - 'properties': {'readonly': True}, - 'status': {'readonly': True}, - 'sub_status': {'readonly': True}, - 'event_timestamp': {'readonly': True}, - 'submission_timestamp': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "authorization": {"readonly": True}, + "claims": {"readonly": True}, + "caller": {"readonly": True}, + "description": {"readonly": True}, + "id": {"readonly": True}, + "event_data_id": {"readonly": True}, + "correlation_id": {"readonly": True}, + "event_name": {"readonly": True}, + "category": {"readonly": True}, + "http_request": {"readonly": True}, + "level": {"readonly": True}, + "resource_group_name": {"readonly": True}, + "resource_provider_name": {"readonly": True}, + "resource_id": {"readonly": True}, + "resource_type": {"readonly": True}, + "operation_id": {"readonly": True}, + "operation_name": {"readonly": True}, + "properties": {"readonly": True}, + "status": {"readonly": True}, + "sub_status": {"readonly": True}, + "event_timestamp": {"readonly": True}, + "submission_timestamp": {"readonly": True}, + "subscription_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'authorization': {'key': 'authorization', 'type': 'SenderAuthorization'}, - 'claims': {'key': 'claims', 'type': '{str}'}, - 'caller': {'key': 'caller', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'event_data_id': {'key': 'eventDataId', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'event_name': {'key': 'eventName', 'type': 'LocalizableString'}, - 'category': {'key': 'category', 'type': 'LocalizableString'}, - 'http_request': {'key': 'httpRequest', 'type': 'HttpRequestInfo'}, - 'level': {'key': 'level', 'type': 'str'}, - 'resource_group_name': {'key': 'resourceGroupName', 'type': 'str'}, - 'resource_provider_name': {'key': 'resourceProviderName', 'type': 'LocalizableString'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'LocalizableString'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'operation_name': {'key': 'operationName', 'type': 'LocalizableString'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - 'status': {'key': 'status', 'type': 'LocalizableString'}, - 'sub_status': {'key': 'subStatus', 'type': 'LocalizableString'}, - 'event_timestamp': {'key': 'eventTimestamp', 'type': 'iso-8601'}, - 'submission_timestamp': {'key': 'submissionTimestamp', 'type': 'iso-8601'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(EventData, self).__init__(**kwargs) + "authorization": {"key": "authorization", "type": "SenderAuthorization"}, + "claims": {"key": "claims", "type": "{str}"}, + "caller": {"key": "caller", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "event_data_id": {"key": "eventDataId", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "event_name": {"key": "eventName", "type": "LocalizableString"}, + "category": {"key": "category", "type": "LocalizableString"}, + "http_request": {"key": "httpRequest", "type": "HttpRequestInfo"}, + "level": {"key": "level", "type": "str"}, + "resource_group_name": {"key": "resourceGroupName", "type": "str"}, + "resource_provider_name": {"key": "resourceProviderName", "type": "LocalizableString"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "LocalizableString"}, + "operation_id": {"key": "operationId", "type": "str"}, + "operation_name": {"key": "operationName", "type": "LocalizableString"}, + "properties": {"key": "properties", "type": "{str}"}, + "status": {"key": "status", "type": "LocalizableString"}, + "sub_status": {"key": "subStatus", "type": "LocalizableString"}, + "event_timestamp": {"key": "eventTimestamp", "type": "iso-8601"}, + "submission_timestamp": {"key": "submissionTimestamp", "type": "iso-8601"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + } + + def __init__(self, **kwargs): # pylint: disable=too-many-locals + """ """ + super().__init__(**kwargs) self.authorization = None self.claims = None self.caller = None @@ -904,45 +871,39 @@ def __init__( self.tenant_id = None -class EventDataCollection(msrest.serialization.Model): +class EventDataCollection(_serialization.Model): """Represents collection of events. All required parameters must be populated in order to send to Azure. - :ivar value: Required. this list that includes the Azure audit logs. + :ivar value: this list that includes the Azure audit logs. Required. :vartype value: list[~$(python-base-namespace).v2015_04_01.models.EventData] :ivar next_link: Provides the link to retrieve the next set of events. :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EventData]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EventData]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["_models.EventData"], - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: List["_models.EventData"], next_link: Optional[str] = None, **kwargs): """ - :keyword value: Required. this list that includes the Azure audit logs. + :keyword value: this list that includes the Azure audit logs. Required. :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.EventData] :keyword next_link: Provides the link to retrieve the next set of events. :paramtype next_link: str """ - super(EventDataCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class HttpRequestInfo(msrest.serialization.Model): +class HttpRequestInfo(_serialization.Model): """The Http request info. :ivar client_request_id: the client request id. @@ -956,10 +917,10 @@ class HttpRequestInfo(msrest.serialization.Model): """ _attribute_map = { - 'client_request_id': {'key': 'clientRequestId', 'type': 'str'}, - 'client_ip_address': {'key': 'clientIpAddress', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, + "client_request_id": {"key": "clientRequestId", "type": "str"}, + "client_ip_address": {"key": "clientIpAddress", "type": "str"}, + "method": {"key": "method", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, } def __init__( @@ -981,63 +942,57 @@ def __init__( :keyword uri: the Uri. :paramtype uri: str """ - super(HttpRequestInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_request_id = client_request_id self.client_ip_address = client_ip_address self.method = method self.uri = uri -class LocalizableString(msrest.serialization.Model): +class LocalizableString(_serialization.Model): """The localizable string class. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the invariant value. + :ivar value: the invariant value. Required. :vartype value: str :ivar localized_value: the locale specific value. :vartype localized_value: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: str, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs): """ - :keyword value: Required. the invariant value. + :keyword value: the invariant value. Required. :paramtype value: str :keyword localized_value: the locale specific value. :paramtype localized_value: str """ - super(LocalizableString, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class RuleCondition(msrest.serialization.Model): +class RuleCondition(_serialization.Model): """The condition that results in the alert rule being activated. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: LocationThresholdRuleCondition, ManagementEventRuleCondition, ThresholdRuleCondition. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + LocationThresholdRuleCondition, ManagementEventRuleCondition, ThresholdRuleCondition All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric).Constant filled by server. + threshold of a metric). Required. :vartype odata_type: str :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -1045,30 +1000,29 @@ class RuleCondition(msrest.serialization.Model): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "data_source": {"key": "dataSource", "type": "RuleDataSource"}, } _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition': 'LocationThresholdRuleCondition', 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition': 'ManagementEventRuleCondition', 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition': 'ThresholdRuleCondition'} + "odata_type": { + "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition": "LocationThresholdRuleCondition", + "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition": "ManagementEventRuleCondition", + "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition": "ThresholdRuleCondition", + } } - def __init__( - self, - *, - data_source: Optional["_models.RuleDataSource"] = None, - **kwargs - ): + def __init__(self, *, data_source: Optional["_models.RuleDataSource"] = None, **kwargs): """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :paramtype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource """ - super(RuleCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] self.data_source = data_source @@ -1078,10 +1032,10 @@ class LocationThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric).Constant filled by server. + threshold of a metric). Required. :vartype odata_type: str :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -1090,21 +1044,21 @@ class LocationThresholdRuleCondition(RuleCondition): alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. :vartype window_size: ~datetime.timedelta - :ivar failed_location_count: Required. the number of locations that must fail to activate the - alert. + :ivar failed_location_count: the number of locations that must fail to activate the alert. + Required. :vartype failed_location_count: int """ _validation = { - 'odata_type': {'required': True}, - 'failed_location_count': {'required': True, 'minimum': 0}, + "odata_type": {"required": True}, + "failed_location_count": {"required": True, "minimum": 0}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - 'failed_location_count': {'key': 'failedLocationCount', 'type': 'int'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "data_source": {"key": "dataSource", "type": "RuleDataSource"}, + "window_size": {"key": "windowSize", "type": "duration"}, + "failed_location_count": {"key": "failedLocationCount", "type": "int"}, } def __init__( @@ -1123,21 +1077,21 @@ def __init__( alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. :paramtype window_size: ~datetime.timedelta - :keyword failed_location_count: Required. the number of locations that must fail to activate - the alert. + :keyword failed_location_count: the number of locations that must fail to activate the alert. + Required. :paramtype failed_location_count: int """ - super(LocationThresholdRuleCondition, self).__init__(data_source=data_source, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition' # type: str + super().__init__(data_source=data_source, **kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" # type: str self.window_size = window_size self.failed_location_count = failed_location_count -class ManagementEventAggregationCondition(msrest.serialization.Model): +class ManagementEventAggregationCondition(_serialization.Model): """How the data that is collected should be combined over time. :ivar operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", - "LessThan", "LessThanOrEqual". + "LessThan", and "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator :ivar threshold: The threshold value that activates the alert. :vartype threshold: float @@ -1148,9 +1102,9 @@ class ManagementEventAggregationCondition(msrest.serialization.Model): """ _attribute_map = { - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "window_size": {"key": "windowSize", "type": "duration"}, } def __init__( @@ -1163,7 +1117,7 @@ def __init__( ): """ :keyword operator: the condition operator. Known values are: "GreaterThan", - "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator :keyword threshold: The threshold value that activates the alert. :paramtype threshold: float @@ -1172,7 +1126,7 @@ def __init__( day. :paramtype window_size: ~datetime.timedelta """ - super(ManagementEventAggregationCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.operator = operator self.threshold = threshold self.window_size = window_size @@ -1183,10 +1137,10 @@ class ManagementEventRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric).Constant filled by server. + threshold of a metric). Required. :vartype odata_type: str :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -1199,13 +1153,13 @@ class ManagementEventRuleCondition(RuleCondition): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'aggregation': {'key': 'aggregation', 'type': 'ManagementEventAggregationCondition'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "data_source": {"key": "dataSource", "type": "RuleDataSource"}, + "aggregation": {"key": "aggregation", "type": "ManagementEventAggregationCondition"}, } def __init__( @@ -1225,45 +1179,45 @@ def __init__( :paramtype aggregation: ~$(python-base-namespace).v2015_04_01.models.ManagementEventAggregationCondition """ - super(ManagementEventRuleCondition, self).__init__(data_source=data_source, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition' # type: str + super().__init__(data_source=data_source, **kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" # type: str self.aggregation = aggregation -class MetricTrigger(msrest.serialization.Model): +class MetricTrigger(_serialization.Model): # pylint: disable=too-many-instance-attributes """The trigger that results in a scaling action. All required parameters must be populated in order to send to Azure. - :ivar metric_name: Required. the name of the metric that defines what the rule monitors. + :ivar metric_name: the name of the metric that defines what the rule monitors. Required. :vartype metric_name: str :ivar metric_namespace: the namespace of the metric that defines what the rule monitors. :vartype metric_namespace: str - :ivar metric_resource_uri: Required. the resource identifier of the resource the rule monitors. + :ivar metric_resource_uri: the resource identifier of the resource the rule monitors. Required. :vartype metric_resource_uri: str :ivar metric_resource_location: the location of the resource the rule monitors. :vartype metric_resource_location: str - :ivar time_grain: Required. the granularity of metrics the rule monitors. Must be one of the - predefined values returned from metric definitions for the metric. Must be between 12 hours and - 1 minute. + :ivar time_grain: the granularity of metrics the rule monitors. Must be one of the predefined + values returned from metric definitions for the metric. Must be between 12 hours and 1 minute. + Required. :vartype time_grain: ~datetime.timedelta - :ivar statistic: Required. the metric statistic type. How the metrics from multiple instances - are combined. Known values are: "Average", "Min", "Max", "Sum", "Count". + :ivar statistic: the metric statistic type. How the metrics from multiple instances are + combined. Required. Known values are: "Average", "Min", "Max", "Sum", and "Count". :vartype statistic: str or ~$(python-base-namespace).v2015_04_01.models.MetricStatisticType - :ivar time_window: Required. the range of time in which instance data is collected. This value - must be greater than the delay in metric collection, which can vary from resource-to-resource. - Must be between 12 hours and 5 minutes. + :ivar time_window: the range of time in which instance data is collected. This value must be + greater than the delay in metric collection, which can vary from resource-to-resource. Must be + between 12 hours and 5 minutes. Required. :vartype time_window: ~datetime.timedelta - :ivar time_aggregation: Required. time aggregation type. How the data that is collected should - be combined over time. The default value is Average. Known values are: "Average", "Minimum", - "Maximum", "Total", "Count", "Last". + :ivar time_aggregation: time aggregation type. How the data that is collected should be + combined over time. The default value is Average. Required. Known values are: "Average", + "Minimum", "Maximum", "Total", "Count", and "Last". :vartype time_aggregation: str or ~$(python-base-namespace).v2015_04_01.models.TimeAggregationType - :ivar operator: Required. the operator that is used to compare the metric data and the - threshold. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", - "LessThan", "LessThanOrEqual". + :ivar operator: the operator that is used to compare the metric data and the threshold. + Required. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + "LessThan", and "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ComparisonOperationType - :ivar threshold: Required. the threshold of the metric that triggers the scale action. + :ivar threshold: the threshold of the metric that triggers the scale action. Required. :vartype threshold: float :ivar dimensions: List of dimension conditions. For example: [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. @@ -1274,29 +1228,29 @@ class MetricTrigger(msrest.serialization.Model): """ _validation = { - 'metric_name': {'required': True}, - 'metric_resource_uri': {'required': True}, - 'time_grain': {'required': True}, - 'statistic': {'required': True}, - 'time_window': {'required': True}, - 'time_aggregation': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, + "metric_name": {"required": True}, + "metric_resource_uri": {"required": True}, + "time_grain": {"required": True}, + "statistic": {"required": True}, + "time_window": {"required": True}, + "time_aggregation": {"required": True}, + "operator": {"required": True}, + "threshold": {"required": True}, } _attribute_map = { - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'metric_resource_uri': {'key': 'metricResourceUri', 'type': 'str'}, - 'metric_resource_location': {'key': 'metricResourceLocation', 'type': 'str'}, - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'statistic': {'key': 'statistic', 'type': 'str'}, - 'time_window': {'key': 'timeWindow', 'type': 'duration'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'dimensions': {'key': 'dimensions', 'type': '[ScaleRuleMetricDimension]'}, - 'divide_per_instance': {'key': 'dividePerInstance', 'type': 'bool'}, + "metric_name": {"key": "metricName", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "metric_resource_uri": {"key": "metricResourceUri", "type": "str"}, + "metric_resource_location": {"key": "metricResourceLocation", "type": "str"}, + "time_grain": {"key": "timeGrain", "type": "duration"}, + "statistic": {"key": "statistic", "type": "str"}, + "time_window": {"key": "timeWindow", "type": "duration"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "dimensions": {"key": "dimensions", "type": "[ScaleRuleMetricDimension]"}, + "divide_per_instance": {"key": "dividePerInstance", "type": "bool"}, } def __init__( @@ -1317,37 +1271,37 @@ def __init__( **kwargs ): """ - :keyword metric_name: Required. the name of the metric that defines what the rule monitors. + :keyword metric_name: the name of the metric that defines what the rule monitors. Required. :paramtype metric_name: str :keyword metric_namespace: the namespace of the metric that defines what the rule monitors. :paramtype metric_namespace: str - :keyword metric_resource_uri: Required. the resource identifier of the resource the rule - monitors. + :keyword metric_resource_uri: the resource identifier of the resource the rule monitors. + Required. :paramtype metric_resource_uri: str :keyword metric_resource_location: the location of the resource the rule monitors. :paramtype metric_resource_location: str - :keyword time_grain: Required. the granularity of metrics the rule monitors. Must be one of the + :keyword time_grain: the granularity of metrics the rule monitors. Must be one of the predefined values returned from metric definitions for the metric. Must be between 12 hours and - 1 minute. + 1 minute. Required. :paramtype time_grain: ~datetime.timedelta - :keyword statistic: Required. the metric statistic type. How the metrics from multiple - instances are combined. Known values are: "Average", "Min", "Max", "Sum", "Count". + :keyword statistic: the metric statistic type. How the metrics from multiple instances are + combined. Required. Known values are: "Average", "Min", "Max", "Sum", and "Count". :paramtype statistic: str or ~$(python-base-namespace).v2015_04_01.models.MetricStatisticType - :keyword time_window: Required. the range of time in which instance data is collected. This - value must be greater than the delay in metric collection, which can vary from - resource-to-resource. Must be between 12 hours and 5 minutes. + :keyword time_window: the range of time in which instance data is collected. This value must be + greater than the delay in metric collection, which can vary from resource-to-resource. Must be + between 12 hours and 5 minutes. Required. :paramtype time_window: ~datetime.timedelta - :keyword time_aggregation: Required. time aggregation type. How the data that is collected - should be combined over time. The default value is Average. Known values are: "Average", - "Minimum", "Maximum", "Total", "Count", "Last". + :keyword time_aggregation: time aggregation type. How the data that is collected should be + combined over time. The default value is Average. Required. Known values are: "Average", + "Minimum", "Maximum", "Total", "Count", and "Last". :paramtype time_aggregation: str or ~$(python-base-namespace).v2015_04_01.models.TimeAggregationType - :keyword operator: Required. the operator that is used to compare the metric data and the - threshold. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", - "LessThan", "LessThanOrEqual". + :keyword operator: the operator that is used to compare the metric data and the threshold. + Required. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + "LessThan", and "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2015_04_01.models.ComparisonOperationType - :keyword threshold: Required. the threshold of the metric that triggers the scale action. + :keyword threshold: the threshold of the metric that triggers the scale action. Required. :paramtype threshold: float :keyword dimensions: List of dimension conditions. For example: [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. @@ -1356,7 +1310,7 @@ def __init__( :keyword divide_per_instance: a value indicating whether metric should divide per instance. :paramtype divide_per_instance: bool """ - super(MetricTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_name = metric_name self.metric_namespace = metric_namespace self.metric_resource_uri = metric_resource_uri @@ -1371,7 +1325,7 @@ def __init__( self.divide_per_instance = divide_per_instance -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft Insights API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1381,29 +1335,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["_models.OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: Display metadata associated with the operation. :paramtype display: ~$(python-base-namespace).v2015_04_01.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft.Insights. @@ -1415,9 +1363,9 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } def __init__( @@ -1436,13 +1384,13 @@ def __init__( :keyword operation: Operation type: Read, write, delete, etc. :paramtype operation: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Insights operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of operations supported by the Microsoft.Insights provider. @@ -1452,97 +1400,87 @@ class OperationListResult(msrest.serialization.Model): """ _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: Optional[List["_models.Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of operations supported by the Microsoft.Insights provider. :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class Recurrence(msrest.serialization.Model): +class Recurrence(_serialization.Model): """The repeating times at which this profile begins. This element is not used if the FixedDate element is used. All required parameters must be populated in order to send to Azure. - :ivar frequency: Required. the recurrence frequency. How often the schedule profile should take - effect. This value must be Week, meaning each week will have the same set of profiles. For - example, to set a daily schedule, set **schedule** to every day of the week. The frequency - property specifies that the schedule is repeated weekly. Known values are: "None", "Second", - "Minute", "Hour", "Day", "Week", "Month", "Year". + :ivar frequency: the recurrence frequency. How often the schedule profile should take effect. + This value must be Week, meaning each week will have the same set of profiles. For example, to + set a daily schedule, set **schedule** to every day of the week. The frequency property + specifies that the schedule is repeated weekly. Required. Known values are: "None", "Second", + "Minute", "Hour", "Day", "Week", "Month", and "Year". :vartype frequency: str or ~$(python-base-namespace).v2015_04_01.models.RecurrenceFrequency - :ivar schedule: Required. the scheduling constraints for when the profile begins. + :ivar schedule: the scheduling constraints for when the profile begins. Required. :vartype schedule: ~$(python-base-namespace).v2015_04_01.models.RecurrentSchedule """ _validation = { - 'frequency': {'required': True}, - 'schedule': {'required': True}, + "frequency": {"required": True}, + "schedule": {"required": True}, } _attribute_map = { - 'frequency': {'key': 'frequency', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'RecurrentSchedule'}, + "frequency": {"key": "frequency", "type": "str"}, + "schedule": {"key": "schedule", "type": "RecurrentSchedule"}, } def __init__( - self, - *, - frequency: Union[str, "_models.RecurrenceFrequency"], - schedule: "_models.RecurrentSchedule", - **kwargs + self, *, frequency: Union[str, "_models.RecurrenceFrequency"], schedule: "_models.RecurrentSchedule", **kwargs ): """ - :keyword frequency: Required. the recurrence frequency. How often the schedule profile should - take effect. This value must be Week, meaning each week will have the same set of profiles. For + :keyword frequency: the recurrence frequency. How often the schedule profile should take + effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency - property specifies that the schedule is repeated weekly. Known values are: "None", "Second", - "Minute", "Hour", "Day", "Week", "Month", "Year". + property specifies that the schedule is repeated weekly. Required. Known values are: "None", + "Second", "Minute", "Hour", "Day", "Week", "Month", and "Year". :paramtype frequency: str or ~$(python-base-namespace).v2015_04_01.models.RecurrenceFrequency - :keyword schedule: Required. the scheduling constraints for when the profile begins. + :keyword schedule: the scheduling constraints for when the profile begins. Required. :paramtype schedule: ~$(python-base-namespace).v2015_04_01.models.RecurrentSchedule """ - super(Recurrence, self).__init__(**kwargs) + super().__init__(**kwargs) self.frequency = frequency self.schedule = schedule -class RecurrentSchedule(msrest.serialization.Model): +class RecurrentSchedule(_serialization.Model): """The scheduling constraints for when the profile begins. All required parameters must be populated in order to send to Azure. - :ivar time_zone: Required. the timezone for the hours of the profile. Some examples of valid - time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, - Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain - Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard - Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, - Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard - Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, - Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina - Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, - Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde - Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. - Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European - Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, - GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. - Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, - Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, - Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + :ivar time_zone: the timezone for the hours of the profile. Some examples of valid time zones + are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific + Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard + Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, + Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern + Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, + Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific SA + Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina Standard + Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, Bahia + Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard + Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe + Standard Time, Central Europe Standard Time, Romance Standard Time, Central European Standard + Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, GTB + Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe + Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel + Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, Arab + Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, @@ -1555,44 +1493,36 @@ class RecurrentSchedule(msrest.serialization.Model): Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands - Standard Time. + Standard Time. Required. :vartype time_zone: str - :ivar days: Required. the collection of days that the profile takes effect on. Possible values - are Sunday through Saturday. + :ivar days: the collection of days that the profile takes effect on. Possible values are Sunday + through Saturday. Required. :vartype days: list[str] - :ivar hours: Required. A collection of hours that the profile takes effect on. Values supported - are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + :ivar hours: A collection of hours that the profile takes effect on. Values supported are 0 to + 23 on the 24-hour clock (AM/PM times are not supported). Required. :vartype hours: list[int] - :ivar minutes: Required. A collection of minutes at which the profile takes effect at. + :ivar minutes: A collection of minutes at which the profile takes effect at. Required. :vartype minutes: list[int] """ _validation = { - 'time_zone': {'required': True}, - 'days': {'required': True}, - 'hours': {'required': True}, - 'minutes': {'required': True}, + "time_zone": {"required": True}, + "days": {"required": True}, + "hours": {"required": True}, + "minutes": {"required": True}, } _attribute_map = { - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'days': {'key': 'days', 'type': '[str]'}, - 'hours': {'key': 'hours', 'type': '[int]'}, - 'minutes': {'key': 'minutes', 'type': '[int]'}, + "time_zone": {"key": "timeZone", "type": "str"}, + "days": {"key": "days", "type": "[str]"}, + "hours": {"key": "hours", "type": "[int]"}, + "minutes": {"key": "minutes", "type": "[int]"}, } - def __init__( - self, - *, - time_zone: str, - days: List[str], - hours: List[int], - minutes: List[int], - **kwargs - ): + def __init__(self, *, time_zone: str, days: List[str], hours: List[int], minutes: List[int], **kwargs): """ - :keyword time_zone: Required. the timezone for the hours of the profile. Some examples of valid - time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, + :keyword time_zone: the timezone for the hours of the profile. Some examples of valid time + zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, @@ -1620,69 +1550,68 @@ def __init__( Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands - Standard Time. + Standard Time. Required. :paramtype time_zone: str - :keyword days: Required. the collection of days that the profile takes effect on. Possible - values are Sunday through Saturday. + :keyword days: the collection of days that the profile takes effect on. Possible values are + Sunday through Saturday. Required. :paramtype days: list[str] - :keyword hours: Required. A collection of hours that the profile takes effect on. Values - supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + :keyword hours: A collection of hours that the profile takes effect on. Values supported are 0 + to 23 on the 24-hour clock (AM/PM times are not supported). Required. :paramtype hours: list[int] - :keyword minutes: Required. A collection of minutes at which the profile takes effect at. + :keyword minutes: A collection of minutes at which the profile takes effect at. Required. :paramtype minutes: list[int] """ - super(RecurrentSchedule, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_zone = time_zone self.days = days self.hours = hours self.minutes = minutes -class RuleAction(msrest.serialization.Model): +class RuleAction(_serialization.Model): """The action that is performed when the alert rule becomes active, and when an alert condition is resolved. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RuleEmailAction, RuleWebhookAction. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + RuleEmailAction, RuleWebhookAction All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction.Constant filled by server. + :ivar odata_type: specifies the type of the action. There are two types of actions: + RuleEmailAction and RuleWebhookAction. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.RuleEmailAction': 'RuleEmailAction', 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction': 'RuleWebhookAction'} + "odata_type": { + "Microsoft.Azure.Management.Insights.Models.RuleEmailAction": "RuleEmailAction", + "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction": "RuleWebhookAction", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(RuleAction, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] -class RuleDataSource(msrest.serialization.Model): +class RuleDataSource(_serialization.Model): """The resource from which the rule collects its data. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RuleManagementEventDataSource, RuleMetricDataSource. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + RuleManagementEventDataSource, RuleMetricDataSource All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of data source. There are two types of rule data - sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :ivar odata_type: specifies the type of data source. There are two types of rule data sources: + RuleMetricDataSource and RuleManagementEventDataSource. Required. :vartype odata_type: str :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1697,19 +1626,22 @@ class RuleDataSource(msrest.serialization.Model): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "resource_uri": {"key": "resourceUri", "type": "str"}, + "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, + "resource_location": {"key": "resourceLocation", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, } _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource': 'RuleManagementEventDataSource', 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource': 'RuleMetricDataSource'} + "odata_type": { + "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource": "RuleManagementEventDataSource", + "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource": "RuleMetricDataSource", + } } def __init__( @@ -1733,7 +1665,7 @@ def __init__( :keyword metric_namespace: the namespace of the metric. :paramtype metric_namespace: str """ - super(RuleDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] self.resource_uri = resource_uri self.legacy_resource_id = legacy_resource_id @@ -1746,8 +1678,8 @@ class RuleEmailAction(RuleAction): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction.Constant filled by server. + :ivar odata_type: specifies the type of the action. There are two types of actions: + RuleEmailAction and RuleWebhookAction. Required. :vartype odata_type: str :ivar send_to_service_owners: Whether the administrators (service and co-administrators) of the service should be notified when the alert is activated. @@ -1758,21 +1690,17 @@ class RuleEmailAction(RuleAction): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'send_to_service_owners': {'key': 'sendToServiceOwners', 'type': 'bool'}, - 'custom_emails': {'key': 'customEmails', 'type': '[str]'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "send_to_service_owners": {"key": "sendToServiceOwners", "type": "bool"}, + "custom_emails": {"key": "customEmails", "type": "[str]"}, } def __init__( - self, - *, - send_to_service_owners: Optional[bool] = None, - custom_emails: Optional[List[str]] = None, - **kwargs + self, *, send_to_service_owners: Optional[bool] = None, custom_emails: Optional[List[str]] = None, **kwargs ): """ :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of @@ -1782,13 +1710,13 @@ def __init__( activation of the alert. :paramtype custom_emails: list[str] """ - super(RuleEmailAction, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleEmailAction' # type: str + super().__init__(**kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" # type: str self.send_to_service_owners = send_to_service_owners self.custom_emails = custom_emails -class RuleManagementEventClaimsDataSource(msrest.serialization.Model): +class RuleManagementEventClaimsDataSource(_serialization.Model): """The claims for a rule management event data source. :ivar email_address: the email address. @@ -1796,30 +1724,25 @@ class RuleManagementEventClaimsDataSource(msrest.serialization.Model): """ _attribute_map = { - 'email_address': {'key': 'emailAddress', 'type': 'str'}, + "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__( - self, - *, - email_address: Optional[str] = None, - **kwargs - ): + def __init__(self, *, email_address: Optional[str] = None, **kwargs): """ :keyword email_address: the email address. :paramtype email_address: str """ - super(RuleManagementEventClaimsDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.email_address = email_address -class RuleManagementEventDataSource(RuleDataSource): +class RuleManagementEventDataSource(RuleDataSource): # pylint: disable=too-many-instance-attributes """A rule management event data source. The discriminator fields is always RuleManagementEventDataSource in this case. All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of data source. There are two types of rule data - sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :ivar odata_type: specifies the type of data source. There are two types of rule data sources: + RuleMetricDataSource and RuleManagementEventDataSource. Required. :vartype odata_type: str :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1855,24 +1778,24 @@ class RuleManagementEventDataSource(RuleDataSource): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'event_name': {'key': 'eventName', 'type': 'str'}, - 'event_source': {'key': 'eventSource', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'operation_name': {'key': 'operationName', 'type': 'str'}, - 'resource_group_name': {'key': 'resourceGroupName', 'type': 'str'}, - 'resource_provider_name': {'key': 'resourceProviderName', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'sub_status': {'key': 'subStatus', 'type': 'str'}, - 'claims': {'key': 'claims', 'type': 'RuleManagementEventClaimsDataSource'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "resource_uri": {"key": "resourceUri", "type": "str"}, + "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, + "resource_location": {"key": "resourceLocation", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "event_name": {"key": "eventName", "type": "str"}, + "event_source": {"key": "eventSource", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "operation_name": {"key": "operationName", "type": "str"}, + "resource_group_name": {"key": "resourceGroupName", "type": "str"}, + "resource_provider_name": {"key": "resourceProviderName", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "sub_status": {"key": "subStatus", "type": "str"}, + "claims": {"key": "claims", "type": "RuleManagementEventClaimsDataSource"}, } def __init__( @@ -1926,8 +1849,14 @@ def __init__( :paramtype claims: ~$(python-base-namespace).v2015_04_01.models.RuleManagementEventClaimsDataSource """ - super(RuleManagementEventDataSource, self).__init__(resource_uri=resource_uri, legacy_resource_id=legacy_resource_id, resource_location=resource_location, metric_namespace=metric_namespace, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource' # type: str + super().__init__( + resource_uri=resource_uri, + legacy_resource_id=legacy_resource_id, + resource_location=resource_location, + metric_namespace=metric_namespace, + **kwargs + ) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" # type: str self.event_name = event_name self.event_source = event_source self.level = level @@ -1944,8 +1873,8 @@ class RuleMetricDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of data source. There are two types of rule data - sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :ivar odata_type: specifies the type of data source. There are two types of rule data sources: + RuleMetricDataSource and RuleManagementEventDataSource. Required. :vartype odata_type: str :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1962,16 +1891,16 @@ class RuleMetricDataSource(RuleDataSource): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "resource_uri": {"key": "resourceUri", "type": "str"}, + "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, + "resource_location": {"key": "resourceLocation", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "metric_name": {"key": "metricName", "type": "str"}, } def __init__( @@ -1998,8 +1927,14 @@ def __init__( :keyword metric_name: the name of the metric that defines what the rule monitors. :paramtype metric_name: str """ - super(RuleMetricDataSource, self).__init__(resource_uri=resource_uri, legacy_resource_id=legacy_resource_id, resource_location=resource_location, metric_namespace=metric_namespace, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource' # type: str + super().__init__( + resource_uri=resource_uri, + legacy_resource_id=legacy_resource_id, + resource_location=resource_location, + metric_namespace=metric_namespace, + **kwargs + ) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" # type: str self.metric_name = metric_name @@ -2008,8 +1943,8 @@ class RuleWebhookAction(RuleAction): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction.Constant filled by server. + :ivar odata_type: specifies the type of the action. There are two types of actions: + RuleEmailAction and RuleWebhookAction. Required. :vartype odata_type: str :ivar service_uri: the service uri to Post the notification when the alert activates or resolves. @@ -2020,22 +1955,16 @@ class RuleWebhookAction(RuleAction): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: Optional[str] = None, - properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs): """ :keyword service_uri: the service uri to Post the notification when the alert activates or resolves. @@ -2044,42 +1973,42 @@ def __init__( These data are appended to the webhook payload. :paramtype properties: dict[str, str] """ - super(RuleWebhookAction, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' # type: str + super().__init__(**kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" # type: str self.service_uri = service_uri self.properties = properties -class ScaleAction(msrest.serialization.Model): +class ScaleAction(_serialization.Model): """The parameters for the scaling action. All required parameters must be populated in order to send to Azure. - :ivar direction: Required. the scale direction. Whether the scaling action increases or - decreases the number of instances. Known values are: "None", "Increase", "Decrease". + :ivar direction: the scale direction. Whether the scaling action increases or decreases the + number of instances. Required. Known values are: "None", "Increase", and "Decrease". :vartype direction: str or ~$(python-base-namespace).v2015_04_01.models.ScaleDirection - :ivar type: Required. the type of action that should occur when the scale rule fires. Known - values are: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". + :ivar type: the type of action that should occur when the scale rule fires. Required. Known + values are: "ChangeCount", "PercentChangeCount", "ExactCount", and "ServiceAllowedNextValue". :vartype type: str or ~$(python-base-namespace).v2015_04_01.models.ScaleType :ivar value: the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. :vartype value: str - :ivar cooldown: Required. the amount of time to wait since the last scaling action before this - action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + :ivar cooldown: the amount of time to wait since the last scaling action before this action + occurs. It must be between 1 week and 1 minute in ISO 8601 format. Required. :vartype cooldown: ~datetime.timedelta """ _validation = { - 'direction': {'required': True}, - 'type': {'required': True}, - 'cooldown': {'required': True}, + "direction": {"required": True}, + "type": {"required": True}, + "cooldown": {"required": True}, } _attribute_map = { - 'direction': {'key': 'direction', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'cooldown': {'key': 'cooldown', 'type': 'duration'}, + "direction": {"key": "direction", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "cooldown": {"key": "cooldown", "type": "duration"}, } def __init__( @@ -2088,148 +2017,135 @@ def __init__( direction: Union[str, "_models.ScaleDirection"], type: Union[str, "_models.ScaleType"], cooldown: datetime.timedelta, - value: Optional[str] = "1", + value: str = "1", **kwargs ): """ - :keyword direction: Required. the scale direction. Whether the scaling action increases or - decreases the number of instances. Known values are: "None", "Increase", "Decrease". + :keyword direction: the scale direction. Whether the scaling action increases or decreases the + number of instances. Required. Known values are: "None", "Increase", and "Decrease". :paramtype direction: str or ~$(python-base-namespace).v2015_04_01.models.ScaleDirection - :keyword type: Required. the type of action that should occur when the scale rule fires. Known - values are: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". + :keyword type: the type of action that should occur when the scale rule fires. Required. Known + values are: "ChangeCount", "PercentChangeCount", "ExactCount", and "ServiceAllowedNextValue". :paramtype type: str or ~$(python-base-namespace).v2015_04_01.models.ScaleType :keyword value: the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. :paramtype value: str - :keyword cooldown: Required. the amount of time to wait since the last scaling action before - this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + :keyword cooldown: the amount of time to wait since the last scaling action before this action + occurs. It must be between 1 week and 1 minute in ISO 8601 format. Required. :paramtype cooldown: ~datetime.timedelta """ - super(ScaleAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.direction = direction self.type = type self.value = value self.cooldown = cooldown -class ScaleCapacity(msrest.serialization.Model): +class ScaleCapacity(_serialization.Model): """The number of instances that can be used during this profile. All required parameters must be populated in order to send to Azure. - :ivar minimum: Required. the minimum number of instances for the resource. + :ivar minimum: the minimum number of instances for the resource. Required. :vartype minimum: str - :ivar maximum: Required. the maximum number of instances for the resource. The actual maximum - number of instances is limited by the cores that are available in the subscription. + :ivar maximum: the maximum number of instances for the resource. The actual maximum number of + instances is limited by the cores that are available in the subscription. Required. :vartype maximum: str - :ivar default: Required. the number of instances that will be set if metrics are not available - for evaluation. The default is only used if the current instance count is lower than the - default. + :ivar default: the number of instances that will be set if metrics are not available for + evaluation. The default is only used if the current instance count is lower than the default. + Required. :vartype default: str """ _validation = { - 'minimum': {'required': True}, - 'maximum': {'required': True}, - 'default': {'required': True}, + "minimum": {"required": True}, + "maximum": {"required": True}, + "default": {"required": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'str'}, - 'maximum': {'key': 'maximum', 'type': 'str'}, - 'default': {'key': 'default', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "str"}, + "maximum": {"key": "maximum", "type": "str"}, + "default": {"key": "default", "type": "str"}, } - def __init__( - self, - *, - minimum: str, - maximum: str, - default: str, - **kwargs - ): + def __init__(self, *, minimum: str, maximum: str, default: str, **kwargs): """ - :keyword minimum: Required. the minimum number of instances for the resource. + :keyword minimum: the minimum number of instances for the resource. Required. :paramtype minimum: str - :keyword maximum: Required. the maximum number of instances for the resource. The actual - maximum number of instances is limited by the cores that are available in the subscription. + :keyword maximum: the maximum number of instances for the resource. The actual maximum number + of instances is limited by the cores that are available in the subscription. Required. :paramtype maximum: str - :keyword default: Required. the number of instances that will be set if metrics are not - available for evaluation. The default is only used if the current instance count is lower than - the default. + :keyword default: the number of instances that will be set if metrics are not available for + evaluation. The default is only used if the current instance count is lower than the default. + Required. :paramtype default: str """ - super(ScaleCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.minimum = minimum self.maximum = maximum self.default = default -class ScaleRule(msrest.serialization.Model): +class ScaleRule(_serialization.Model): """A rule that provide the triggers and parameters for the scaling action. All required parameters must be populated in order to send to Azure. - :ivar metric_trigger: Required. the trigger that results in a scaling action. + :ivar metric_trigger: the trigger that results in a scaling action. Required. :vartype metric_trigger: ~$(python-base-namespace).v2015_04_01.models.MetricTrigger - :ivar scale_action: Required. the parameters for the scaling action. + :ivar scale_action: the parameters for the scaling action. Required. :vartype scale_action: ~$(python-base-namespace).v2015_04_01.models.ScaleAction """ _validation = { - 'metric_trigger': {'required': True}, - 'scale_action': {'required': True}, + "metric_trigger": {"required": True}, + "scale_action": {"required": True}, } _attribute_map = { - 'metric_trigger': {'key': 'metricTrigger', 'type': 'MetricTrigger'}, - 'scale_action': {'key': 'scaleAction', 'type': 'ScaleAction'}, + "metric_trigger": {"key": "metricTrigger", "type": "MetricTrigger"}, + "scale_action": {"key": "scaleAction", "type": "ScaleAction"}, } - def __init__( - self, - *, - metric_trigger: "_models.MetricTrigger", - scale_action: "_models.ScaleAction", - **kwargs - ): + def __init__(self, *, metric_trigger: "_models.MetricTrigger", scale_action: "_models.ScaleAction", **kwargs): """ - :keyword metric_trigger: Required. the trigger that results in a scaling action. + :keyword metric_trigger: the trigger that results in a scaling action. Required. :paramtype metric_trigger: ~$(python-base-namespace).v2015_04_01.models.MetricTrigger - :keyword scale_action: Required. the parameters for the scaling action. + :keyword scale_action: the parameters for the scaling action. Required. :paramtype scale_action: ~$(python-base-namespace).v2015_04_01.models.ScaleAction """ - super(ScaleRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_trigger = metric_trigger self.scale_action = scale_action -class ScaleRuleMetricDimension(msrest.serialization.Model): +class ScaleRuleMetricDimension(_serialization.Model): """Specifies an auto scale rule metric dimension. All required parameters must be populated in order to send to Azure. - :ivar dimension_name: Required. Name of the dimension. + :ivar dimension_name: Name of the dimension. Required. :vartype dimension_name: str - :ivar operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. - 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. - Known values are: "Equals", "NotEquals". + :ivar operator: the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' + being equal to any of the values. 'NotEquals' being not equal to all of the values. Required. + Known values are: "Equals" and "NotEquals". :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimensionOperationType - :ivar values: Required. list of dimension values. For example: ["App1","App2"]. + :ivar values: list of dimension values. For example: ["App1","App2"]. Required. :vartype values: list[str] """ _validation = { - 'dimension_name': {'required': True}, - 'operator': {'required': True}, - 'values': {'required': True}, + "dimension_name": {"required": True}, + "operator": {"required": True}, + "values": {"required": True}, } _attribute_map = { - 'dimension_name': {'key': 'DimensionName', 'type': 'str'}, - 'operator': {'key': 'Operator', 'type': 'str'}, - 'values': {'key': 'Values', 'type': '[str]'}, + "dimension_name": {"key": "DimensionName", "type": "str"}, + "operator": {"key": "Operator", "type": "str"}, + "values": {"key": "Values", "type": "[str]"}, } def __init__( @@ -2241,23 +2157,23 @@ def __init__( **kwargs ): """ - :keyword dimension_name: Required. Name of the dimension. + :keyword dimension_name: Name of the dimension. Required. :paramtype dimension_name: str - :keyword operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are - supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the - values. Known values are: "Equals", "NotEquals". + :keyword operator: the dimension operator. Only 'Equals' and 'NotEquals' are supported. + 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. + Required. Known values are: "Equals" and "NotEquals". :paramtype operator: str or ~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimensionOperationType - :keyword values: Required. list of dimension values. For example: ["App1","App2"]. + :keyword values: list of dimension values. For example: ["App1","App2"]. Required. :paramtype values: list[str] """ - super(ScaleRuleMetricDimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.dimension_name = dimension_name self.operator = operator self.values = values -class SenderAuthorization(msrest.serialization.Model): +class SenderAuthorization(_serialization.Model): """the authorization used by the user who has performed the operation that led to this event. This captures the RBAC properties of the event. These usually include the 'action', 'role' and the 'scope'. :ivar action: the permissible actions. For instance: microsoft.support/supporttickets/write. @@ -2269,18 +2185,13 @@ class SenderAuthorization(msrest.serialization.Model): """ _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, - 'scope': {'key': 'scope', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "role": {"key": "role", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, } def __init__( - self, - *, - action: Optional[str] = None, - role: Optional[str] = None, - scope: Optional[str] = None, - **kwargs + self, *, action: Optional[str] = None, role: Optional[str] = None, scope: Optional[str] = None, **kwargs ): """ :keyword action: the permissible actions. For instance: microsoft.support/supporttickets/write. @@ -2290,7 +2201,7 @@ def __init__( :keyword scope: the scope. :paramtype scope: str """ - super(SenderAuthorization, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.role = role self.scope = scope @@ -2301,18 +2212,18 @@ class ThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric).Constant filled by server. + threshold of a metric). Required. :vartype odata_type: str :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :vartype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource - :ivar operator: Required. the operator used to compare the data and the threshold. Known values - are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :ivar operator: the operator used to compare the data and the threshold. Required. Known values + are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator - :ivar threshold: Required. the threshold value that activates the alert. + :ivar threshold: the threshold value that activates the alert. Required. :vartype threshold: float :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 @@ -2320,24 +2231,24 @@ class ThresholdRuleCondition(RuleCondition): :vartype window_size: ~datetime.timedelta :ivar time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. Known - values are: "Average", "Minimum", "Maximum", "Total", "Last". + values are: "Average", "Minimum", "Maximum", "Total", and "Last". :vartype time_aggregation: str or ~$(python-base-namespace).v2015_04_01.models.TimeAggregationOperator """ _validation = { - 'odata_type': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, + "odata_type": {"required": True}, + "operator": {"required": True}, + "threshold": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "data_source": {"key": "dataSource", "type": "RuleDataSource"}, + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "window_size": {"key": "windowSize", "type": "duration"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, } def __init__( @@ -2354,10 +2265,10 @@ def __init__( :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :paramtype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource - :keyword operator: Required. the operator used to compare the data and the threshold. Known - values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :keyword operator: the operator used to compare the data and the threshold. Required. Known + values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator - :keyword threshold: Required. the threshold value that activates the alert. + :keyword threshold: the threshold value that activates the alert. Required. :paramtype threshold: float :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 @@ -2365,19 +2276,19 @@ def __init__( :paramtype window_size: ~datetime.timedelta :keyword time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. - Known values are: "Average", "Minimum", "Maximum", "Total", "Last". + Known values are: "Average", "Minimum", "Maximum", "Total", and "Last". :paramtype time_aggregation: str or ~$(python-base-namespace).v2015_04_01.models.TimeAggregationOperator """ - super(ThresholdRuleCondition, self).__init__(data_source=data_source, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition' # type: str + super().__init__(data_source=data_source, **kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" # type: str self.operator = operator self.threshold = threshold self.window_size = window_size self.time_aggregation = time_aggregation -class TimeWindow(msrest.serialization.Model): +class TimeWindow(_serialization.Model): """A specific date-time for the profile. All required parameters must be populated in order to send to Azure. @@ -2413,31 +2324,24 @@ class TimeWindow(msrest.serialization.Model): Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. :vartype time_zone: str - :ivar start: Required. the start time for the profile in ISO 8601 format. + :ivar start: the start time for the profile in ISO 8601 format. Required. :vartype start: ~datetime.datetime - :ivar end: Required. the end time for the profile in ISO 8601 format. + :ivar end: the end time for the profile in ISO 8601 format. Required. :vartype end: ~datetime.datetime """ _validation = { - 'start': {'required': True}, - 'end': {'required': True}, + "start": {"required": True}, + "end": {"required": True}, } _attribute_map = { - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'start': {'key': 'start', 'type': 'iso-8601'}, - 'end': {'key': 'end', 'type': 'iso-8601'}, + "time_zone": {"key": "timeZone", "type": "str"}, + "start": {"key": "start", "type": "iso-8601"}, + "end": {"key": "end", "type": "iso-8601"}, } - def __init__( - self, - *, - start: datetime.datetime, - end: datetime.datetime, - time_zone: Optional[str] = None, - **kwargs - ): + def __init__(self, *, start: datetime.datetime, end: datetime.datetime, time_zone: Optional[str] = None, **kwargs): """ :keyword time_zone: the timezone of the start and end times for the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard @@ -2470,18 +2374,18 @@ def __init__( Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. :paramtype time_zone: str - :keyword start: Required. the start time for the profile in ISO 8601 format. + :keyword start: the start time for the profile in ISO 8601 format. Required. :paramtype start: ~datetime.datetime - :keyword end: Required. the end time for the profile in ISO 8601 format. + :keyword end: the end time for the profile in ISO 8601 format. Required. :paramtype end: ~datetime.datetime """ - super(TimeWindow, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_zone = time_zone self.start = start self.end = end -class WebhookNotification(msrest.serialization.Model): +class WebhookNotification(_serialization.Model): """Webhook notification of an autoscale event. :ivar service_uri: the service address to receive the notification. @@ -2491,23 +2395,17 @@ class WebhookNotification(msrest.serialization.Model): """ _attribute_map = { - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: Optional[str] = None, - properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs): """ :keyword service_uri: the service address to receive the notification. :paramtype service_uri: str :keyword properties: a property bag of settings. This value can be empty. :paramtype properties: dict[str, str] """ - super(WebhookNotification, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_uri = service_uri self.properties = properties diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py index a0ae11b4bdc2..c8326c1a0246 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py @@ -11,8 +11,7 @@ class ComparisonOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the operator that is used to compare the metric data and the threshold. - """ + """the operator that is used to compare the metric data and the threshold.""" EQUALS = "Equals" NOT_EQUALS = "NotEquals" @@ -21,18 +20,18 @@ class ComparisonOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operators allowed in the rule condition. - """ + """Operators allowed in the rule condition.""" GREATER_THAN = "GreaterThan" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + class EventLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the event level - """ + """the event level.""" CRITICAL = "Critical" ERROR = "Error" @@ -40,9 +39,9 @@ class EventLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFORMATIONAL = "Informational" VERBOSE = "Verbose" + class MetricStatisticType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the metric statistic type. How the metrics from multiple instances are combined. - """ + """the metric statistic type. How the metrics from multiple instances are combined.""" AVERAGE = "Average" MIN = "Min" @@ -50,6 +49,7 @@ class MetricStatisticType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SUM = "Sum" COUNT = "Count" + class RecurrenceFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily @@ -66,34 +66,35 @@ class RecurrenceFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): MONTH = "Month" YEAR = "Year" + class ScaleDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the scale direction. Whether the scaling action increases or decreases the number of instances. - """ + """the scale direction. Whether the scaling action increases or decreases the number of instances.""" NONE = "None" INCREASE = "Increase" DECREASE = "Decrease" + class ScaleRuleMetricDimensionOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to - any of the values. 'NotEquals' being not equal to all of the values + any of the values. 'NotEquals' being not equal to all of the values. """ EQUALS = "Equals" NOT_EQUALS = "NotEquals" + class ScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the type of action that should occur when the scale rule fires. - """ + """the type of action that should occur when the scale rule fires.""" CHANGE_COUNT = "ChangeCount" PERCENT_CHANGE_COUNT = "PercentChangeCount" EXACT_COUNT = "ExactCount" SERVICE_ALLOWED_NEXT_VALUE = "ServiceAllowedNextValue" + class TimeAggregationOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Aggregation operators allowed in a rule. - """ + """Aggregation operators allowed in a rule.""" AVERAGE = "Average" MINIMUM = "Minimum" @@ -101,6 +102,7 @@ class TimeAggregationOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): TOTAL = "Total" LAST = "Last" + class TimeAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """time aggregation type. How the data that is collected should be combined over time. The default value is Average. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/__init__.py index 3f665d258d3a..4c1cd2bf4a61 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/__init__.py @@ -16,13 +16,14 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActivityLogsOperations', - 'AutoscaleSettingsOperations', - 'EventCategoriesOperations', - 'Operations', - 'TenantActivityLogsOperations', - 'AlertRulesOperations', + "ActivityLogsOperations", + "AutoscaleSettingsOperations", + "EventCategoriesOperations", + "Operations", + "TenantActivityLogsOperations", + "AlertRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py index 6046f4eee0d3..ea70db8f2f8d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,50 +24,46 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: str, - select: Optional[str] = None, - **kwargs: Any + subscription_id: str, *, filter: str, select: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if select is not None: - _params['$select'] = _SERIALIZER.query("select", select, 'str') + _params["$select"] = _SERIALIZER.query("select", select, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ActivityLogsOperations: """ @@ -84,14 +84,8 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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: str, - select: Optional[str] = None, - **kwargs: Any - ) -> Iterable[_models.EventDataCollection]: + def list(self, filter: str, select: Optional[str] = None, **kwargs: Any) -> Iterable["_models.EventData"]: """Provides the list of records from the activity logs. :param filter: Reduces the set of data collected.:code:`
`This argument is required and it @@ -108,7 +102,7 @@ def list( '2014-07-20T04:36:37.6407898Z' and resourceProvider eq 'resourceProviderName'.:code:`
`- *List events for a correlation Id*\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq - 'correlationID'.:code:`
`:code:`
`\ **NOTE**\ : No other syntax is allowed. + 'correlationID'.:code:`
`:code:`
`\ **NOTE**\ : No other syntax is allowed. Required. :type filter: str :param select: Used to fetch events with only the given properties.:code:`
`The **$select** argument is a comma separated list of property names to be returned. Possible values are: @@ -118,34 +112,29 @@ def list( *resourceId*\ , *status*\ , *submissionTimestamp*\ , *subStatus*\ , *subscriptionId*. Default value is None. :type select: str - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventDataCollection or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventData or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventData] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventDataCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventDataCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, select=select, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -153,16 +142,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - select=select, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -178,10 +158,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -192,8 +170,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py index 00c92ceae69d..9e3a9e15b11d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +24,201 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - resource_group_name: str, - rule_name: str, - subscription_id: str, - *, - json: Optional[_models.AlertRuleResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_group_name: str, - rule_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_get_request( - resource_group_name: str, - rule_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - subscription_id: str, - resource_group_name: str, - rule_name: str, - *, - json: Optional[_models.AlertRuleResourcePatch] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class AlertRulesOperations: """ @@ -277,44 +239,101 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, rule_name: str, parameters: _models.AlertRuleResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AlertRuleResource: """Creates or updates a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. + :param parameters: The parameters of the rule to create or update. Required. :type parameters: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Creates or updates a classic metric alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, rule_name: str, parameters: Union[_models.AlertRuleResource, IO], **kwargs: Any + ) -> _models.AlertRuleResource: + """Creates or updates a classic metric alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a model type or a + IO type. Required. + :type parameters: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - _json = self._serialize.body(parameters, 'AlertRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AlertRuleResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -323,7 +342,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -331,10 +351,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,58 +362,49 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, **kwargs: Any ) -> None: """Deletes a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -402,10 +412,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -416,48 +425,37 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.AlertRuleResource: + def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: """Gets a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - request = build_get_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -465,10 +463,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -476,63 +473,128 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + alert_rules_resource: _models.AlertRuleResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Updates an existing classic metric AlertRuleResource. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param alert_rules_resource: Parameters supplied to the operation. Required. + :type alert_rules_resource: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + alert_rules_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Updates an existing classic metric AlertRuleResource. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param alert_rules_resource: Parameters supplied to the operation. Required. + :type alert_rules_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, rule_name: str, - alert_rules_resource: _models.AlertRuleResourcePatch, + alert_rules_resource: Union[_models.AlertRuleResourcePatch, IO], **kwargs: Any ) -> _models.AlertRuleResource: """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. + :param alert_rules_resource: Parameters supplied to the operation. Is either a model type or a + IO type. Required. :type alert_rules_resource: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResourcePatch - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(alert_rules_resource, (IO, bytes)): + _content = alert_rules_resource + else: + _json = self._serialize.body(alert_rules_resource, "AlertRuleResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -540,10 +602,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -552,57 +613,48 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.AlertRuleResourceCollection]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: """List the classic metric alert rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AlertRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -610,15 +662,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -634,10 +678,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -648,46 +690,36 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.AlertRuleResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: """List the classic metric alert rules within a subscription. - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AlertRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -695,14 +727,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -718,10 +743,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -732,8 +755,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py index 249a2b772fa2..ce6914a98865 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +24,207 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - autoscale_setting_name: str, - subscription_id: str, - *, - json: Optional[_models.AutoscaleSettingResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - autoscale_setting_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - autoscale_setting_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - autoscale_setting_name: str, - *, - json: Optional[_models.AutoscaleSettingResourcePatch] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class AutoscaleSettingsOperations: """ @@ -277,45 +245,39 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.AutoscaleSettingResourceCollection]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.AutoscaleSettingResource"]: """Lists the autoscale settings for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either AutoscaleSettingResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -323,15 +285,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -347,10 +301,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -361,49 +313,109 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, autoscale_setting_name: str, parameters: _models.AutoscaleSettingResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AutoscaleSettingResource: """Creates or updates an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: Union[_models.AutoscaleSettingResource, IO], + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AutoscaleSettingResource, or the result of cls(response) + :return: AutoscaleSettingResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] - _json = self._serialize.body(parameters, 'AutoscaleSettingResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AutoscaleSettingResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -412,7 +424,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -420,10 +433,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -432,58 +444,49 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - autoscale_setting_name: str, - **kwargs: Any + self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any ) -> None: """Deletes and autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -491,10 +494,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -505,48 +507,39 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - autoscale_setting_name: str, - **kwargs: Any + self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any ) -> _models.AutoscaleSettingResource: """Gets an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource, or the result of cls(response) + :return: AutoscaleSettingResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] - request = build_get_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -554,10 +547,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,64 +557,129 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, autoscale_setting_name: str, autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AutoscaleSettingResource: """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. + :param autoscale_setting_resource: Parameters supplied to the operation. Required. :type autoscale_setting_resource: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourcePatch - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Required. + :type autoscale_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: Union[_models.AutoscaleSettingResourcePatch, IO], + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Is either a model type + or a IO type. Required. + :type autoscale_setting_resource: + ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AutoscaleSettingResource, or the result of cls(response) + :return: AutoscaleSettingResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] - _json = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(autoscale_setting_resource, (IO, bytes)): + _content = autoscale_setting_resource + else: + _json = self._serialize.body(autoscale_setting_resource, "AutoscaleSettingResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -630,10 +687,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -641,50 +697,42 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.AutoscaleSettingResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AutoscaleSettingResource"]: """Lists the autoscale settings for a subscription. - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either AutoscaleSettingResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -692,14 +740,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -715,10 +756,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -729,8 +768,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py index 96a6dbc52c0a..ee526e2b22b4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +24,34 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/eventcategories") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class EventCategoriesOperations: """ @@ -72,42 +72,33 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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.EventCategoryCollection]: + def list(self, **kwargs: Any) -> Iterable["_models.LocalizableString"]: """Get the list of available event categories supported in the Activity Logs Service.:code:`
`The current list includes the following: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventCategoryCollection or the result of - cls(response) + :return: An iterator like instance of either LocalizableString or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventCategoryCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.LocalizableString] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventCategoryCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventCategoryCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -115,13 +106,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -137,10 +122,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,8 +134,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Insights/eventcategories"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Insights/eventcategories"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py index 2fe3474a556c..250fd97bed59 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,38 +23,34 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -71,37 +71,27 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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 - ) -> _models.OperationListResult: + def list(self, **kwargs: Any) -> _models.OperationListResult: """Lists all of the available operations from Microsoft.Insights provider. - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult, or the result of cls(response) + :return: OperationListResult or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.OperationListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,22 +99,20 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/providers/Microsoft.Insights/operations"} # type: ignore - + list.metadata = {"url": "/providers/Microsoft.Insights/operations"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py index 588e78c70bd8..79ec4216c051 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,45 +24,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - *, - filter: Optional[str] = None, - select: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(*, filter: Optional[str] = None, select: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/eventtypes/management/values") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if select is not None: - _params['$select'] = _SERIALIZER.query("select", select, 'str') + _params["$select"] = _SERIALIZER.query("select", select, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TenantActivityLogsOperations: """ @@ -79,14 +76,10 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - select: Optional[str] = None, - **kwargs: Any - ) -> Iterable[_models.EventDataCollection]: + self, filter: Optional[str] = None, select: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.EventData"]: """Gets the Activity Logs for the Tenant.:code:`
`Everything that is applicable to the API to get the Activity Logs for the subscription is applicable to this API (the parameters, $filter, etc.).:code:`
`One thing to point out here is that this API does *not* retrieve the logs at @@ -118,33 +111,28 @@ def list( *resourceId*\ , *status*\ , *submissionTimestamp*\ , *subStatus*\ , *subscriptionId*. Default value is None. :type select: str - :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventDataCollection or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventData or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventData] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventDataCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventDataCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - api_version=api_version, filter=filter, select=select, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -152,15 +140,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - filter=filter, - select=select, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -176,10 +156,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -190,8 +168,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Insights/eventtypes/management/values"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Insights/eventtypes/management/values"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py index b152f1a01ba7..cdc7a049c1d9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py @@ -25,18 +25,13 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,23 +40,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json index b25ebe057879..46482e0e8abd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py index 4dbfdc9804a5..11332bfbd51d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py @@ -9,20 +9,25 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import AlertRulesOperations, MetricDefinitionsOperations, Operations, ServiceDiagnosticSettingsOperations +from .operations import ( + AlertRulesOperations, + MetricDefinitionsOperations, + Operations, + ServiceDiagnosticSettingsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations @@ -35,9 +40,9 @@ class MonitorManagementClient: :vartype alert_rules: $(python-base-namespace).v2015_07_01.operations.AlertRulesOperations :ivar operations: Operations operations :vartype operations: $(python-base-namespace).v2015_07_01.operations.Operations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,7 +55,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -63,19 +70,10 @@ def __init__( self.metric_definitions = MetricDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.alert_rules = AlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -84,7 +82,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py index fe42fc99d8d7..ff77a05cbd87 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py @@ -25,18 +25,13 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,22 +40,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py index 4527d7b5fc0c..32eb44131780 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py @@ -9,20 +9,25 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import AlertRulesOperations, MetricDefinitionsOperations, Operations, ServiceDiagnosticSettingsOperations +from .operations import ( + AlertRulesOperations, + MetricDefinitionsOperations, + Operations, + ServiceDiagnosticSettingsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations @@ -35,9 +40,9 @@ class MonitorManagementClient: :vartype alert_rules: $(python-base-namespace).v2015_07_01.aio.operations.AlertRulesOperations :ivar operations: Operations operations :vartype operations: $(python-base-namespace).v2015_07_01.aio.operations.Operations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,7 +55,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -63,19 +70,10 @@ def __init__( self.metric_definitions = MetricDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.alert_rules = AlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -84,7 +82,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/__init__.py index aedf5ce120e4..5737890365bd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/__init__.py @@ -14,11 +14,12 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ServiceDiagnosticSettingsOperations', - 'MetricDefinitionsOperations', - 'AlertRulesOperations', - 'Operations', + "ServiceDiagnosticSettingsOperations", + "MetricDefinitionsOperations", + "AlertRulesOperations", + "Operations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py index b5daf5520920..531c8f85c909 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py @@ -6,10 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +26,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._alert_rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._alert_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AlertRulesOperations: """ .. warning:: @@ -43,44 +58,101 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, rule_name: str, parameters: _models.AlertRuleResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AlertRuleResource: """Creates or updates a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. + :param parameters: The parameters of the rule to create or update. Required. :type parameters: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Creates or updates a classic metric alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, rule_name: str, parameters: Union[_models.AlertRuleResource, IO], **kwargs: Any + ) -> _models.AlertRuleResource: + """Creates or updates a classic metric alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a model type or a + IO type. Required. + :type parameters: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - _json = self._serialize.body(parameters, 'AlertRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AlertRuleResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -89,7 +161,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -97,10 +170,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -109,58 +181,49 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, **kwargs: Any ) -> None: """Deletes a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -168,10 +231,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -182,48 +244,37 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.AlertRuleResource: + async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: """Gets a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - request = build_get_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -231,10 +282,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -242,63 +292,128 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + alert_rules_resource: _models.AlertRuleResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Updates an existing classic metric AlertRuleResource. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param alert_rules_resource: Parameters supplied to the operation. Required. + :type alert_rules_resource: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + alert_rules_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Updates an existing classic metric AlertRuleResource. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param alert_rules_resource: Parameters supplied to the operation. Required. + :type alert_rules_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, rule_name: str, - alert_rules_resource: _models.AlertRuleResourcePatch, + alert_rules_resource: Union[_models.AlertRuleResourcePatch, IO], **kwargs: Any ) -> _models.AlertRuleResource: """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. + :param alert_rules_resource: Parameters supplied to the operation. Is either a model type or a + IO type. Required. :type alert_rules_resource: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResourcePatch - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(alert_rules_resource, (IO, bytes)): + _content = alert_rules_resource + else: + _json = self._serialize.body(alert_rules_resource, "AlertRuleResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -306,10 +421,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -318,57 +432,50 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.AlertRuleResourceCollection]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AlertRuleResource"]: """List the classic metric alert rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AlertRuleResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -376,15 +483,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -400,10 +499,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -414,46 +511,36 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.AlertRuleResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AlertRuleResource"]: """List the classic metric alert rules within a subscription. - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AlertRuleResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -461,14 +548,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -484,10 +564,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -498,8 +576,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py index 2f10780f7037..3bbc1ca121db 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py @@ -9,7 +9,13 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +26,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._metric_definitions_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MetricDefinitionsOperations: """ .. warning:: @@ -42,17 +50,13 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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, - resource_uri: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[_models.MetricDefinitionCollection]: + self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.MetricDefinition"]: """Lists the metric definitions for the resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param filter: Reduces the set of data collected by retrieving particular metric definitions from all the definitions available for the resource.:code:`
`For example, to get just the @@ -61,34 +65,29 @@ def list( :code:``'* clauses separated by *or* logical operators.:code:`
`\ **NOTE**\ : No other syntax is allowed. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of - cls(response) + :return: An iterator like instance of either MetricDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.MetricDefinitionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -96,15 +95,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +111,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,8 +123,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py index 6338db60489a..d386bac7527e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -41,37 +49,27 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 list( - self, - **kwargs: Any - ) -> _models.OperationListResult: + async def list(self, **kwargs: Any) -> _models.OperationListResult: """Lists all of the available operations from Microsoft.Insights provider. - :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult, or the result of cls(response) + :return: OperationListResult or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.OperationListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,10 +77,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -90,12 +87,11 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/providers/Microsoft.Insights/operations"} # type: ignore - + list.metadata = {"url": "/providers/Microsoft.Insights/operations"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py index e789ce45124e..f7a7730461c2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py @@ -6,9 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._service_diagnostic_settings_operations import build_create_or_update_request, build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ServiceDiagnosticSettingsOperations: """ .. warning:: @@ -41,41 +49,30 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get( - self, - resource_uri: str, - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: + async def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource, or the result of cls(response) + :return: ServiceDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] - request = build_get_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -83,10 +80,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -94,58 +90,104 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_uri: str, parameters: _models.ServiceDiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ServiceDiagnosticSettingsResource: """Create or update new diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource - :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ServiceDiagnosticSettingsResource, or the result of cls(response) + :return: ServiceDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, resource_uri: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. 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: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_uri: str, parameters: Union[_models.ServiceDiagnosticSettingsResource, IO], **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceDiagnosticSettingsResource") request = build_create_or_update_request( resource_uri=resource_uri, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -153,22 +195,20 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore - + create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py index 3043683a3028..f67e14597faa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py @@ -42,56 +42,54 @@ from ._models_py3 import TableInfoEntry from ._models_py3 import ThresholdRuleCondition - -from ._monitor_management_client_enums import ( - AggregationType, - ConditionOperator, - TimeAggregationOperator, - Unit, -) +from ._monitor_management_client_enums import AggregationType +from ._monitor_management_client_enums import ConditionOperator +from ._monitor_management_client_enums import TimeAggregationOperator +from ._monitor_management_client_enums import Unit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AlertRuleResource', - 'AlertRuleResourceCollection', - 'AlertRuleResourcePatch', - 'DimensionProperties', - 'ErrorContract', - 'ErrorResponse', - 'LocalizableString', - 'LocationThresholdRuleCondition', - 'LogSettings', - 'LogSpecification', - 'ManagementEventAggregationCondition', - 'ManagementEventRuleCondition', - 'MetricAvailability', - 'MetricAvailabilityLocation', - 'MetricDefinition', - 'MetricDefinitionCollection', - 'MetricSettings', - 'MetricSpecification', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Resource', - 'RetentionPolicy', - 'RuleAction', - 'RuleCondition', - 'RuleDataSource', - 'RuleEmailAction', - 'RuleManagementEventClaimsDataSource', - 'RuleManagementEventDataSource', - 'RuleMetricDataSource', - 'RuleWebhookAction', - 'ServiceDiagnosticSettingsResource', - 'ServiceSpecification', - 'TableInfoEntry', - 'ThresholdRuleCondition', - 'AggregationType', - 'ConditionOperator', - 'TimeAggregationOperator', - 'Unit', + "AlertRuleResource", + "AlertRuleResourceCollection", + "AlertRuleResourcePatch", + "DimensionProperties", + "ErrorContract", + "ErrorResponse", + "LocalizableString", + "LocationThresholdRuleCondition", + "LogSettings", + "LogSpecification", + "ManagementEventAggregationCondition", + "ManagementEventRuleCondition", + "MetricAvailability", + "MetricAvailabilityLocation", + "MetricDefinition", + "MetricDefinitionCollection", + "MetricSettings", + "MetricSpecification", + "Operation", + "OperationDisplay", + "OperationListResult", + "Resource", + "RetentionPolicy", + "RuleAction", + "RuleCondition", + "RuleDataSource", + "RuleEmailAction", + "RuleManagementEventClaimsDataSource", + "RuleManagementEventDataSource", + "RuleMetricDataSource", + "RuleWebhookAction", + "ServiceDiagnosticSettingsResource", + "ServiceSpecification", + "TableInfoEntry", + "ThresholdRuleCondition", + "AggregationType", + "ConditionOperator", + "TimeAggregationOperator", + "Unit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py index 035f5c22faf3..9d9565b0d7a6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_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,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -30,41 +36,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -72,7 +72,7 @@ def __init__( self.tags = tags -class AlertRuleResource(Resource): +class AlertRuleResource(Resource): # pylint: disable=too-many-instance-attributes """The alert rule resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -85,19 +85,19 @@ class AlertRuleResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar name_properties_name: Required. the name of the alert rule. + :ivar name_properties_name: the name of the alert rule. Required. :vartype name_properties_name: str :ivar description: the description of the alert rule that will be included in the alert email. :vartype description: str :ivar provisioning_state: the provisioning state. :vartype provisioning_state: str - :ivar is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :ivar is_enabled: the flag that indicates whether the alert rule is enabled. Required. :vartype is_enabled: bool - :ivar condition: Required. the condition that results in the alert rule being activated. + :ivar condition: the condition that results in the alert rule being activated. Required. :vartype condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. @@ -110,30 +110,30 @@ class AlertRuleResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'name_properties_name': {'required': True}, - 'is_enabled': {'required': True}, - 'condition': {'required': True}, - 'last_updated_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "name_properties_name": {"required": True}, + "is_enabled": {"required": True}, + "condition": {"required": True}, + "last_updated_time": {"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}'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'RuleCondition'}, - 'action': {'key': 'properties.action', 'type': 'RuleAction'}, - 'actions': {'key': 'properties.actions', 'type': '[RuleAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, + "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}"}, + "name_properties_name": {"key": "properties.name", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, + "condition": {"key": "properties.condition", "type": "RuleCondition"}, + "action": {"key": "properties.action", "type": "RuleAction"}, + "actions": {"key": "properties.actions", "type": "[RuleAction]"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, } def __init__( @@ -151,20 +151,20 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword name_properties_name: Required. the name of the alert rule. + :keyword name_properties_name: the name of the alert rule. Required. :paramtype name_properties_name: str :keyword description: the description of the alert rule that will be included in the alert email. :paramtype description: str :keyword provisioning_state: the provisioning state. :paramtype provisioning_state: str - :keyword is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :keyword is_enabled: the flag that indicates whether the alert rule is enabled. Required. :paramtype is_enabled: bool - :keyword condition: Required. the condition that results in the alert rule being activated. + :keyword condition: the condition that results in the alert rule being activated. Required. :paramtype condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition :keyword action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. @@ -173,7 +173,7 @@ def __init__( and when an alert condition is resolved. :paramtype actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] """ - super(AlertRuleResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.name_properties_name = name_properties_name self.description = description self.provisioning_state = provisioning_state @@ -184,7 +184,7 @@ def __init__( self.last_updated_time = None -class AlertRuleResourceCollection(msrest.serialization.Model): +class AlertRuleResourceCollection(_serialization.Model): """Represents a collection of alert rule resources. :ivar value: the values for the alert rule resources. @@ -192,29 +192,24 @@ class AlertRuleResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AlertRuleResource]'}, + "value": {"key": "value", "type": "[AlertRuleResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.AlertRuleResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs): """ :keyword value: the values for the alert rule resources. :paramtype value: list[~$(python-base-namespace).v2015_07_01.models.AlertRuleResource] """ - super(AlertRuleResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class AlertRuleResourcePatch(msrest.serialization.Model): +class AlertRuleResourcePatch(_serialization.Model): """The alert rule object for patch operations. Variables are only populated by the server, and will be ignored when sending a request. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar name: the name of the alert rule. :vartype name: str @@ -237,19 +232,19 @@ class AlertRuleResourcePatch(msrest.serialization.Model): """ _validation = { - 'last_updated_time': {'readonly': True}, + "last_updated_time": {"readonly": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'properties.name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'RuleCondition'}, - 'action': {'key': 'properties.action', 'type': 'RuleAction'}, - 'actions': {'key': 'properties.actions', 'type': '[RuleAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, + "tags": {"key": "tags", "type": "{str}"}, + "name": {"key": "properties.name", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, + "condition": {"key": "properties.condition", "type": "RuleCondition"}, + "action": {"key": "properties.action", "type": "RuleAction"}, + "actions": {"key": "properties.actions", "type": "[RuleAction]"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, } def __init__( @@ -266,7 +261,7 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword name: the name of the alert rule. :paramtype name: str @@ -286,7 +281,7 @@ def __init__( and when an alert condition is resolved. :paramtype actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] """ - super(AlertRuleResourcePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.name = name self.description = description @@ -298,7 +293,7 @@ def __init__( self.last_updated_time = None -class DimensionProperties(msrest.serialization.Model): +class DimensionProperties(_serialization.Model): """Type of operation: get, read, delete, etc. :ivar name: Name of dimension. @@ -312,15 +307,15 @@ class DimensionProperties(msrest.serialization.Model): :vartype is_hidden: bool :ivar default_dimension_values: Default dimension value to be sent down for the hidden dimension during query. - :vartype default_dimension_values: any + :vartype default_dimension_values: JSON """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, - 'is_hidden': {'key': 'isHidden', 'type': 'bool'}, - 'default_dimension_values': {'key': 'defaultDimensionValues', 'type': 'object'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, + "is_hidden": {"key": "isHidden", "type": "bool"}, + "default_dimension_values": {"key": "defaultDimensionValues", "type": "object"}, } def __init__( @@ -330,7 +325,7 @@ def __init__( display_name: Optional[str] = None, to_be_exported_for_shoebox: Optional[bool] = None, is_hidden: Optional[bool] = None, - default_dimension_values: Optional[Any] = None, + default_dimension_values: Optional[JSON] = None, **kwargs ): """ @@ -345,9 +340,9 @@ def __init__( :paramtype is_hidden: bool :keyword default_dimension_values: Default dimension value to be sent down for the hidden dimension during query. - :paramtype default_dimension_values: any + :paramtype default_dimension_values: JSON """ - super(DimensionProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox @@ -355,7 +350,7 @@ def __init__( self.default_dimension_values = default_dimension_values -class ErrorContract(msrest.serialization.Model): +class ErrorContract(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. @@ -363,24 +358,19 @@ class ErrorContract(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~$(python-base-namespace).v2015_07_01.models.ErrorResponse """ - super(ErrorContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -390,78 +380,66 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class LocalizableString(msrest.serialization.Model): +class LocalizableString(_serialization.Model): """The localizable string class. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the invariant value. + :ivar value: the invariant value. Required. :vartype value: str :ivar localized_value: the locale specific value. :vartype localized_value: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: str, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs): """ - :keyword value: Required. the invariant value. + :keyword value: the invariant value. Required. :paramtype value: str :keyword localized_value: the locale specific value. :paramtype localized_value: str """ - super(LocalizableString, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class RuleCondition(msrest.serialization.Model): +class RuleCondition(_serialization.Model): """The condition that results in the alert rule being activated. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: LocationThresholdRuleCondition, ManagementEventRuleCondition, ThresholdRuleCondition. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + LocationThresholdRuleCondition, ManagementEventRuleCondition, ThresholdRuleCondition All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric).Constant filled by server. + threshold of a metric). Required. :vartype odata_type: str :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -469,30 +447,29 @@ class RuleCondition(msrest.serialization.Model): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "data_source": {"key": "dataSource", "type": "RuleDataSource"}, } _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition': 'LocationThresholdRuleCondition', 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition': 'ManagementEventRuleCondition', 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition': 'ThresholdRuleCondition'} + "odata_type": { + "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition": "LocationThresholdRuleCondition", + "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition": "ManagementEventRuleCondition", + "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition": "ThresholdRuleCondition", + } } - def __init__( - self, - *, - data_source: Optional["_models.RuleDataSource"] = None, - **kwargs - ): + def __init__(self, *, data_source: Optional["_models.RuleDataSource"] = None, **kwargs): """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :paramtype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource """ - super(RuleCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] self.data_source = data_source @@ -502,10 +479,10 @@ class LocationThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric).Constant filled by server. + threshold of a metric). Required. :vartype odata_type: str :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -514,21 +491,21 @@ class LocationThresholdRuleCondition(RuleCondition): alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. :vartype window_size: ~datetime.timedelta - :ivar failed_location_count: Required. the number of locations that must fail to activate the - alert. + :ivar failed_location_count: the number of locations that must fail to activate the alert. + Required. :vartype failed_location_count: int """ _validation = { - 'odata_type': {'required': True}, - 'failed_location_count': {'required': True, 'minimum': 0}, + "odata_type": {"required": True}, + "failed_location_count": {"required": True, "minimum": 0}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - 'failed_location_count': {'key': 'failedLocationCount', 'type': 'int'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "data_source": {"key": "dataSource", "type": "RuleDataSource"}, + "window_size": {"key": "windowSize", "type": "duration"}, + "failed_location_count": {"key": "failedLocationCount", "type": "int"}, } def __init__( @@ -547,17 +524,17 @@ def __init__( alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. :paramtype window_size: ~datetime.timedelta - :keyword failed_location_count: Required. the number of locations that must fail to activate - the alert. + :keyword failed_location_count: the number of locations that must fail to activate the alert. + Required. :paramtype failed_location_count: int """ - super(LocationThresholdRuleCondition, self).__init__(data_source=data_source, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition' # type: str + super().__init__(data_source=data_source, **kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" # type: str self.window_size = window_size self.failed_location_count = failed_location_count -class LogSettings(msrest.serialization.Model): +class LogSettings(_serialization.Model): """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. All required parameters must be populated in order to send to Azure. @@ -566,20 +543,20 @@ class LogSettings(msrest.serialization.Model): to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. :vartype category: str - :ivar enabled: Required. a value indicating whether this log is enabled. + :ivar enabled: a value indicating whether this log is enabled. Required. :vartype enabled: bool :ivar retention_policy: the retention policy for this log. :vartype retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy """ _validation = { - 'enabled': {'required': True}, + "enabled": {"required": True}, } _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, + "category": {"key": "category", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, } def __init__( @@ -595,18 +572,18 @@ def __init__( applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. :paramtype category: str - :keyword enabled: Required. a value indicating whether this log is enabled. + :keyword enabled: a value indicating whether this log is enabled. Required. :paramtype enabled: bool :keyword retention_policy: the retention policy for this log. :paramtype retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy """ - super(LogSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.category = category self.enabled = enabled self.retention_policy = retention_policy -class LogSpecification(msrest.serialization.Model): +class LogSpecification(_serialization.Model): """Log specification of operation. :ivar name: Name of log specification. @@ -618,9 +595,9 @@ class LogSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, } def __init__( @@ -639,17 +616,17 @@ def __init__( :keyword blob_duration: Blob duration of specification. :paramtype blob_duration: str """ - super(LogSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration -class ManagementEventAggregationCondition(msrest.serialization.Model): +class ManagementEventAggregationCondition(_serialization.Model): """How the data that is collected should be combined over time. :ivar operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", - "LessThan", "LessThanOrEqual". + "LessThan", and "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator :ivar threshold: The threshold value that activates the alert. :vartype threshold: float @@ -660,9 +637,9 @@ class ManagementEventAggregationCondition(msrest.serialization.Model): """ _attribute_map = { - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "window_size": {"key": "windowSize", "type": "duration"}, } def __init__( @@ -675,7 +652,7 @@ def __init__( ): """ :keyword operator: the condition operator. Known values are: "GreaterThan", - "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator :keyword threshold: The threshold value that activates the alert. :paramtype threshold: float @@ -684,7 +661,7 @@ def __init__( day. :paramtype window_size: ~datetime.timedelta """ - super(ManagementEventAggregationCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.operator = operator self.threshold = threshold self.window_size = window_size @@ -695,10 +672,10 @@ class ManagementEventRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric).Constant filled by server. + threshold of a metric). Required. :vartype odata_type: str :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -711,13 +688,13 @@ class ManagementEventRuleCondition(RuleCondition): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'aggregation': {'key': 'aggregation', 'type': 'ManagementEventAggregationCondition'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "data_source": {"key": "dataSource", "type": "RuleDataSource"}, + "aggregation": {"key": "aggregation", "type": "ManagementEventAggregationCondition"}, } def __init__( @@ -737,12 +714,12 @@ def __init__( :paramtype aggregation: ~$(python-base-namespace).v2015_07_01.models.ManagementEventAggregationCondition """ - super(ManagementEventRuleCondition, self).__init__(data_source=data_source, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition' # type: str + super().__init__(data_source=data_source, **kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" # type: str self.aggregation = aggregation -class MetricAvailability(msrest.serialization.Model): +class MetricAvailability(_serialization.Model): """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed @@ -756,9 +733,9 @@ class MetricAvailability(msrest.serialization.Model): """ _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'retention': {'key': 'retention', 'type': 'duration'}, - 'location': {'key': 'location', 'type': 'MetricAvailabilityLocation'}, + "time_grain": {"key": "timeGrain", "type": "duration"}, + "retention": {"key": "retention", "type": "duration"}, + "location": {"key": "location", "type": "MetricAvailabilityLocation"}, } def __init__( @@ -779,13 +756,13 @@ def __init__( :keyword location: Info about where the metric data is stored. :paramtype location: ~$(python-base-namespace).v2015_07_01.models.MetricAvailabilityLocation """ - super(MetricAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_grain = time_grain self.retention = retention self.location = location -class MetricAvailabilityLocation(msrest.serialization.Model): +class MetricAvailabilityLocation(_serialization.Model): """Info about where the metric data is stored. :ivar table_endpoint: The url for the storage account. @@ -797,9 +774,9 @@ class MetricAvailabilityLocation(msrest.serialization.Model): """ _attribute_map = { - 'table_endpoint': {'key': 'tableEndpoint', 'type': 'str'}, - 'table_info': {'key': 'tableInfo', 'type': '[TableInfoEntry]'}, - 'partition_key': {'key': 'partitionKey', 'type': 'str'}, + "table_endpoint": {"key": "tableEndpoint", "type": "str"}, + "table_info": {"key": "tableInfo", "type": "[TableInfoEntry]"}, + "partition_key": {"key": "partitionKey", "type": "str"}, } def __init__( @@ -819,13 +796,13 @@ def __init__( stored. :paramtype partition_key: str """ - super(MetricAvailabilityLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.table_endpoint = table_endpoint self.table_info = table_info self.partition_key = partition_key -class MetricDefinition(msrest.serialization.Model): +class MetricDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Metric definition class specifies the metadata for a metric. :ivar resource_id: The resource identifier of the resource that emitted the metric. @@ -837,14 +814,14 @@ class MetricDefinition(msrest.serialization.Model): :ivar category: The category of this metric. :vartype category: str :ivar unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds". + "CountPerSecond", "BytesPerSecond", "Percent", and "MilliSeconds". :vartype unit: str or ~$(python-base-namespace).v2015_07_01.models.Unit :ivar start_time: Start time of the metadata request timespan. :vartype start_time: ~datetime.datetime :ivar end_time: End time of the metadata request timespan. :vartype end_time: ~datetime.datetime :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and "Total". :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2015_07_01.models.AggregationType @@ -861,17 +838,17 @@ class MetricDefinition(msrest.serialization.Model): """ _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'category': {'key': 'category', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'primary_aggregation_type': {'key': 'primaryAggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'metric_availabilities': {'key': 'metricAvailabilities', 'type': '[MetricAvailability]'}, - 'id': {'key': 'id', 'type': 'str'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "resource_uri": {"key": "resourceUri", "type": "str"}, + "name": {"key": "name", "type": "LocalizableString"}, + "category": {"key": "category", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "primary_aggregation_type": {"key": "primaryAggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "metric_availabilities": {"key": "metricAvailabilities", "type": "[MetricAvailability]"}, + "id": {"key": "id", "type": "str"}, } def __init__( @@ -887,7 +864,7 @@ def __init__( primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, supported_aggregation_types: Optional[List[Union[str, "_models.AggregationType"]]] = None, metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin **kwargs ): """ @@ -900,14 +877,14 @@ def __init__( :keyword category: The category of this metric. :paramtype category: str :keyword unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds". + "CountPerSecond", "BytesPerSecond", "Percent", and "MilliSeconds". :paramtype unit: str or ~$(python-base-namespace).v2015_07_01.models.Unit :keyword start_time: Start time of the metadata request timespan. :paramtype start_time: ~datetime.datetime :keyword end_time: End time of the metadata request timespan. :paramtype end_time: ~datetime.datetime :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and "Total". :paramtype primary_aggregation_type: str or ~$(python-base-namespace).v2015_07_01.models.AggregationType @@ -922,7 +899,7 @@ def __init__( :keyword id: the resource identifier of the metric definition. :paramtype id: str """ - super(MetricDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.resource_uri = resource_uri self.name = name @@ -936,66 +913,66 @@ def __init__( self.id = id -class MetricDefinitionCollection(msrest.serialization.Model): +class MetricDefinitionCollection(_serialization.Model): """Represents collection of metric definitions. All required parameters must be populated in order to send to Azure. :ivar id: Resource Id for these metric definitions. :vartype id: str - :ivar value: Required. the values for the metric definitions. + :ivar value: the values for the metric definitions. Required. :vartype value: list[~$(python-base-namespace).v2015_07_01.models.MetricDefinition] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[MetricDefinition]'}, + "id": {"key": "id", "type": "str"}, + "value": {"key": "value", "type": "[MetricDefinition]"}, } def __init__( self, *, value: List["_models.MetricDefinition"], - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin **kwargs ): """ :keyword id: Resource Id for these metric definitions. :paramtype id: str - :keyword value: Required. the values for the metric definitions. + :keyword value: the values for the metric definitions. Required. :paramtype value: list[~$(python-base-namespace).v2015_07_01.models.MetricDefinition] """ - super(MetricDefinitionCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.value = value -class MetricSettings(msrest.serialization.Model): +class MetricSettings(_serialization.Model): """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. All required parameters must be populated in order to send to Azure. - :ivar time_grain: Required. the timegrain of the metric in ISO8601 format. + :ivar time_grain: the timegrain of the metric in ISO8601 format. Required. :vartype time_grain: ~datetime.timedelta - :ivar enabled: Required. a value indicating whether this timegrain is enabled. + :ivar enabled: a value indicating whether this timegrain is enabled. Required. :vartype enabled: bool :ivar retention_policy: the retention policy for this timegrain. :vartype retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy """ _validation = { - 'time_grain': {'required': True}, - 'enabled': {'required': True}, + "time_grain": {"required": True}, + "enabled": {"required": True}, } _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, + "time_grain": {"key": "timeGrain", "type": "duration"}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, } def __init__( @@ -1007,20 +984,20 @@ def __init__( **kwargs ): """ - :keyword time_grain: Required. the timegrain of the metric in ISO8601 format. + :keyword time_grain: the timegrain of the metric in ISO8601 format. Required. :paramtype time_grain: ~datetime.timedelta - :keyword enabled: Required. a value indicating whether this timegrain is enabled. + :keyword enabled: a value indicating whether this timegrain is enabled. Required. :paramtype enabled: bool :keyword retention_policy: the retention policy for this timegrain. :paramtype retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy """ - super(MetricSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_grain = time_grain self.enabled = enabled self.retention_policy = retention_policy -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes """Metric specification of operation. :ivar name: The name of the metric. @@ -1054,19 +1031,19 @@ class MetricSpecification(msrest.serialization.Model): """ _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'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'availabilities': {'key': 'availabilities', 'type': '[str]'}, - 'lock_aggregation_type': {'key': 'lockAggregationType', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[DimensionProperties]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'internal_metric_name': {'key': 'internalMetricName', '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"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "availabilities": {"key": "availabilities", "type": "[str]"}, + "lock_aggregation_type": {"key": "lockAggregationType", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[DimensionProperties]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "internal_metric_name": {"key": "internalMetricName", "type": "str"}, } def __init__( @@ -1117,7 +1094,7 @@ def __init__( :keyword internal_metric_name: The internal metric name. :paramtype internal_metric_name: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1133,7 +1110,7 @@ def __init__( self.internal_metric_name = internal_metric_name -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Microsoft Insights API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1148,10 +1125,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -1174,14 +1151,14 @@ def __init__( :paramtype service_specification: ~$(python-base-namespace).v2015_07_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar publisher: The publisher of this operation. @@ -1197,11 +1174,11 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "publisher": {"key": "publisher", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1226,7 +1203,7 @@ def __init__( :keyword description: The description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.publisher = publisher self.provider = provider self.resource = resource @@ -1234,7 +1211,7 @@ def __init__( self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Microsoft.Insights operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of operations supported by the Microsoft.Insights provider. @@ -1244,114 +1221,101 @@ class OperationListResult(msrest.serialization.Model): """ _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: Optional[List["_models.Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of operations supported by the Microsoft.Insights provider. :paramtype value: list[~$(python-base-namespace).v2015_07_01.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RetentionPolicy(msrest.serialization.Model): +class RetentionPolicy(_serialization.Model): """Specifies the retention policy for the log. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :ivar enabled: a value indicating whether the retention policy is enabled. Required. :vartype enabled: bool - :ivar days: Required. the number of days for the retention in days. A value of 0 will retain - the events indefinitely. + :ivar days: the number of days for the retention in days. A value of 0 will retain the events + indefinitely. Required. :vartype days: int """ _validation = { - 'enabled': {'required': True}, - 'days': {'required': True}, + "enabled": {"required": True}, + "days": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: bool, - days: int, - **kwargs - ): + def __init__(self, *, enabled: bool, days: int, **kwargs): """ - :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :keyword enabled: a value indicating whether the retention policy is enabled. Required. :paramtype enabled: bool - :keyword days: Required. the number of days for the retention in days. A value of 0 will retain - the events indefinitely. + :keyword days: the number of days for the retention in days. A value of 0 will retain the + events indefinitely. Required. :paramtype days: int """ - super(RetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class RuleAction(msrest.serialization.Model): +class RuleAction(_serialization.Model): """The action that is performed when the alert rule becomes active, and when an alert condition is resolved. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RuleEmailAction, RuleWebhookAction. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + RuleEmailAction, RuleWebhookAction All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction.Constant filled by server. + :ivar odata_type: specifies the type of the action. There are two types of actions: + RuleEmailAction and RuleWebhookAction. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.RuleEmailAction': 'RuleEmailAction', 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction': 'RuleWebhookAction'} + "odata_type": { + "Microsoft.Azure.Management.Insights.Models.RuleEmailAction": "RuleEmailAction", + "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction": "RuleWebhookAction", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(RuleAction, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] -class RuleDataSource(msrest.serialization.Model): +class RuleDataSource(_serialization.Model): """The resource from which the rule collects its data. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RuleManagementEventDataSource, RuleMetricDataSource. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + RuleManagementEventDataSource, RuleMetricDataSource All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of data source. There are two types of rule data - sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :ivar odata_type: specifies the type of data source. There are two types of rule data sources: + RuleMetricDataSource and RuleManagementEventDataSource. Required. :vartype odata_type: str :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1366,19 +1330,22 @@ class RuleDataSource(msrest.serialization.Model): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "resource_uri": {"key": "resourceUri", "type": "str"}, + "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, + "resource_location": {"key": "resourceLocation", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, } _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource': 'RuleManagementEventDataSource', 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource': 'RuleMetricDataSource'} + "odata_type": { + "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource": "RuleManagementEventDataSource", + "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource": "RuleMetricDataSource", + } } def __init__( @@ -1402,7 +1369,7 @@ def __init__( :keyword metric_namespace: the namespace of the metric. :paramtype metric_namespace: str """ - super(RuleDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] self.resource_uri = resource_uri self.legacy_resource_id = legacy_resource_id @@ -1415,8 +1382,8 @@ class RuleEmailAction(RuleAction): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction.Constant filled by server. + :ivar odata_type: specifies the type of the action. There are two types of actions: + RuleEmailAction and RuleWebhookAction. Required. :vartype odata_type: str :ivar send_to_service_owners: Whether the administrators (service and co-administrators) of the service should be notified when the alert is activated. @@ -1427,21 +1394,17 @@ class RuleEmailAction(RuleAction): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'send_to_service_owners': {'key': 'sendToServiceOwners', 'type': 'bool'}, - 'custom_emails': {'key': 'customEmails', 'type': '[str]'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "send_to_service_owners": {"key": "sendToServiceOwners", "type": "bool"}, + "custom_emails": {"key": "customEmails", "type": "[str]"}, } def __init__( - self, - *, - send_to_service_owners: Optional[bool] = None, - custom_emails: Optional[List[str]] = None, - **kwargs + self, *, send_to_service_owners: Optional[bool] = None, custom_emails: Optional[List[str]] = None, **kwargs ): """ :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of @@ -1451,13 +1414,13 @@ def __init__( activation of the alert. :paramtype custom_emails: list[str] """ - super(RuleEmailAction, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleEmailAction' # type: str + super().__init__(**kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" # type: str self.send_to_service_owners = send_to_service_owners self.custom_emails = custom_emails -class RuleManagementEventClaimsDataSource(msrest.serialization.Model): +class RuleManagementEventClaimsDataSource(_serialization.Model): """The claims for a rule management event data source. :ivar email_address: the email address. @@ -1465,30 +1428,25 @@ class RuleManagementEventClaimsDataSource(msrest.serialization.Model): """ _attribute_map = { - 'email_address': {'key': 'emailAddress', 'type': 'str'}, + "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__( - self, - *, - email_address: Optional[str] = None, - **kwargs - ): + def __init__(self, *, email_address: Optional[str] = None, **kwargs): """ :keyword email_address: the email address. :paramtype email_address: str """ - super(RuleManagementEventClaimsDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.email_address = email_address -class RuleManagementEventDataSource(RuleDataSource): +class RuleManagementEventDataSource(RuleDataSource): # pylint: disable=too-many-instance-attributes """A rule management event data source. The discriminator fields is always RuleManagementEventDataSource in this case. All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of data source. There are two types of rule data - sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :ivar odata_type: specifies the type of data source. There are two types of rule data sources: + RuleMetricDataSource and RuleManagementEventDataSource. Required. :vartype odata_type: str :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1524,24 +1482,24 @@ class RuleManagementEventDataSource(RuleDataSource): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'event_name': {'key': 'eventName', 'type': 'str'}, - 'event_source': {'key': 'eventSource', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'operation_name': {'key': 'operationName', 'type': 'str'}, - 'resource_group_name': {'key': 'resourceGroupName', 'type': 'str'}, - 'resource_provider_name': {'key': 'resourceProviderName', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'sub_status': {'key': 'subStatus', 'type': 'str'}, - 'claims': {'key': 'claims', 'type': 'RuleManagementEventClaimsDataSource'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "resource_uri": {"key": "resourceUri", "type": "str"}, + "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, + "resource_location": {"key": "resourceLocation", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "event_name": {"key": "eventName", "type": "str"}, + "event_source": {"key": "eventSource", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "operation_name": {"key": "operationName", "type": "str"}, + "resource_group_name": {"key": "resourceGroupName", "type": "str"}, + "resource_provider_name": {"key": "resourceProviderName", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "sub_status": {"key": "subStatus", "type": "str"}, + "claims": {"key": "claims", "type": "RuleManagementEventClaimsDataSource"}, } def __init__( @@ -1595,8 +1553,14 @@ def __init__( :paramtype claims: ~$(python-base-namespace).v2015_07_01.models.RuleManagementEventClaimsDataSource """ - super(RuleManagementEventDataSource, self).__init__(resource_uri=resource_uri, legacy_resource_id=legacy_resource_id, resource_location=resource_location, metric_namespace=metric_namespace, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource' # type: str + super().__init__( + resource_uri=resource_uri, + legacy_resource_id=legacy_resource_id, + resource_location=resource_location, + metric_namespace=metric_namespace, + **kwargs + ) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" # type: str self.event_name = event_name self.event_source = event_source self.level = level @@ -1613,8 +1577,8 @@ class RuleMetricDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of data source. There are two types of rule data - sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :ivar odata_type: specifies the type of data source. There are two types of rule data sources: + RuleMetricDataSource and RuleManagementEventDataSource. Required. :vartype odata_type: str :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1631,16 +1595,16 @@ class RuleMetricDataSource(RuleDataSource): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "resource_uri": {"key": "resourceUri", "type": "str"}, + "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, + "resource_location": {"key": "resourceLocation", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "metric_name": {"key": "metricName", "type": "str"}, } def __init__( @@ -1667,8 +1631,14 @@ def __init__( :keyword metric_name: the name of the metric that defines what the rule monitors. :paramtype metric_name: str """ - super(RuleMetricDataSource, self).__init__(resource_uri=resource_uri, legacy_resource_id=legacy_resource_id, resource_location=resource_location, metric_namespace=metric_namespace, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource' # type: str + super().__init__( + resource_uri=resource_uri, + legacy_resource_id=legacy_resource_id, + resource_location=resource_location, + metric_namespace=metric_namespace, + **kwargs + ) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" # type: str self.metric_name = metric_name @@ -1677,8 +1647,8 @@ class RuleWebhookAction(RuleAction): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction.Constant filled by server. + :ivar odata_type: specifies the type of the action. There are two types of actions: + RuleEmailAction and RuleWebhookAction. Required. :vartype odata_type: str :ivar service_uri: the service uri to Post the notification when the alert activates or resolves. @@ -1689,22 +1659,16 @@ class RuleWebhookAction(RuleAction): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: Optional[str] = None, - properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs): """ :keyword service_uri: the service uri to Post the notification when the alert activates or resolves. @@ -1713,8 +1677,8 @@ def __init__( These data are appended to the webhook payload. :paramtype properties: dict[str, str] """ - super(RuleWebhookAction, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' # type: str + super().__init__(**kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" # type: str self.service_uri = service_uri self.properties = properties @@ -1732,9 +1696,9 @@ class ServiceDiagnosticSettingsResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. @@ -1754,23 +1718,23 @@ class ServiceDiagnosticSettingsResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'metrics': {'key': 'properties.metrics', 'type': '[MetricSettings]'}, - 'logs': {'key': 'properties.logs', 'type': '[LogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, + "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}"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "metrics": {"key": "properties.metrics", "type": "[MetricSettings]"}, + "logs": {"key": "properties.logs", "type": "[LogSettings]"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, } def __init__( @@ -1786,9 +1750,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. @@ -1806,7 +1770,7 @@ def __init__( /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. :paramtype workspace_id: str """ - super(ServiceDiagnosticSettingsResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id self.metrics = metrics @@ -1814,7 +1778,7 @@ def __init__( self.workspace_id = workspace_id -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include log specifications. :ivar log_specifications: Log specifications of operation. @@ -1825,13 +1789,13 @@ class ServiceSpecification(msrest.serialization.Model): list[~$(python-base-namespace).v2015_07_01.models.MetricSpecification] :ivar legacy_metric_specifications: Legacy Metric specifications for operation. Deprecated, do not use. - :vartype legacy_metric_specifications: any + :vartype legacy_metric_specifications: JSON """ _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, - 'legacy_metric_specifications': {'key': 'legacyMetricSpecifications', 'type': 'object'}, + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, + "legacy_metric_specifications": {"key": "legacyMetricSpecifications", "type": "object"}, } def __init__( @@ -1839,7 +1803,7 @@ def __init__( *, log_specifications: Optional[List["_models.LogSpecification"]] = None, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - legacy_metric_specifications: Optional[Any] = None, + legacy_metric_specifications: Optional[JSON] = None, **kwargs ): """ @@ -1851,15 +1815,15 @@ def __init__( list[~$(python-base-namespace).v2015_07_01.models.MetricSpecification] :keyword legacy_metric_specifications: Legacy Metric specifications for operation. Deprecated, do not use. - :paramtype legacy_metric_specifications: any + :paramtype legacy_metric_specifications: JSON """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_specifications = log_specifications self.metric_specifications = metric_specifications self.legacy_metric_specifications = legacy_metric_specifications -class TableInfoEntry(msrest.serialization.Model): +class TableInfoEntry(_serialization.Model): """Info about a storage table with metric data. :ivar table_name: Name of a table with metric data for this resource. @@ -1875,11 +1839,11 @@ class TableInfoEntry(msrest.serialization.Model): """ _attribute_map = { - 'table_name': {'key': 'tableName', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'sas_token': {'key': 'sasToken', 'type': 'str'}, - 'sas_token_expiration_time': {'key': 'sasTokenExpirationTime', 'type': 'iso-8601'}, + "table_name": {"key": "tableName", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "sas_token": {"key": "sasToken", "type": "str"}, + "sas_token_expiration_time": {"key": "sasTokenExpirationTime", "type": "iso-8601"}, } def __init__( @@ -1904,7 +1868,7 @@ def __init__( :keyword sas_token_expiration_time: For the storage account with metrics. :paramtype sas_token_expiration_time: ~datetime.datetime """ - super(TableInfoEntry, self).__init__(**kwargs) + super().__init__(**kwargs) self.table_name = table_name self.start_time = start_time self.end_time = end_time @@ -1917,18 +1881,18 @@ class ThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric).Constant filled by server. + threshold of a metric). Required. :vartype odata_type: str :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :vartype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource - :ivar operator: Required. the operator used to compare the data and the threshold. Known values - are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :ivar operator: the operator used to compare the data and the threshold. Required. Known values + are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator - :ivar threshold: Required. the threshold value that activates the alert. + :ivar threshold: the threshold value that activates the alert. Required. :vartype threshold: float :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 @@ -1936,24 +1900,24 @@ class ThresholdRuleCondition(RuleCondition): :vartype window_size: ~datetime.timedelta :ivar time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. Known - values are: "Average", "Minimum", "Maximum", "Total", "Last". + values are: "Average", "Minimum", "Maximum", "Total", and "Last". :vartype time_aggregation: str or ~$(python-base-namespace).v2015_07_01.models.TimeAggregationOperator """ _validation = { - 'odata_type': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, + "odata_type": {"required": True}, + "operator": {"required": True}, + "threshold": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "data_source": {"key": "dataSource", "type": "RuleDataSource"}, + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "window_size": {"key": "windowSize", "type": "duration"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, } def __init__( @@ -1970,10 +1934,10 @@ def __init__( :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :paramtype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource - :keyword operator: Required. the operator used to compare the data and the threshold. Known - values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :keyword operator: the operator used to compare the data and the threshold. Required. Known + values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator - :keyword threshold: Required. the threshold value that activates the alert. + :keyword threshold: the threshold value that activates the alert. Required. :paramtype threshold: float :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 @@ -1981,12 +1945,12 @@ def __init__( :paramtype window_size: ~datetime.timedelta :keyword time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. - Known values are: "Average", "Minimum", "Maximum", "Total", "Last". + Known values are: "Average", "Minimum", "Maximum", "Total", and "Last". :paramtype time_aggregation: str or ~$(python-base-namespace).v2015_07_01.models.TimeAggregationOperator """ - super(ThresholdRuleCondition, self).__init__(data_source=data_source, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition' # type: str + super().__init__(data_source=data_source, **kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" # type: str self.operator = operator self.threshold = threshold self.window_size = window_size diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py index 90f2668aa444..060b21d2666a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py @@ -11,8 +11,7 @@ class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes how metric values are aggregated - """ + """Describes how metric values are aggregated.""" NONE = "None" AVERAGE = "Average" @@ -21,18 +20,18 @@ class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): MAXIMUM = "Maximum" TOTAL = "Total" + class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operators allowed in the rule condition. - """ + """Operators allowed in the rule condition.""" GREATER_THAN = "GreaterThan" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + class TimeAggregationOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Aggregation operators allowed in a rule. - """ + """Aggregation operators allowed in a rule.""" AVERAGE = "Average" MINIMUM = "Minimum" @@ -40,9 +39,9 @@ class TimeAggregationOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): TOTAL = "Total" LAST = "Last" + class Unit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the unit of the metric. - """ + """the unit of the metric.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/__init__.py index aedf5ce120e4..5737890365bd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/__init__.py @@ -14,11 +14,12 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ServiceDiagnosticSettingsOperations', - 'MetricDefinitionsOperations', - 'AlertRulesOperations', - 'Operations', + "ServiceDiagnosticSettingsOperations", + "MetricDefinitionsOperations", + "AlertRulesOperations", + "Operations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py index dc434be726e7..d11c2294afcf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +24,201 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - resource_group_name: str, - rule_name: str, - subscription_id: str, - *, - json: Optional[_models.AlertRuleResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_group_name: str, - rule_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_get_request( - resource_group_name: str, - rule_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - subscription_id: str, - resource_group_name: str, - rule_name: str, - *, - json: Optional[_models.AlertRuleResourcePatch] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class AlertRulesOperations: """ @@ -277,44 +239,101 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, rule_name: str, parameters: _models.AlertRuleResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AlertRuleResource: """Creates or updates a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. + :param parameters: The parameters of the rule to create or update. Required. :type parameters: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Creates or updates a classic metric alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, rule_name: str, parameters: Union[_models.AlertRuleResource, IO], **kwargs: Any + ) -> _models.AlertRuleResource: + """Creates or updates a classic metric alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a model type or a + IO type. Required. + :type parameters: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - _json = self._serialize.body(parameters, 'AlertRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AlertRuleResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -323,7 +342,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -331,10 +351,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,58 +362,49 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, **kwargs: Any ) -> None: """Deletes a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -402,10 +412,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -416,48 +425,37 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.AlertRuleResource: + def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: """Gets a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - request = build_get_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -465,10 +463,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -476,63 +473,128 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + alert_rules_resource: _models.AlertRuleResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Updates an existing classic metric AlertRuleResource. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param alert_rules_resource: Parameters supplied to the operation. Required. + :type alert_rules_resource: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + alert_rules_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Updates an existing classic metric AlertRuleResource. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param alert_rules_resource: Parameters supplied to the operation. Required. + :type alert_rules_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, rule_name: str, - alert_rules_resource: _models.AlertRuleResourcePatch, + alert_rules_resource: Union[_models.AlertRuleResourcePatch, IO], **kwargs: Any ) -> _models.AlertRuleResource: """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. + :param alert_rules_resource: Parameters supplied to the operation. Is either a model type or a + IO type. Required. :type alert_rules_resource: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResourcePatch - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(alert_rules_resource, (IO, bytes)): + _content = alert_rules_resource + else: + _json = self._serialize.body(alert_rules_resource, "AlertRuleResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -540,10 +602,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -552,57 +613,48 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.AlertRuleResourceCollection]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: """List the classic metric alert rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AlertRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -610,15 +662,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -634,10 +678,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -648,46 +690,36 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.AlertRuleResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: """List the classic metric alert rules within a subscription. - :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AlertRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -695,14 +727,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -718,10 +743,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -732,8 +755,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py index 21816accc29e..613e6b2f4bc6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,48 +24,41 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_uri: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_uri: 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MetricDefinitionsOperations: """ @@ -82,17 +79,13 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - resource_uri: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable[_models.MetricDefinitionCollection]: + self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.MetricDefinition"]: """Lists the metric definitions for the resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param filter: Reduces the set of data collected by retrieving particular metric definitions from all the definitions available for the resource.:code:`
`For example, to get just the @@ -101,34 +94,29 @@ def list( :code:``'* clauses separated by *or* logical operators.:code:`
`\ **NOTE**\ : No other syntax is allowed. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of - cls(response) + :return: An iterator like instance of either MetricDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.MetricDefinitionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -136,15 +124,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -160,10 +140,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -174,8 +152,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py index 828bd431cdff..541dc8b3ac14 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,38 +23,34 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -71,37 +71,27 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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 - ) -> _models.OperationListResult: + def list(self, **kwargs: Any) -> _models.OperationListResult: """Lists all of the available operations from Microsoft.Insights provider. - :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult, or the result of cls(response) + :return: OperationListResult or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.OperationListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,10 +99,9 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -120,12 +109,11 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/providers/Microsoft.Insights/operations"} # type: ignore - + list.metadata = {"url": "/providers/Microsoft.Insights/operations"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py index 18b59bf5b67e..6d7f9207a6b9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,85 +23,66 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - resource_uri: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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( - resource_uri: str, - *, - json: Optional[_models.ServiceDiagnosticSettingsResource] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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 ServiceDiagnosticSettingsOperations: """ @@ -118,41 +103,30 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get( - self, - resource_uri: str, - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: + def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource, or the result of cls(response) + :return: ServiceDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] - request = build_get_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -160,10 +134,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -171,58 +144,104 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_uri: str, parameters: _models.ServiceDiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ServiceDiagnosticSettingsResource: """Create or update new diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource - :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ServiceDiagnosticSettingsResource, or the result of cls(response) + :return: ServiceDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, resource_uri: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. 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: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_uri: str, parameters: Union[_models.ServiceDiagnosticSettingsResource, IO], **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceDiagnosticSettingsResource") request = build_create_or_update_request( resource_uri=resource_uri, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -230,22 +249,20 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore - + create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py index e63c63a28c97..4e506b40a11a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-03-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-03-01") # type: str + api_version = kwargs.pop("api_version", "2016-03-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json index 0b1363b1cf1f..da26c934e00d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py index 6698d1ccd66a..9532ba73144a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py @@ -9,20 +9,25 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import AlertRuleIncidentsOperations, AlertRulesOperations, LogProfilesOperations, MetricDefinitionsOperations +from .operations import ( + AlertRuleIncidentsOperations, + AlertRulesOperations, + LogProfilesOperations, + MetricDefinitionsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar alert_rule_incidents: AlertRuleIncidentsOperations operations @@ -35,9 +40,9 @@ class MonitorManagementClient: :ivar metric_definitions: MetricDefinitionsOperations operations :vartype metric_definitions: $(python-base-namespace).v2016_03_01.operations.MetricDefinitionsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -53,7 +58,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -63,22 +70,13 @@ def __init__( self.alert_rule_incidents = AlertRuleIncidentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.alert_rules = AlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.log_profiles = LogProfilesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.log_profiles = LogProfilesOperations(self._client, self._config, self._serialize, self._deserialize) self.metric_definitions = MetricDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -87,7 +85,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py index 77ff113d679f..5c68c583285c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-03-01") # type: str + api_version = kwargs.pop("api_version", "2016-03-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py index 903848c887db..93f3d940077a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py @@ -9,20 +9,25 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import AlertRuleIncidentsOperations, AlertRulesOperations, LogProfilesOperations, MetricDefinitionsOperations +from .operations import ( + AlertRuleIncidentsOperations, + AlertRulesOperations, + LogProfilesOperations, + MetricDefinitionsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar alert_rule_incidents: AlertRuleIncidentsOperations operations @@ -36,9 +41,9 @@ class MonitorManagementClient: :ivar metric_definitions: MetricDefinitionsOperations operations :vartype metric_definitions: $(python-base-namespace).v2016_03_01.aio.operations.MetricDefinitionsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -54,7 +59,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -64,22 +71,13 @@ def __init__( self.alert_rule_incidents = AlertRuleIncidentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.alert_rules = AlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.log_profiles = LogProfilesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.log_profiles = LogProfilesOperations(self._client, self._config, self._serialize, self._deserialize) self.metric_definitions = MetricDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -88,7 +86,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/__init__.py index 1bd2ec16581f..ba29eb66c1f6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/__init__.py @@ -14,11 +14,12 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AlertRuleIncidentsOperations', - 'AlertRulesOperations', - 'LogProfilesOperations', - 'MetricDefinitionsOperations', + "AlertRuleIncidentsOperations", + "AlertRulesOperations", + "LogProfilesOperations", + "MetricDefinitionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py index af9d2de4ac38..c28010c6bb7a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +28,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._alert_rule_incidents_operations import build_get_request, build_list_by_alert_rule_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AlertRuleIncidentsOperations: """ .. warning:: @@ -43,47 +52,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( - self, - resource_group_name: str, - rule_name: str, - incident_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, incident_name: str, **kwargs: Any ) -> _models.Incident: """Gets an incident associated to an alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param incident_name: The name of the incident to retrieve. + :param incident_name: The name of the incident to retrieve. Required. :type incident_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Incident, or the result of cls(response) + :return: Incident or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.Incident - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Incident] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Incident] - request = build_get_request( resource_group_name=resource_group_name, rule_name=rule_name, incident_name=incident_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -91,10 +93,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -102,54 +103,50 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Incident', pipeline_response) + deserialized = self._deserialize("Incident", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}"} # type: ignore @distributed_trace def list_by_alert_rule( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.IncidentListResult]: + self, resource_group_name: str, rule_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Incident"]: """Gets a list of incidents associated to an alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IncidentListResult or the result of cls(response) + :return: An iterator like instance of either Incident or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.IncidentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.Incident] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.IncidentListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IncidentListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_alert_rule_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_alert_rule.metadata['url'], + template_url=self.list_by_alert_rule.metadata["url"], headers=_headers, params=_params, ) @@ -157,16 +154,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_alert_rule_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -182,10 +174,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -195,8 +185,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_alert_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents"} # type: ignore + list_by_alert_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py index 4c296fb8706b..2b4bd9981871 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._alert_rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._alert_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AlertRulesOperations: """ .. warning:: @@ -43,41 +59,101 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, rule_name: str, parameters: _models.AlertRuleResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AlertRuleResource: """Creates or updates a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. + :param parameters: The parameters of the rule to create or update. Required. :type parameters: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Creates or updates a classic metric alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_group_name: str, rule_name: str, parameters: Union[_models.AlertRuleResource, IO], **kwargs: Any + ) -> _models.AlertRuleResource: + """Creates or updates a classic metric alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a model type or a + IO type. Required. + :type parameters: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - _json = self._serialize.body(parameters, 'AlertRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AlertRuleResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -86,7 +162,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -94,10 +171,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -106,55 +182,49 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, **kwargs: Any ) -> None: """Deletes a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -162,10 +232,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -176,45 +245,37 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.AlertRuleResource: + async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: """Gets a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - request = build_get_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -222,10 +283,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -233,60 +293,128 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + alert_rules_resource: _models.AlertRuleResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Updates an existing classic metric AlertRuleResource. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param alert_rules_resource: Parameters supplied to the operation. Required. + :type alert_rules_resource: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + alert_rules_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Updates an existing classic metric AlertRuleResource. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param alert_rules_resource: Parameters supplied to the operation. Required. + :type alert_rules_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, rule_name: str, - alert_rules_resource: _models.AlertRuleResourcePatch, + alert_rules_resource: Union[_models.AlertRuleResourcePatch, IO], **kwargs: Any ) -> _models.AlertRuleResource: """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. + :param alert_rules_resource: Parameters supplied to the operation. Is either a model type or a + IO type. Required. :type alert_rules_resource: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResourcePatch + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(alert_rules_resource, (IO, bytes)): + _content = alert_rules_resource + else: + _json = self._serialize.body(alert_rules_resource, "AlertRuleResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -294,10 +422,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -306,54 +433,50 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.AlertRuleResourceCollection]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AlertRuleResource"]: """List the classic metric alert rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 AlertRuleResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AlertRuleResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -361,15 +484,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -385,10 +504,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -399,43 +516,36 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.AlertRuleResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AlertRuleResource"]: """List the classic metric alert rules within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AlertRuleResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -443,14 +553,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -466,10 +573,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -480,8 +585,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py index 48650b91bb7b..95e49c14ace8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,18 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._log_profiles_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._log_profiles_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class LogProfilesOperations: """ .. warning:: @@ -43,39 +58,33 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 delete( # pylint: disable=inconsistent-return-statements - self, - log_profile_name: str, - **kwargs: Any + self, log_profile_name: str, **kwargs: Any ) -> None: """Deletes the log profile. - :param log_profile_name: The name of the log profile. + :param log_profile_name: The name of the log profile. Required. :type log_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( log_profile_name=log_profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -83,10 +92,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,41 +104,33 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore @distributed_trace_async - async def get( - self, - log_profile_name: str, - **kwargs: Any - ) -> _models.LogProfileResource: + async def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileResource: """Gets the log profile. - :param log_profile_name: The name of the log profile. + :param log_profile_name: The name of the log profile. Required. :type log_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource, or the result of cls(response) + :return: LogProfileResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileResource] - request = build_get_request( log_profile_name=log_profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -138,10 +138,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -149,47 +148,94 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LogProfileResource', pipeline_response) + deserialized = self._deserialize("LogProfileResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, log_profile_name: str, parameters: _models.LogProfileResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LogProfileResource: """Create or update a log profile in Azure Monitoring REST API. - :param log_profile_name: The name of the log profile. + :param log_profile_name: The name of the log profile. Required. :type log_profile_name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: LogProfileResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, log_profile_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.LogProfileResource: + """Create or update a log profile in Azure Monitoring REST API. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param parameters: Parameters supplied to the operation. 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: LogProfileResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, log_profile_name: str, parameters: Union[_models.LogProfileResource, IO], **kwargs: Any + ) -> _models.LogProfileResource: + """Create or update a log profile in Azure Monitoring REST API. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: LogProfileResource, or the result of cls(response) + :return: LogProfileResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileResource] - _json = self._serialize.body(parameters, 'LogProfileResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LogProfileResource") request = build_create_or_update_request( log_profile_name=log_profile_name, @@ -197,7 +243,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -205,66 +252,114 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LogProfileResource', pipeline_response) + deserialized = self._deserialize("LogProfileResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, log_profile_name: str, log_profiles_resource: _models.LogProfileResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LogProfileResource: """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. - :param log_profile_name: The name of the log profile. + :param log_profile_name: The name of the log profile. Required. :type log_profile_name: str - :param log_profiles_resource: Parameters supplied to the operation. + :param log_profiles_resource: Parameters supplied to the operation. Required. :type log_profiles_resource: ~$(python-base-namespace).v2016_03_01.models.LogProfileResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: LogProfileResource, or the result of cls(response) + :return: LogProfileResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def update( + self, log_profile_name: str, log_profiles_resource: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.LogProfileResource: + """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param log_profiles_resource: Parameters supplied to the operation. Required. + :type log_profiles_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: LogProfileResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, log_profile_name: str, log_profiles_resource: Union[_models.LogProfileResourcePatch, IO], **kwargs: Any + ) -> _models.LogProfileResource: + """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param log_profiles_resource: Parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type log_profiles_resource: + ~$(python-base-namespace).v2016_03_01.models.LogProfileResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: LogProfileResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileResource] - _json = self._serialize.body(log_profiles_resource, 'LogProfileResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(log_profiles_resource, (IO, bytes)): + _content = log_profiles_resource + else: + _json = self._serialize.body(log_profiles_resource, "LogProfileResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -272,10 +367,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -283,47 +377,41 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LogProfileResource', pipeline_response) + deserialized = self._deserialize("LogProfileResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.LogProfileCollection]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.LogProfileResource"]: """List the log profiles. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogProfileCollection or the result of - cls(response) + :return: An iterator like instance of either LogProfileResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.LogProfileCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.LogProfileResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -331,14 +419,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -354,10 +439,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -367,8 +450,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py index 3a5abaff1ef4..4100d0d1fb98 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._metric_definitions_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MetricDefinitionsOperations: """ .. warning:: @@ -42,17 +51,13 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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, - resource_uri: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[_models.MetricDefinitionCollection]: + self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.MetricDefinition"]: """Lists the metric definitions for the resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param filter: Reduces the set of data collected by retrieving particular metric definitions from all the definitions available for the resource.:code:`
`For example, to get just the @@ -62,30 +67,28 @@ def list( other syntax is allowed. 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 MetricDefinitionCollection or the result of - cls(response) + :return: An iterator like instance of either MetricDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.MetricDefinitionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +96,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +116,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,8 +128,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py index 0b5ef4df0790..a9a18ee60bc6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py @@ -34,48 +34,46 @@ from ._models_py3 import RuleWebhookAction from ._models_py3 import ThresholdRuleCondition - -from ._monitor_management_client_enums import ( - AggregationType, - ConditionOperator, - TimeAggregationOperator, - Unit, -) +from ._monitor_management_client_enums import AggregationType +from ._monitor_management_client_enums import ConditionOperator +from ._monitor_management_client_enums import TimeAggregationOperator +from ._monitor_management_client_enums import Unit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AlertRuleResource', - 'AlertRuleResourceCollection', - 'AlertRuleResourcePatch', - 'ErrorResponse', - 'Incident', - 'IncidentListResult', - 'LocalizableString', - 'LocationThresholdRuleCondition', - 'LogProfileCollection', - 'LogProfileResource', - 'LogProfileResourcePatch', - 'ManagementEventAggregationCondition', - 'ManagementEventRuleCondition', - 'MetricAvailability', - 'MetricDefinition', - 'MetricDefinitionCollection', - 'Resource', - 'RetentionPolicy', - 'RuleAction', - 'RuleCondition', - 'RuleDataSource', - 'RuleEmailAction', - 'RuleManagementEventClaimsDataSource', - 'RuleManagementEventDataSource', - 'RuleMetricDataSource', - 'RuleWebhookAction', - 'ThresholdRuleCondition', - 'AggregationType', - 'ConditionOperator', - 'TimeAggregationOperator', - 'Unit', + "AlertRuleResource", + "AlertRuleResourceCollection", + "AlertRuleResourcePatch", + "ErrorResponse", + "Incident", + "IncidentListResult", + "LocalizableString", + "LocationThresholdRuleCondition", + "LogProfileCollection", + "LogProfileResource", + "LogProfileResourcePatch", + "ManagementEventAggregationCondition", + "ManagementEventRuleCondition", + "MetricAvailability", + "MetricDefinition", + "MetricDefinitionCollection", + "Resource", + "RetentionPolicy", + "RuleAction", + "RuleCondition", + "RuleDataSource", + "RuleEmailAction", + "RuleManagementEventClaimsDataSource", + "RuleManagementEventDataSource", + "RuleMetricDataSource", + "RuleWebhookAction", + "ThresholdRuleCondition", + "AggregationType", + "ConditionOperator", + "TimeAggregationOperator", + "Unit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py index 253a1f6d33eb..d930762bdee2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_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. @@ -9,15 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -30,41 +30,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -72,7 +66,7 @@ def __init__( self.tags = tags -class AlertRuleResource(Resource): +class AlertRuleResource(Resource): # pylint: disable=too-many-instance-attributes """The alert rule resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -85,19 +79,19 @@ class AlertRuleResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar name_properties_name: Required. the name of the alert rule. + :ivar name_properties_name: the name of the alert rule. Required. :vartype name_properties_name: str :ivar description: the description of the alert rule that will be included in the alert email. :vartype description: str :ivar provisioning_state: the provisioning state. :vartype provisioning_state: str - :ivar is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :ivar is_enabled: the flag that indicates whether the alert rule is enabled. Required. :vartype is_enabled: bool - :ivar condition: Required. the condition that results in the alert rule being activated. + :ivar condition: the condition that results in the alert rule being activated. Required. :vartype condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. @@ -110,30 +104,30 @@ class AlertRuleResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'name_properties_name': {'required': True}, - 'is_enabled': {'required': True}, - 'condition': {'required': True}, - 'last_updated_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "name_properties_name": {"required": True}, + "is_enabled": {"required": True}, + "condition": {"required": True}, + "last_updated_time": {"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}'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'RuleCondition'}, - 'action': {'key': 'properties.action', 'type': 'RuleAction'}, - 'actions': {'key': 'properties.actions', 'type': '[RuleAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, + "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}"}, + "name_properties_name": {"key": "properties.name", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, + "condition": {"key": "properties.condition", "type": "RuleCondition"}, + "action": {"key": "properties.action", "type": "RuleAction"}, + "actions": {"key": "properties.actions", "type": "[RuleAction]"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, } def __init__( @@ -151,20 +145,20 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword name_properties_name: Required. the name of the alert rule. + :keyword name_properties_name: the name of the alert rule. Required. :paramtype name_properties_name: str :keyword description: the description of the alert rule that will be included in the alert email. :paramtype description: str :keyword provisioning_state: the provisioning state. :paramtype provisioning_state: str - :keyword is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :keyword is_enabled: the flag that indicates whether the alert rule is enabled. Required. :paramtype is_enabled: bool - :keyword condition: Required. the condition that results in the alert rule being activated. + :keyword condition: the condition that results in the alert rule being activated. Required. :paramtype condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition :keyword action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. @@ -173,7 +167,7 @@ def __init__( and when an alert condition is resolved. :paramtype actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] """ - super(AlertRuleResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.name_properties_name = name_properties_name self.description = description self.provisioning_state = provisioning_state @@ -184,7 +178,7 @@ def __init__( self.last_updated_time = None -class AlertRuleResourceCollection(msrest.serialization.Model): +class AlertRuleResourceCollection(_serialization.Model): """Represents a collection of alert rule resources. :ivar value: the values for the alert rule resources. @@ -192,29 +186,24 @@ class AlertRuleResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AlertRuleResource]'}, + "value": {"key": "value", "type": "[AlertRuleResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.AlertRuleResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs): """ :keyword value: the values for the alert rule resources. :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.AlertRuleResource] """ - super(AlertRuleResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class AlertRuleResourcePatch(msrest.serialization.Model): +class AlertRuleResourcePatch(_serialization.Model): """The alert rule object for patch operations. Variables are only populated by the server, and will be ignored when sending a request. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar name: the name of the alert rule. :vartype name: str @@ -237,19 +226,19 @@ class AlertRuleResourcePatch(msrest.serialization.Model): """ _validation = { - 'last_updated_time': {'readonly': True}, + "last_updated_time": {"readonly": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'properties.name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'RuleCondition'}, - 'action': {'key': 'properties.action', 'type': 'RuleAction'}, - 'actions': {'key': 'properties.actions', 'type': '[RuleAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, + "tags": {"key": "tags", "type": "{str}"}, + "name": {"key": "properties.name", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, + "condition": {"key": "properties.condition", "type": "RuleCondition"}, + "action": {"key": "properties.action", "type": "RuleAction"}, + "actions": {"key": "properties.actions", "type": "[RuleAction]"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, } def __init__( @@ -266,7 +255,7 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword name: the name of the alert rule. :paramtype name: str @@ -286,7 +275,7 @@ def __init__( and when an alert condition is resolved. :paramtype actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] """ - super(AlertRuleResourcePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.name = name self.description = description @@ -298,7 +287,7 @@ def __init__( self.last_updated_time = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -308,29 +297,23 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class Incident(msrest.serialization.Model): +class Incident(_serialization.Model): """An alert incident indicates the activation status of an alert rule. Variables are only populated by the server, and will be ignored when sending a request. @@ -349,28 +332,24 @@ class Incident(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'rule_name': {'readonly': True}, - 'is_active': {'readonly': True}, - 'activated_time': {'readonly': True}, - 'resolved_time': {'readonly': True}, + "name": {"readonly": True}, + "rule_name": {"readonly": True}, + "is_active": {"readonly": True}, + "activated_time": {"readonly": True}, + "resolved_time": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'rule_name': {'key': 'ruleName', 'type': 'str'}, - 'is_active': {'key': 'isActive', 'type': 'bool'}, - 'activated_time': {'key': 'activatedTime', 'type': 'iso-8601'}, - 'resolved_time': {'key': 'resolvedTime', 'type': 'iso-8601'}, + "name": {"key": "name", "type": "str"}, + "rule_name": {"key": "ruleName", "type": "str"}, + "is_active": {"key": "isActive", "type": "bool"}, + "activated_time": {"key": "activatedTime", "type": "iso-8601"}, + "resolved_time": {"key": "resolvedTime", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Incident, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.rule_name = None self.is_active = None @@ -378,7 +357,7 @@ def __init__( self.resolved_time = None -class IncidentListResult(msrest.serialization.Model): +class IncidentListResult(_serialization.Model): """The List incidents operation response. :ivar value: the incident collection. @@ -386,73 +365,62 @@ class IncidentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Incident]'}, + "value": {"key": "value", "type": "[Incident]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Incident"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Incident"]] = None, **kwargs): """ :keyword value: the incident collection. :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.Incident] """ - super(IncidentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class LocalizableString(msrest.serialization.Model): +class LocalizableString(_serialization.Model): """The localizable string class. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the invariant value. + :ivar value: the invariant value. Required. :vartype value: str :ivar localized_value: the locale specific value. :vartype localized_value: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: str, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs): """ - :keyword value: Required. the invariant value. + :keyword value: the invariant value. Required. :paramtype value: str :keyword localized_value: the locale specific value. :paramtype localized_value: str """ - super(LocalizableString, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class RuleCondition(msrest.serialization.Model): +class RuleCondition(_serialization.Model): """The condition that results in the alert rule being activated. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: LocationThresholdRuleCondition, ManagementEventRuleCondition, ThresholdRuleCondition. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + LocationThresholdRuleCondition, ManagementEventRuleCondition, ThresholdRuleCondition All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric).Constant filled by server. + threshold of a metric). Required. :vartype odata_type: str :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -460,30 +428,29 @@ class RuleCondition(msrest.serialization.Model): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "data_source": {"key": "dataSource", "type": "RuleDataSource"}, } _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition': 'LocationThresholdRuleCondition', 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition': 'ManagementEventRuleCondition', 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition': 'ThresholdRuleCondition'} + "odata_type": { + "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition": "LocationThresholdRuleCondition", + "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition": "ManagementEventRuleCondition", + "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition": "ThresholdRuleCondition", + } } - def __init__( - self, - *, - data_source: Optional["_models.RuleDataSource"] = None, - **kwargs - ): + def __init__(self, *, data_source: Optional["_models.RuleDataSource"] = None, **kwargs): """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :paramtype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource """ - super(RuleCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] self.data_source = data_source @@ -493,10 +460,10 @@ class LocationThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric).Constant filled by server. + threshold of a metric). Required. :vartype odata_type: str :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -505,21 +472,21 @@ class LocationThresholdRuleCondition(RuleCondition): alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. :vartype window_size: ~datetime.timedelta - :ivar failed_location_count: Required. the number of locations that must fail to activate the - alert. + :ivar failed_location_count: the number of locations that must fail to activate the alert. + Required. :vartype failed_location_count: int """ _validation = { - 'odata_type': {'required': True}, - 'failed_location_count': {'required': True, 'minimum': 0}, + "odata_type": {"required": True}, + "failed_location_count": {"required": True, "minimum": 0}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - 'failed_location_count': {'key': 'failedLocationCount', 'type': 'int'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "data_source": {"key": "dataSource", "type": "RuleDataSource"}, + "window_size": {"key": "windowSize", "type": "duration"}, + "failed_location_count": {"key": "failedLocationCount", "type": "int"}, } def __init__( @@ -538,44 +505,39 @@ def __init__( alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. :paramtype window_size: ~datetime.timedelta - :keyword failed_location_count: Required. the number of locations that must fail to activate - the alert. + :keyword failed_location_count: the number of locations that must fail to activate the alert. + Required. :paramtype failed_location_count: int """ - super(LocationThresholdRuleCondition, self).__init__(data_source=data_source, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition' # type: str + super().__init__(data_source=data_source, **kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" # type: str self.window_size = window_size self.failed_location_count = failed_location_count -class LogProfileCollection(msrest.serialization.Model): +class LogProfileCollection(_serialization.Model): """Represents a collection of log profiles. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the values of the log profiles. + :ivar value: the values of the log profiles. Required. :vartype value: list[~$(python-base-namespace).v2016_03_01.models.LogProfileResource] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[LogProfileResource]'}, + "value": {"key": "value", "type": "[LogProfileResource]"}, } - def __init__( - self, - *, - value: List["_models.LogProfileResource"], - **kwargs - ): + def __init__(self, *, value: List["_models.LogProfileResource"], **kwargs): """ - :keyword value: Required. the values of the log profiles. + :keyword value: the values of the log profiles. Required. :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.LogProfileResource] """ - super(LogProfileCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -592,9 +554,9 @@ class LogProfileResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar storage_account_id: the resource id of the storage account to which you would like to send the Activity Log. @@ -603,37 +565,37 @@ class LogProfileResource(Resource): would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. :vartype service_bus_rule_id: str - :ivar locations: Required. List of regions for which Activity Log events should be stored or - streamed. It is a comma separated list of valid ARM locations including the 'global' location. + :ivar locations: List of regions for which Activity Log events should be stored or streamed. It + is a comma separated list of valid ARM locations including the 'global' location. Required. :vartype locations: list[str] - :ivar categories: Required. the categories of the logs. These categories are created as is - convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. + :ivar categories: the categories of the logs. These categories are created as is convenient to + the user. Some values are: 'Write', 'Delete', and/or 'Action.'. Required. :vartype categories: list[str] - :ivar retention_policy: Required. the retention policy for the events in the log. + :ivar retention_policy: the retention policy for the events in the log. Required. :vartype retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'locations': {'required': True}, - 'categories': {'required': True}, - 'retention_policy': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "locations": {"required": True}, + "categories": {"required": True}, + "retention_policy": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'locations': {'key': 'properties.locations', 'type': '[str]'}, - 'categories': {'key': 'properties.categories', 'type': '[str]'}, - 'retention_policy': {'key': 'properties.retentionPolicy', 'type': 'RetentionPolicy'}, + "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}"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "locations": {"key": "properties.locations", "type": "[str]"}, + "categories": {"key": "properties.categories", "type": "[str]"}, + "retention_policy": {"key": "properties.retentionPolicy", "type": "RetentionPolicy"}, } def __init__( @@ -649,9 +611,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword storage_account_id: the resource id of the storage account to which you would like to send the Activity Log. @@ -660,16 +622,16 @@ def __init__( would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. :paramtype service_bus_rule_id: str - :keyword locations: Required. List of regions for which Activity Log events should be stored or - streamed. It is a comma separated list of valid ARM locations including the 'global' location. + :keyword locations: List of regions for which Activity Log events should be stored or streamed. + It is a comma separated list of valid ARM locations including the 'global' location. Required. :paramtype locations: list[str] - :keyword categories: Required. the categories of the logs. These categories are created as is - convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. + :keyword categories: the categories of the logs. These categories are created as is convenient + to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. Required. :paramtype categories: list[str] - :keyword retention_policy: Required. the retention policy for the events in the log. + :keyword retention_policy: the retention policy for the events in the log. Required. :paramtype retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy """ - super(LogProfileResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id self.locations = locations @@ -677,10 +639,10 @@ def __init__( self.retention_policy = retention_policy -class LogProfileResourcePatch(msrest.serialization.Model): +class LogProfileResourcePatch(_serialization.Model): """The log profile resource for patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar storage_account_id: the resource id of the storage account to which you would like to send the Activity Log. @@ -700,12 +662,12 @@ class LogProfileResourcePatch(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'locations': {'key': 'properties.locations', 'type': '[str]'}, - 'categories': {'key': 'properties.categories', 'type': '[str]'}, - 'retention_policy': {'key': 'properties.retentionPolicy', 'type': 'RetentionPolicy'}, + "tags": {"key": "tags", "type": "{str}"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "locations": {"key": "properties.locations", "type": "[str]"}, + "categories": {"key": "properties.categories", "type": "[str]"}, + "retention_policy": {"key": "properties.retentionPolicy", "type": "RetentionPolicy"}, } def __init__( @@ -720,7 +682,7 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword storage_account_id: the resource id of the storage account to which you would like to send the Activity Log. @@ -738,7 +700,7 @@ def __init__( :keyword retention_policy: the retention policy for the events in the log. :paramtype retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy """ - super(LogProfileResourcePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id @@ -747,11 +709,11 @@ def __init__( self.retention_policy = retention_policy -class ManagementEventAggregationCondition(msrest.serialization.Model): +class ManagementEventAggregationCondition(_serialization.Model): """How the data that is collected should be combined over time. :ivar operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", - "LessThan", "LessThanOrEqual". + "LessThan", and "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator :ivar threshold: The threshold value that activates the alert. :vartype threshold: float @@ -762,9 +724,9 @@ class ManagementEventAggregationCondition(msrest.serialization.Model): """ _attribute_map = { - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "window_size": {"key": "windowSize", "type": "duration"}, } def __init__( @@ -777,7 +739,7 @@ def __init__( ): """ :keyword operator: the condition operator. Known values are: "GreaterThan", - "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator :keyword threshold: The threshold value that activates the alert. :paramtype threshold: float @@ -786,7 +748,7 @@ def __init__( day. :paramtype window_size: ~datetime.timedelta """ - super(ManagementEventAggregationCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.operator = operator self.threshold = threshold self.window_size = window_size @@ -797,10 +759,10 @@ class ManagementEventRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric).Constant filled by server. + threshold of a metric). Required. :vartype odata_type: str :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -813,13 +775,13 @@ class ManagementEventRuleCondition(RuleCondition): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'aggregation': {'key': 'aggregation', 'type': 'ManagementEventAggregationCondition'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "data_source": {"key": "dataSource", "type": "RuleDataSource"}, + "aggregation": {"key": "aggregation", "type": "ManagementEventAggregationCondition"}, } def __init__( @@ -839,12 +801,12 @@ def __init__( :paramtype aggregation: ~$(python-base-namespace).v2016_03_01.models.ManagementEventAggregationCondition """ - super(ManagementEventRuleCondition, self).__init__(data_source=data_source, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition' # type: str + super().__init__(data_source=data_source, **kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" # type: str self.aggregation = aggregation -class MetricAvailability(msrest.serialization.Model): +class MetricAvailability(_serialization.Model): """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed @@ -856,8 +818,8 @@ class MetricAvailability(msrest.serialization.Model): """ _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'retention': {'key': 'retention', 'type': 'duration'}, + "time_grain": {"key": "timeGrain", "type": "duration"}, + "retention": {"key": "retention", "type": "duration"}, } def __init__( @@ -875,12 +837,12 @@ def __init__( as a duration 'PT1M', 'P1D', etc. :paramtype retention: ~datetime.timedelta """ - super(MetricAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_grain = time_grain self.retention = retention -class MetricDefinition(msrest.serialization.Model): +class MetricDefinition(_serialization.Model): """Metric definition class specifies the metadata for a metric. :ivar resource_id: the resource identifier of the resource that emitted the metric. @@ -889,10 +851,10 @@ class MetricDefinition(msrest.serialization.Model): :vartype name: ~$(python-base-namespace).v2016_03_01.models.LocalizableString :ivar unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". :vartype unit: str or ~$(python-base-namespace).v2016_03_01.models.Unit :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and "Total". :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2016_03_01.models.AggregationType @@ -905,12 +867,12 @@ class MetricDefinition(msrest.serialization.Model): """ _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'primary_aggregation_type': {'key': 'primaryAggregationType', 'type': 'str'}, - 'metric_availabilities': {'key': 'metricAvailabilities', 'type': '[MetricAvailability]'}, - 'id': {'key': 'id', 'type': 'str'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "name": {"key": "name", "type": "LocalizableString"}, + "unit": {"key": "unit", "type": "str"}, + "primary_aggregation_type": {"key": "primaryAggregationType", "type": "str"}, + "metric_availabilities": {"key": "metricAvailabilities", "type": "[MetricAvailability]"}, + "id": {"key": "id", "type": "str"}, } def __init__( @@ -921,7 +883,7 @@ def __init__( unit: Optional[Union[str, "_models.Unit"]] = None, primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin **kwargs ): """ @@ -931,10 +893,10 @@ def __init__( :paramtype name: ~$(python-base-namespace).v2016_03_01.models.LocalizableString :keyword unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". :paramtype unit: str or ~$(python-base-namespace).v2016_03_01.models.Unit :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and "Total". :paramtype primary_aggregation_type: str or ~$(python-base-namespace).v2016_03_01.models.AggregationType @@ -945,7 +907,7 @@ def __init__( :keyword id: the resource identifier of the metric definition. :paramtype id: str """ - super(MetricDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.name = name self.unit = unit @@ -954,123 +916,111 @@ def __init__( self.id = id -class MetricDefinitionCollection(msrest.serialization.Model): +class MetricDefinitionCollection(_serialization.Model): """Represents collection of metric definitions. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the values for the metric definitions. + :ivar value: the values for the metric definitions. Required. :vartype value: list[~$(python-base-namespace).v2016_03_01.models.MetricDefinition] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricDefinition]'}, + "value": {"key": "value", "type": "[MetricDefinition]"}, } - def __init__( - self, - *, - value: List["_models.MetricDefinition"], - **kwargs - ): + def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs): """ - :keyword value: Required. the values for the metric definitions. + :keyword value: the values for the metric definitions. Required. :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.MetricDefinition] """ - super(MetricDefinitionCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class RetentionPolicy(msrest.serialization.Model): +class RetentionPolicy(_serialization.Model): """Specifies the retention policy for the log. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :ivar enabled: a value indicating whether the retention policy is enabled. Required. :vartype enabled: bool - :ivar days: Required. the number of days for the retention in days. A value of 0 will retain - the events indefinitely. + :ivar days: the number of days for the retention in days. A value of 0 will retain the events + indefinitely. Required. :vartype days: int """ _validation = { - 'enabled': {'required': True}, - 'days': {'required': True, 'minimum': 0}, + "enabled": {"required": True}, + "days": {"required": True, "minimum": 0}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: bool, - days: int, - **kwargs - ): + def __init__(self, *, enabled: bool, days: int, **kwargs): """ - :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :keyword enabled: a value indicating whether the retention policy is enabled. Required. :paramtype enabled: bool - :keyword days: Required. the number of days for the retention in days. A value of 0 will retain - the events indefinitely. + :keyword days: the number of days for the retention in days. A value of 0 will retain the + events indefinitely. Required. :paramtype days: int """ - super(RetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class RuleAction(msrest.serialization.Model): +class RuleAction(_serialization.Model): """The action that is performed when the alert rule becomes active, and when an alert condition is resolved. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RuleEmailAction, RuleWebhookAction. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + RuleEmailAction, RuleWebhookAction All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction.Constant filled by server. + :ivar odata_type: specifies the type of the action. There are two types of actions: + RuleEmailAction and RuleWebhookAction. Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.RuleEmailAction': 'RuleEmailAction', 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction': 'RuleWebhookAction'} + "odata_type": { + "Microsoft.Azure.Management.Insights.Models.RuleEmailAction": "RuleEmailAction", + "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction": "RuleWebhookAction", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(RuleAction, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] -class RuleDataSource(msrest.serialization.Model): +class RuleDataSource(_serialization.Model): """The resource from which the rule collects its data. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RuleManagementEventDataSource, RuleMetricDataSource. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + RuleManagementEventDataSource, RuleMetricDataSource All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of data source. There are two types of rule data - sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :ivar odata_type: specifies the type of data source. There are two types of rule data sources: + RuleMetricDataSource and RuleManagementEventDataSource. Required. :vartype odata_type: str :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1085,19 +1035,22 @@ class RuleDataSource(msrest.serialization.Model): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "resource_uri": {"key": "resourceUri", "type": "str"}, + "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, + "resource_location": {"key": "resourceLocation", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, } _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource': 'RuleManagementEventDataSource', 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource': 'RuleMetricDataSource'} + "odata_type": { + "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource": "RuleManagementEventDataSource", + "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource": "RuleMetricDataSource", + } } def __init__( @@ -1121,7 +1074,7 @@ def __init__( :keyword metric_namespace: the namespace of the metric. :paramtype metric_namespace: str """ - super(RuleDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] self.resource_uri = resource_uri self.legacy_resource_id = legacy_resource_id @@ -1134,8 +1087,8 @@ class RuleEmailAction(RuleAction): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction.Constant filled by server. + :ivar odata_type: specifies the type of the action. There are two types of actions: + RuleEmailAction and RuleWebhookAction. Required. :vartype odata_type: str :ivar send_to_service_owners: Whether the administrators (service and co-administrators) of the service should be notified when the alert is activated. @@ -1146,21 +1099,17 @@ class RuleEmailAction(RuleAction): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'send_to_service_owners': {'key': 'sendToServiceOwners', 'type': 'bool'}, - 'custom_emails': {'key': 'customEmails', 'type': '[str]'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "send_to_service_owners": {"key": "sendToServiceOwners", "type": "bool"}, + "custom_emails": {"key": "customEmails", "type": "[str]"}, } def __init__( - self, - *, - send_to_service_owners: Optional[bool] = None, - custom_emails: Optional[List[str]] = None, - **kwargs + self, *, send_to_service_owners: Optional[bool] = None, custom_emails: Optional[List[str]] = None, **kwargs ): """ :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of @@ -1170,13 +1119,13 @@ def __init__( activation of the alert. :paramtype custom_emails: list[str] """ - super(RuleEmailAction, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleEmailAction' # type: str + super().__init__(**kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" # type: str self.send_to_service_owners = send_to_service_owners self.custom_emails = custom_emails -class RuleManagementEventClaimsDataSource(msrest.serialization.Model): +class RuleManagementEventClaimsDataSource(_serialization.Model): """The claims for a rule management event data source. :ivar email_address: the email address. @@ -1184,30 +1133,25 @@ class RuleManagementEventClaimsDataSource(msrest.serialization.Model): """ _attribute_map = { - 'email_address': {'key': 'emailAddress', 'type': 'str'}, + "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__( - self, - *, - email_address: Optional[str] = None, - **kwargs - ): + def __init__(self, *, email_address: Optional[str] = None, **kwargs): """ :keyword email_address: the email address. :paramtype email_address: str """ - super(RuleManagementEventClaimsDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.email_address = email_address -class RuleManagementEventDataSource(RuleDataSource): +class RuleManagementEventDataSource(RuleDataSource): # pylint: disable=too-many-instance-attributes """A rule management event data source. The discriminator fields is always RuleManagementEventDataSource in this case. All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of data source. There are two types of rule data - sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :ivar odata_type: specifies the type of data source. There are two types of rule data sources: + RuleMetricDataSource and RuleManagementEventDataSource. Required. :vartype odata_type: str :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1243,24 +1187,24 @@ class RuleManagementEventDataSource(RuleDataSource): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'event_name': {'key': 'eventName', 'type': 'str'}, - 'event_source': {'key': 'eventSource', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'operation_name': {'key': 'operationName', 'type': 'str'}, - 'resource_group_name': {'key': 'resourceGroupName', 'type': 'str'}, - 'resource_provider_name': {'key': 'resourceProviderName', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'sub_status': {'key': 'subStatus', 'type': 'str'}, - 'claims': {'key': 'claims', 'type': 'RuleManagementEventClaimsDataSource'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "resource_uri": {"key": "resourceUri", "type": "str"}, + "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, + "resource_location": {"key": "resourceLocation", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "event_name": {"key": "eventName", "type": "str"}, + "event_source": {"key": "eventSource", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "operation_name": {"key": "operationName", "type": "str"}, + "resource_group_name": {"key": "resourceGroupName", "type": "str"}, + "resource_provider_name": {"key": "resourceProviderName", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "sub_status": {"key": "subStatus", "type": "str"}, + "claims": {"key": "claims", "type": "RuleManagementEventClaimsDataSource"}, } def __init__( @@ -1314,8 +1258,14 @@ def __init__( :paramtype claims: ~$(python-base-namespace).v2016_03_01.models.RuleManagementEventClaimsDataSource """ - super(RuleManagementEventDataSource, self).__init__(resource_uri=resource_uri, legacy_resource_id=legacy_resource_id, resource_location=resource_location, metric_namespace=metric_namespace, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource' # type: str + super().__init__( + resource_uri=resource_uri, + legacy_resource_id=legacy_resource_id, + resource_location=resource_location, + metric_namespace=metric_namespace, + **kwargs + ) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" # type: str self.event_name = event_name self.event_source = event_source self.level = level @@ -1332,8 +1282,8 @@ class RuleMetricDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of data source. There are two types of rule data - sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :ivar odata_type: specifies the type of data source. There are two types of rule data sources: + RuleMetricDataSource and RuleManagementEventDataSource. Required. :vartype odata_type: str :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1350,16 +1300,16 @@ class RuleMetricDataSource(RuleDataSource): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "resource_uri": {"key": "resourceUri", "type": "str"}, + "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, + "resource_location": {"key": "resourceLocation", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "metric_name": {"key": "metricName", "type": "str"}, } def __init__( @@ -1386,8 +1336,14 @@ def __init__( :keyword metric_name: the name of the metric that defines what the rule monitors. :paramtype metric_name: str """ - super(RuleMetricDataSource, self).__init__(resource_uri=resource_uri, legacy_resource_id=legacy_resource_id, resource_location=resource_location, metric_namespace=metric_namespace, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource' # type: str + super().__init__( + resource_uri=resource_uri, + legacy_resource_id=legacy_resource_id, + resource_location=resource_location, + metric_namespace=metric_namespace, + **kwargs + ) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" # type: str self.metric_name = metric_name @@ -1396,8 +1352,8 @@ class RuleWebhookAction(RuleAction): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction.Constant filled by server. + :ivar odata_type: specifies the type of the action. There are two types of actions: + RuleEmailAction and RuleWebhookAction. Required. :vartype odata_type: str :ivar service_uri: the service uri to Post the notification when the alert activates or resolves. @@ -1408,22 +1364,16 @@ class RuleWebhookAction(RuleAction): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: Optional[str] = None, - properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs): """ :keyword service_uri: the service uri to Post the notification when the alert activates or resolves. @@ -1432,8 +1382,8 @@ def __init__( These data are appended to the webhook payload. :paramtype properties: dict[str, str] """ - super(RuleWebhookAction, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' # type: str + super().__init__(**kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" # type: str self.service_uri = service_uri self.properties = properties @@ -1443,18 +1393,18 @@ class ThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric).Constant filled by server. + threshold of a metric). Required. :vartype odata_type: str :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :vartype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource - :ivar operator: Required. the operator used to compare the data and the threshold. Known values - are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :ivar operator: the operator used to compare the data and the threshold. Required. Known values + are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator - :ivar threshold: Required. the threshold value that activates the alert. + :ivar threshold: the threshold value that activates the alert. Required. :vartype threshold: float :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 @@ -1462,24 +1412,24 @@ class ThresholdRuleCondition(RuleCondition): :vartype window_size: ~datetime.timedelta :ivar time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. Known - values are: "Average", "Minimum", "Maximum", "Total", "Last". + values are: "Average", "Minimum", "Maximum", "Total", and "Last". :vartype time_aggregation: str or ~$(python-base-namespace).v2016_03_01.models.TimeAggregationOperator """ _validation = { - 'odata_type': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, + "odata_type": {"required": True}, + "operator": {"required": True}, + "threshold": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "data_source": {"key": "dataSource", "type": "RuleDataSource"}, + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "window_size": {"key": "windowSize", "type": "duration"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, } def __init__( @@ -1496,10 +1446,10 @@ def __init__( :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :paramtype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource - :keyword operator: Required. the operator used to compare the data and the threshold. Known - values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :keyword operator: the operator used to compare the data and the threshold. Required. Known + values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator - :keyword threshold: Required. the threshold value that activates the alert. + :keyword threshold: the threshold value that activates the alert. Required. :paramtype threshold: float :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 @@ -1507,12 +1457,12 @@ def __init__( :paramtype window_size: ~datetime.timedelta :keyword time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. - Known values are: "Average", "Minimum", "Maximum", "Total", "Last". + Known values are: "Average", "Minimum", "Maximum", "Total", and "Last". :paramtype time_aggregation: str or ~$(python-base-namespace).v2016_03_01.models.TimeAggregationOperator """ - super(ThresholdRuleCondition, self).__init__(data_source=data_source, **kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition' # type: str + super().__init__(data_source=data_source, **kwargs) + self.odata_type = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" # type: str self.operator = operator self.threshold = threshold self.window_size = window_size diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py index 41465c545753..39c249cb1d29 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py @@ -11,8 +11,7 @@ class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the primary aggregation type value defining how to use the values for display. - """ + """the primary aggregation type value defining how to use the values for display.""" NONE = "None" AVERAGE = "Average" @@ -21,18 +20,18 @@ class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): MAXIMUM = "Maximum" TOTAL = "Total" + class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operators allowed in the rule condition. - """ + """Operators allowed in the rule condition.""" GREATER_THAN = "GreaterThan" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + class TimeAggregationOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Aggregation operators allowed in a rule. - """ + """Aggregation operators allowed in a rule.""" AVERAGE = "Average" MINIMUM = "Minimum" @@ -40,9 +39,9 @@ class TimeAggregationOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): TOTAL = "Total" LAST = "Last" + class Unit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of the metric. - """ + """The unit of the metric.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/__init__.py index 1bd2ec16581f..ba29eb66c1f6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/__init__.py @@ -14,11 +14,12 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AlertRuleIncidentsOperations', - 'AlertRulesOperations', - 'LogProfilesOperations', - 'MetricDefinitionsOperations', + "AlertRuleIncidentsOperations", + "AlertRulesOperations", + "LogProfilesOperations", + "MetricDefinitionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py index 6c5a77ea1afe..2be1dbf9ad3e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,87 +25,82 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - resource_group_name: str, - rule_name: str, - incident_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, rule_name: str, incident_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "incidentName": _SERIALIZER.url("incident_name", incident_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "incidentName": _SERIALIZER.url("incident_name", incident_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_alert_rule_request( - resource_group_name: str, - rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class AlertRuleIncidentsOperations: """ @@ -121,47 +121,38 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get( - self, - resource_group_name: str, - rule_name: str, - incident_name: str, - **kwargs: Any - ) -> _models.Incident: + def get(self, resource_group_name: str, rule_name: str, incident_name: str, **kwargs: Any) -> _models.Incident: """Gets an incident associated to an alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param incident_name: The name of the incident to retrieve. + :param incident_name: The name of the incident to retrieve. Required. :type incident_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Incident, or the result of cls(response) + :return: Incident or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.Incident - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Incident] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Incident] - request = build_get_request( resource_group_name=resource_group_name, rule_name=rule_name, incident_name=incident_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -169,10 +160,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -180,54 +170,49 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Incident', pipeline_response) + deserialized = self._deserialize("Incident", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}"} # type: ignore @distributed_trace def list_by_alert_rule( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> Iterable[_models.IncidentListResult]: + self, resource_group_name: str, rule_name: str, **kwargs: Any + ) -> Iterable["_models.Incident"]: """Gets a list of incidents associated to an alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IncidentListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.IncidentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Incident or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.Incident] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.IncidentListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IncidentListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_alert_rule_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_alert_rule.metadata['url'], + template_url=self.list_by_alert_rule.metadata["url"], headers=_headers, params=_params, ) @@ -235,16 +220,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_alert_rule_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -260,10 +240,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -273,8 +251,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_alert_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents"} # type: ignore + list_by_alert_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py index 2dcb602b96d9..3589207be3dc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +25,201 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - resource_group_name: str, - rule_name: str, - subscription_id: str, - *, - json: Optional[_models.AlertRuleResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_group_name: str, - rule_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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_get_request( - resource_group_name: str, - rule_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - subscription_id: str, - resource_group_name: str, - rule_name: str, - *, - json: Optional[_models.AlertRuleResourcePatch] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["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_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class AlertRulesOperations: """ @@ -277,41 +240,101 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, rule_name: str, parameters: _models.AlertRuleResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AlertRuleResource: """Creates or updates a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. + :param parameters: The parameters of the rule to create or update. Required. :type parameters: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Creates or updates a classic metric alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_group_name: str, rule_name: str, parameters: Union[_models.AlertRuleResource, IO], **kwargs: Any + ) -> _models.AlertRuleResource: + """Creates or updates a classic metric alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a model type or a + IO type. Required. + :type parameters: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - _json = self._serialize.body(parameters, 'AlertRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AlertRuleResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -320,7 +343,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -328,10 +352,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -340,55 +363,49 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, **kwargs: Any ) -> None: """Deletes a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -396,10 +413,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -410,45 +426,37 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.AlertRuleResource: + def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: """Gets a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - request = build_get_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -456,10 +464,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -467,60 +474,128 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + alert_rules_resource: _models.AlertRuleResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Updates an existing classic metric AlertRuleResource. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param alert_rules_resource: Parameters supplied to the operation. Required. + :type alert_rules_resource: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + alert_rules_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AlertRuleResource: + """Updates an existing classic metric AlertRuleResource. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param alert_rules_resource: Parameters supplied to the operation. Required. + :type alert_rules_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AlertRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, rule_name: str, - alert_rules_resource: _models.AlertRuleResourcePatch, + alert_rules_resource: Union[_models.AlertRuleResourcePatch, IO], **kwargs: Any ) -> _models.AlertRuleResource: """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. + :param alert_rules_resource: Parameters supplied to the operation. Is either a model type or a + IO type. Required. :type alert_rules_resource: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResourcePatch + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AlertRuleResource, or the result of cls(response) + :return: AlertRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] - _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(alert_rules_resource, (IO, bytes)): + _content = alert_rules_resource + else: + _json = self._serialize.body(alert_rules_resource, "AlertRuleResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -528,10 +603,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -540,54 +614,48 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRuleResource', pipeline_response) + deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.AlertRuleResourceCollection]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: """List the classic metric alert rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 AlertRuleResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AlertRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -595,15 +663,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -619,10 +683,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -633,43 +695,36 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.AlertRuleResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: """List the classic metric alert rules within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of - cls(response) + :return: An iterator like instance of either AlertRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -677,14 +732,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -700,10 +752,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -714,8 +764,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py index 69225e50d950..7eb60e347512 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,193 +25,147 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_delete_request( - log_profile_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_delete_request(log_profile_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_get_request( - log_profile_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_get_request(log_profile_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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( - log_profile_name: str, - subscription_id: str, - *, - json: Optional[_models.LogProfileResource] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(log_profile_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_update_request( - subscription_id: str, - log_profile_name: str, - *, - json: Optional[_models.LogProfileResourcePatch] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _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_update_request(log_profile_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_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 = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class LogProfilesOperations: """ @@ -227,39 +186,31 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - log_profile_name: str, - **kwargs: Any - ) -> None: + def delete(self, log_profile_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes the log profile. - :param log_profile_name: The name of the log profile. + :param log_profile_name: The name of the log profile. Required. :type log_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( log_profile_name=log_profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -267,10 +218,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,41 +230,33 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore @distributed_trace - def get( - self, - log_profile_name: str, - **kwargs: Any - ) -> _models.LogProfileResource: + def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileResource: """Gets the log profile. - :param log_profile_name: The name of the log profile. + :param log_profile_name: The name of the log profile. Required. :type log_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource, or the result of cls(response) + :return: LogProfileResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileResource] - request = build_get_request( log_profile_name=log_profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -322,10 +264,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -333,47 +274,94 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LogProfileResource', pipeline_response) + deserialized = self._deserialize("LogProfileResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, log_profile_name: str, parameters: _models.LogProfileResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LogProfileResource: """Create or update a log profile in Azure Monitoring REST API. - :param log_profile_name: The name of the log profile. + :param log_profile_name: The name of the log profile. Required. :type log_profile_name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: LogProfileResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, log_profile_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.LogProfileResource: + """Create or update a log profile in Azure Monitoring REST API. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param parameters: Parameters supplied to the operation. 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: LogProfileResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, log_profile_name: str, parameters: Union[_models.LogProfileResource, IO], **kwargs: Any + ) -> _models.LogProfileResource: + """Create or update a log profile in Azure Monitoring REST API. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: LogProfileResource, or the result of cls(response) + :return: LogProfileResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileResource] - _json = self._serialize.body(parameters, 'LogProfileResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LogProfileResource") request = build_create_or_update_request( log_profile_name=log_profile_name, @@ -381,7 +369,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -389,66 +378,114 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LogProfileResource', pipeline_response) + deserialized = self._deserialize("LogProfileResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore - @distributed_trace + @overload def update( self, log_profile_name: str, log_profiles_resource: _models.LogProfileResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LogProfileResource: """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. - :param log_profile_name: The name of the log profile. + :param log_profile_name: The name of the log profile. Required. :type log_profile_name: str - :param log_profiles_resource: Parameters supplied to the operation. + :param log_profiles_resource: Parameters supplied to the operation. Required. :type log_profiles_resource: ~$(python-base-namespace).v2016_03_01.models.LogProfileResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: LogProfileResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, log_profile_name: str, log_profiles_resource: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.LogProfileResource: + """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param log_profiles_resource: Parameters supplied to the operation. Required. + :type log_profiles_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: LogProfileResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, log_profile_name: str, log_profiles_resource: Union[_models.LogProfileResourcePatch, IO], **kwargs: Any + ) -> _models.LogProfileResource: + """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param log_profiles_resource: Parameters supplied to the operation. Is either a model type or a + IO type. Required. + :type log_profiles_resource: + ~$(python-base-namespace).v2016_03_01.models.LogProfileResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: LogProfileResource, or the result of cls(response) + :return: LogProfileResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileResource] - _json = self._serialize.body(log_profiles_resource, 'LogProfileResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(log_profiles_resource, (IO, bytes)): + _content = log_profiles_resource + else: + _json = self._serialize.body(log_profiles_resource, "LogProfileResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -456,10 +493,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -467,47 +503,41 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LogProfileResource', pipeline_response) + deserialized = self._deserialize("LogProfileResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.LogProfileCollection]: + def list(self, **kwargs: Any) -> Iterable["_models.LogProfileResource"]: """List the log profiles. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogProfileCollection or the result of - cls(response) + :return: An iterator like instance of either LogProfileResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.LogProfileCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.LogProfileResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -515,14 +545,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -538,10 +565,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -551,8 +576,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py index f37a7dec329b..9526a3f7ad19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,48 +25,41 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_uri: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_uri: 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 = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metricDefinitions") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MetricDefinitionsOperations: """ @@ -82,17 +80,13 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - resource_uri: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable[_models.MetricDefinitionCollection]: + self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.MetricDefinition"]: """Lists the metric definitions for the resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param filter: Reduces the set of data collected by retrieving particular metric definitions from all the definitions available for the resource.:code:`
`For example, to get just the @@ -102,30 +96,28 @@ def list( other syntax is allowed. 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 MetricDefinitionCollection or the result of - cls(response) + :return: An iterator like instance of either MetricDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.MetricDefinitionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -133,15 +125,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -157,10 +145,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -171,8 +157,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py index 3924ba7ecc21..e8402d49e16b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py @@ -25,43 +25,40 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", "2016-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json index 8445b275583e..dd87cd1bcd39 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json @@ -10,14 +10,14 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 } @@ -25,7 +25,7 @@ "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 } @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py index aafd3ed5e1ff..5923e0722f61 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import MetricsOperations, ServiceDiagnosticSettingsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar metrics: MetricsOperations operations @@ -30,7 +30,7 @@ class MonitorManagementClient: :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations :vartype service_diagnostic_settings: $(python-base-namespace).v2016_09_01.operations.ServiceDiagnosticSettingsOperations - :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 base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -40,10 +40,7 @@ class MonitorManagementClient: """ def __init__( - self, - credential: "TokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -52,19 +49,12 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.metrics = MetricsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -73,7 +63,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py index 459d9633f5bd..3cda5da22161 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py @@ -25,42 +25,37 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-09-01") # type: str + api_version = kwargs.pop("api_version", "2016-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py index 13e3b6c545e9..2dd6e4fc91b4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import MetricsOperations, ServiceDiagnosticSettingsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar metrics: MetricsOperations operations @@ -30,7 +30,7 @@ class MonitorManagementClient: :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations :vartype service_diagnostic_settings: $(python-base-namespace).v2016_09_01.aio.operations.ServiceDiagnosticSettingsOperations - :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 base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -40,10 +40,7 @@ class MonitorManagementClient: """ def __init__( - self, - credential: "AsyncTokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -52,19 +49,12 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.metrics = MetricsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -73,7 +63,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/__init__.py index ac60aa87cb1b..a619a5adabf7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'MetricsOperations', - 'ServiceDiagnosticSettingsOperations', + "MetricsOperations", + "ServiceDiagnosticSettingsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py index af8931bc612c..8db80e2f0142 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._metrics_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MetricsOperations: """ .. warning:: @@ -42,17 +51,11 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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, - resource_uri: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[_models.MetricCollection]: + def list(self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.Metric"]: """Lists the metric values for a resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param filter: Reduces the set of data collected.:code:`
`The filter is optional. If present it must contain a list of metric names to retrieve of the form: *(name.value eq 'metricName' @@ -74,29 +77,28 @@ def list( metrics. 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 MetricCollection or the result of cls(response) + :return: An iterator like instance of either Metric or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_09_01.models.MetricCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_09_01.models.Metric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -104,15 +106,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -128,10 +126,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -142,8 +138,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py index a816976e3cfd..c0e705776bef 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py @@ -6,9 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +24,16 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._service_diagnostic_settings_operations import build_create_or_update_request, build_get_request, build_update_request -T = TypeVar('T') +from ...operations._service_diagnostic_settings_operations import ( + build_create_or_update_request, + build_get_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ServiceDiagnosticSettingsOperations: """ .. warning:: @@ -41,39 +53,31 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get( - self, - resource_uri: str, - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: + async def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. **WARNING**\ : This method will be deprecated in future releases. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource, or the result of cls(response) + :return: ServiceDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] - request = build_get_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -81,10 +85,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,56 +95,107 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_uri: str, parameters: _models.ServiceDiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ServiceDiagnosticSettingsResource: """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method will be deprecated in future releases. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_uri: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method + will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. 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: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_uri: str, parameters: Union[_models.ServiceDiagnosticSettingsResource, IO], **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method + will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ServiceDiagnosticSettingsResource, or the result of cls(response) + :return: ServiceDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceDiagnosticSettingsResource") request = build_create_or_update_request( resource_uri=resource_uri, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -149,66 +203,124 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore - + create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_uri: str, service_diagnostic_settings_resource: _models.ServiceDiagnosticSettingsResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ServiceDiagnosticSettingsResource: """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param service_diagnostic_settings_resource: Parameters supplied to the operation. + :param service_diagnostic_settings_resource: Parameters supplied to the operation. Required. :type service_diagnostic_settings_resource: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ServiceDiagnosticSettingsResource, or the result of cls(response) + :return: ServiceDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def update( + self, + resource_uri: str, + service_diagnostic_settings_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the + CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param service_diagnostic_settings_resource: Parameters supplied to the operation. Required. + :type service_diagnostic_settings_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_uri: str, + service_diagnostic_settings_resource: Union[_models.ServiceDiagnosticSettingsResourcePatch, IO], + **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the + CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param service_diagnostic_settings_resource: Parameters supplied to the operation. Is either a + model type or a IO type. Required. + :type service_diagnostic_settings_resource: + ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] - _json = self._serialize.body(service_diagnostic_settings_resource, 'ServiceDiagnosticSettingsResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(service_diagnostic_settings_resource, (IO, bytes)): + _content = service_diagnostic_settings_resource + else: + _json = self._serialize.body(service_diagnostic_settings_resource, "ServiceDiagnosticSettingsResourcePatch") request = build_update_request( resource_uri=resource_uri, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -216,10 +328,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -227,12 +338,11 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore - + update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py index c4b18e16f22a..06c53293c351 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py @@ -18,26 +18,24 @@ from ._models_py3 import ServiceDiagnosticSettingsResource from ._models_py3 import ServiceDiagnosticSettingsResourcePatch - -from ._monitor_management_client_enums import ( - Unit, -) +from ._monitor_management_client_enums import Unit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ErrorResponse', - 'LocalizableString', - 'LogSettings', - 'Metric', - 'MetricCollection', - 'MetricSettings', - 'MetricValue', - 'Resource', - 'RetentionPolicy', - 'ServiceDiagnosticSettingsResource', - 'ServiceDiagnosticSettingsResourcePatch', - 'Unit', + "ErrorResponse", + "LocalizableString", + "LogSettings", + "Metric", + "MetricCollection", + "MetricSettings", + "MetricValue", + "Resource", + "RetentionPolicy", + "ServiceDiagnosticSettingsResource", + "ServiceDiagnosticSettingsResourcePatch", + "Unit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py index 0a7ab91110d8..0ac41d3a67c1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_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. @@ -9,15 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -27,67 +27,55 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class LocalizableString(msrest.serialization.Model): +class LocalizableString(_serialization.Model): """The localizable string class. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the invariant value. + :ivar value: the invariant value. Required. :vartype value: str :ivar localized_value: the locale specific value. :vartype localized_value: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: str, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs): """ - :keyword value: Required. the invariant value. + :keyword value: the invariant value. Required. :paramtype value: str :keyword localized_value: the locale specific value. :paramtype localized_value: str """ - super(LocalizableString, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class LogSettings(msrest.serialization.Model): +class LogSettings(_serialization.Model): """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. All required parameters must be populated in order to send to Azure. @@ -96,20 +84,20 @@ class LogSettings(msrest.serialization.Model): to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. :vartype category: str - :ivar enabled: Required. a value indicating whether this log is enabled. + :ivar enabled: a value indicating whether this log is enabled. Required. :vartype enabled: bool :ivar retention_policy: the retention policy for this log. :vartype retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy """ _validation = { - 'enabled': {'required': True}, + "enabled": {"required": True}, } _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, + "category": {"key": "category", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, } def __init__( @@ -125,18 +113,18 @@ def __init__( applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. :paramtype category: str - :keyword enabled: Required. a value indicating whether this log is enabled. + :keyword enabled: a value indicating whether this log is enabled. Required. :paramtype enabled: bool :keyword retention_policy: the retention policy for this log. :paramtype retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy """ - super(LogSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.category = category self.enabled = enabled self.retention_policy = retention_policy -class Metric(msrest.serialization.Model): +class Metric(_serialization.Model): """A set of metric values in a time range. All required parameters must be populated in order to send to Azure. @@ -145,29 +133,29 @@ class Metric(msrest.serialization.Model): :vartype id: str :ivar type: the resource type of the metric resource. :vartype type: str - :ivar name: Required. the name and the display name of the metric, i.e. it is localizable - string. + :ivar name: the name and the display name of the metric, i.e. it is localizable string. + Required. :vartype name: ~$(python-base-namespace).v2016_09_01.models.LocalizableString - :ivar unit: Required. the unit of the metric. Known values are: "Count", "Bytes", "Seconds", + :ivar unit: the unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". :vartype unit: str or ~$(python-base-namespace).v2016_09_01.models.Unit - :ivar data: Required. Array of data points representing the metric values. + :ivar data: Array of data points representing the metric values. Required. :vartype data: list[~$(python-base-namespace).v2016_09_01.models.MetricValue] """ _validation = { - 'name': {'required': True}, - 'unit': {'required': True}, - 'data': {'required': True}, + "name": {"required": True}, + "unit": {"required": True}, + "data": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'data': {'key': 'data', 'type': '[MetricValue]'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "LocalizableString"}, + "unit": {"key": "unit", "type": "str"}, + "data": {"key": "data", "type": "[MetricValue]"}, } def __init__( @@ -176,7 +164,7 @@ def __init__( name: "_models.LocalizableString", unit: Union[str, "_models.Unit"], data: List["_models.MetricValue"], - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, **kwargs ): @@ -185,17 +173,17 @@ def __init__( :paramtype id: str :keyword type: the resource type of the metric resource. :paramtype type: str - :keyword name: Required. the name and the display name of the metric, i.e. it is localizable - string. + :keyword name: the name and the display name of the metric, i.e. it is localizable string. + Required. :paramtype name: ~$(python-base-namespace).v2016_09_01.models.LocalizableString - :keyword unit: Required. the unit of the metric. Known values are: "Count", "Bytes", "Seconds", + :keyword unit: the unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". :paramtype unit: str or ~$(python-base-namespace).v2016_09_01.models.Unit - :keyword data: Required. Array of data points representing the metric values. + :keyword data: Array of data points representing the metric values. Required. :paramtype data: list[~$(python-base-namespace).v2016_09_01.models.MetricValue] """ - super(Metric, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.name = name @@ -203,59 +191,54 @@ def __init__( self.data = data -class MetricCollection(msrest.serialization.Model): +class MetricCollection(_serialization.Model): """The collection of metric value sets. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the value of the collection. + :ivar value: the value of the collection. Required. :vartype value: list[~$(python-base-namespace).v2016_09_01.models.Metric] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Metric]'}, + "value": {"key": "value", "type": "[Metric]"}, } - def __init__( - self, - *, - value: List["_models.Metric"], - **kwargs - ): + def __init__(self, *, value: List["_models.Metric"], **kwargs): """ - :keyword value: Required. the value of the collection. + :keyword value: the value of the collection. Required. :paramtype value: list[~$(python-base-namespace).v2016_09_01.models.Metric] """ - super(MetricCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class MetricSettings(msrest.serialization.Model): +class MetricSettings(_serialization.Model): """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. All required parameters must be populated in order to send to Azure. - :ivar time_grain: Required. the timegrain of the metric in ISO8601 format. + :ivar time_grain: the timegrain of the metric in ISO8601 format. Required. :vartype time_grain: ~datetime.timedelta - :ivar enabled: Required. a value indicating whether this timegrain is enabled. + :ivar enabled: a value indicating whether this timegrain is enabled. Required. :vartype enabled: bool :ivar retention_policy: the retention policy for this timegrain. :vartype retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy """ _validation = { - 'time_grain': {'required': True}, - 'enabled': {'required': True}, + "time_grain": {"required": True}, + "enabled": {"required": True}, } _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, + "time_grain": {"key": "timeGrain", "type": "duration"}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, } def __init__( @@ -267,25 +250,25 @@ def __init__( **kwargs ): """ - :keyword time_grain: Required. the timegrain of the metric in ISO8601 format. + :keyword time_grain: the timegrain of the metric in ISO8601 format. Required. :paramtype time_grain: ~datetime.timedelta - :keyword enabled: Required. a value indicating whether this timegrain is enabled. + :keyword enabled: a value indicating whether this timegrain is enabled. Required. :paramtype enabled: bool :keyword retention_policy: the retention policy for this timegrain. :paramtype retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy """ - super(MetricSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_grain = time_grain self.enabled = enabled self.retention_policy = retention_policy -class MetricValue(msrest.serialization.Model): +class MetricValue(_serialization.Model): """Represents a metric value. All required parameters must be populated in order to send to Azure. - :ivar time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :ivar time_stamp: the timestamp for the metric value in ISO 8601 format. Required. :vartype time_stamp: ~datetime.datetime :ivar average: the average value in the time range. :vartype average: float @@ -297,20 +280,20 @@ class MetricValue(msrest.serialization.Model): :vartype total: float :ivar count: the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. - :vartype count: long + :vartype count: int """ _validation = { - 'time_stamp': {'required': True}, + "time_stamp": {"required": True}, } _attribute_map = { - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'average': {'key': 'average', 'type': 'float'}, - 'minimum': {'key': 'minimum', 'type': 'float'}, - 'maximum': {'key': 'maximum', 'type': 'float'}, - 'total': {'key': 'total', 'type': 'float'}, - 'count': {'key': 'count', 'type': 'long'}, + "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, + "average": {"key": "average", "type": "float"}, + "minimum": {"key": "minimum", "type": "float"}, + "maximum": {"key": "maximum", "type": "float"}, + "total": {"key": "total", "type": "float"}, + "count": {"key": "count", "type": "int"}, } def __init__( @@ -325,7 +308,7 @@ def __init__( **kwargs ): """ - :keyword time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. :paramtype time_stamp: ~datetime.datetime :keyword average: the average value in the time range. :paramtype average: float @@ -337,9 +320,9 @@ def __init__( :paramtype total: float :keyword count: the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. - :paramtype count: long + :paramtype count: int """ - super(MetricValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_stamp = time_stamp self.average = average self.minimum = minimum @@ -348,7 +331,7 @@ def __init__( self.count = count -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -361,41 +344,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -403,48 +380,42 @@ def __init__( self.tags = tags -class RetentionPolicy(msrest.serialization.Model): +class RetentionPolicy(_serialization.Model): """Specifies the retention policy for the log. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :ivar enabled: a value indicating whether the retention policy is enabled. Required. :vartype enabled: bool - :ivar days: Required. the number of days for the retention in days. A value of 0 will retain - the events indefinitely. + :ivar days: the number of days for the retention in days. A value of 0 will retain the events + indefinitely. Required. :vartype days: int """ _validation = { - 'enabled': {'required': True}, - 'days': {'required': True, 'minimum': 0}, + "enabled": {"required": True}, + "days": {"required": True, "minimum": 0}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: bool, - days: int, - **kwargs - ): + def __init__(self, *, enabled: bool, days: int, **kwargs): """ - :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :keyword enabled: a value indicating whether the retention policy is enabled. Required. :paramtype enabled: bool - :keyword days: Required. the number of days for the retention in days. A value of 0 will retain - the events indefinitely. + :keyword days: the number of days for the retention in days. A value of 0 will retain the + events indefinitely. Required. :paramtype days: int """ - super(RetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class ServiceDiagnosticSettingsResource(Resource): +class ServiceDiagnosticSettingsResource(Resource): # pylint: disable=too-many-instance-attributes """Description of a service diagnostic setting. Variables are only populated by the server, and will be ignored when sending a request. @@ -457,9 +428,9 @@ class ServiceDiagnosticSettingsResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. @@ -482,24 +453,24 @@ class ServiceDiagnosticSettingsResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'metrics': {'key': 'properties.metrics', 'type': '[MetricSettings]'}, - 'logs': {'key': 'properties.logs', 'type': '[LogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, + "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}"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, + "metrics": {"key": "properties.metrics", "type": "[MetricSettings]"}, + "logs": {"key": "properties.logs", "type": "[LogSettings]"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, } def __init__( @@ -516,9 +487,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. @@ -539,7 +510,7 @@ def __init__( /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. :paramtype workspace_id: str """ - super(ServiceDiagnosticSettingsResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id self.event_hub_authorization_rule_id = event_hub_authorization_rule_id @@ -548,10 +519,10 @@ def __init__( self.workspace_id = workspace_id -class ServiceDiagnosticSettingsResourcePatch(msrest.serialization.Model): +class ServiceDiagnosticSettingsResourcePatch(_serialization.Model): """Service diagnostic setting resource for patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. @@ -574,13 +545,13 @@ class ServiceDiagnosticSettingsResourcePatch(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'metrics': {'key': 'properties.metrics', 'type': '[MetricSettings]'}, - 'logs': {'key': 'properties.logs', 'type': '[LogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, + "metrics": {"key": "properties.metrics", "type": "[MetricSettings]"}, + "logs": {"key": "properties.logs", "type": "[LogSettings]"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, } def __init__( @@ -596,7 +567,7 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. @@ -617,7 +588,7 @@ def __init__( /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. :paramtype workspace_id: str """ - super(ServiceDiagnosticSettingsResourcePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py index 25cb50eb3163..e8d8442d73e0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py @@ -11,8 +11,7 @@ class Unit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of the metric. - """ + """The unit of the metric.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/__init__.py index ac60aa87cb1b..a619a5adabf7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'MetricsOperations', - 'ServiceDiagnosticSettingsOperations', + "MetricsOperations", + "ServiceDiagnosticSettingsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py index 5bbfe40cfb90..6c169d0816f4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,48 +25,41 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_uri: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_uri: 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 = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metrics") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MetricsOperations: """ @@ -82,17 +80,11 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - resource_uri: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable[_models.MetricCollection]: + def list(self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.Metric"]: """Lists the metric values for a resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param filter: Reduces the set of data collected.:code:`
`The filter is optional. If present it must contain a list of metric names to retrieve of the form: *(name.value eq 'metricName' @@ -114,29 +106,27 @@ def list( metrics. 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 MetricCollection or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_09_01.models.MetricCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_09_01.models.Metric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -144,15 +134,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -168,10 +154,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -182,8 +166,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py index a414a4865041..b7bf60708e5d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,126 +23,93 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - resource_uri: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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( - resource_uri: str, - *, - json: Optional[_models.ServiceDiagnosticSettingsResource] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_update_request( - resource_uri: str, - *, - json: Optional[_models.ServiceDiagnosticSettingsResourcePatch] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _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_update_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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) + class ServiceDiagnosticSettingsOperations: """ @@ -159,39 +130,31 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get( - self, - resource_uri: str, - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: + def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. **WARNING**\ : This method will be deprecated in future releases. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource, or the result of cls(response) + :return: ServiceDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] - request = build_get_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -199,10 +162,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -210,56 +172,107 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore - + get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_uri: str, parameters: _models.ServiceDiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ServiceDiagnosticSettingsResource: """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method will be deprecated in future releases. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ServiceDiagnosticSettingsResource, or the result of cls(response) + :return: ServiceDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, resource_uri: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method + will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. 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: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_uri: str, parameters: Union[_models.ServiceDiagnosticSettingsResource, IO], **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method + will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceDiagnosticSettingsResource") request = build_create_or_update_request( resource_uri=resource_uri, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -267,66 +280,124 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore - - @distributed_trace + @overload def update( self, resource_uri: str, service_diagnostic_settings_resource: _models.ServiceDiagnosticSettingsResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ServiceDiagnosticSettingsResource: """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param service_diagnostic_settings_resource: Parameters supplied to the operation. + :param service_diagnostic_settings_resource: Parameters supplied to the operation. Required. :type service_diagnostic_settings_resource: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ServiceDiagnosticSettingsResource, or the result of cls(response) + :return: ServiceDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_uri: str, + service_diagnostic_settings_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the + CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param service_diagnostic_settings_resource: Parameters supplied to the operation. Required. + :type service_diagnostic_settings_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_uri: str, + service_diagnostic_settings_resource: Union[_models.ServiceDiagnosticSettingsResourcePatch, IO], + **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the + CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param service_diagnostic_settings_resource: Parameters supplied to the operation. Is either a + model type or a IO type. Required. + :type service_diagnostic_settings_resource: + ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] - _json = self._serialize.body(service_diagnostic_settings_resource, 'ServiceDiagnosticSettingsResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(service_diagnostic_settings_resource, (IO, bytes)): + _content = service_diagnostic_settings_resource + else: + _json = self._serialize.body(service_diagnostic_settings_resource, "ServiceDiagnosticSettingsResourcePatch") request = build_update_request( resource_uri=resource_uri, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -334,10 +405,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -345,12 +415,11 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore - + update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py index f80855d96408..c54e5adef4db 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-03-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-03-01-preview") # type: str + api_version = kwargs.pop("api_version", "2017-03-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json index 0c766a2666c3..c74234f8fa0c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py index 00f2d4308077..34d0b77392aa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActivityLogAlertsOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar activity_log_alerts: ActivityLogAlertsOperations operations :vartype activity_log_alerts: $(python-base-namespace).v2017_03_01_preview.operations.ActivityLogAlertsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -46,7 +46,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -57,12 +59,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -71,7 +68,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py index 93dde4d32098..a539a0d703fa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-03-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-03-01-preview") # type: str + api_version = kwargs.pop("api_version", "2017-03-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py index f8e709eefadc..203cca5d1590 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActivityLogAlertsOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar activity_log_alerts: ActivityLogAlertsOperations operations :vartype activity_log_alerts: $(python-base-namespace).v2017_03_01_preview.aio.operations.ActivityLogAlertsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -46,7 +46,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -57,12 +59,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -71,7 +68,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/__init__.py index 26aff77830bf..605798ce7feb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActivityLogAlertsOperations', + "ActivityLogAlertsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py index 56c7341496ef..d2bbf32ace55 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._activity_log_alerts_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_request -T = TypeVar('T') +from ...operations._activity_log_alerts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ActivityLogAlertsOperations: """ .. warning:: @@ -43,51 +59,117 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, activity_log_alert_name: str, activity_log_alert: _models.ActivityLogAlertResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActivityLogAlertResource: """Create a new activity log alert or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. + :param activity_log_alert: The activity log alert to create or use for the update. Required. :type activity_log_alert: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Required. + :type activity_log_alert: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: Union[_models.ActivityLogAlertResource, IO], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Is either a + model type or a IO type. Required. + :type activity_log_alert: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert, (IO, bytes)): + _content = activity_log_alert + else: + _json = self._serialize.body(activity_log_alert, "ActivityLogAlertResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -95,10 +177,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -107,55 +188,49 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any ) -> _models.ActivityLogAlertResource: """Get an activity log alert. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -163,10 +238,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -174,52 +248,46 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any ) -> None: """Delete an activity log alert. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -227,10 +295,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -241,54 +308,122 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, activity_log_alert_name: str, activity_log_alert_patch: _models.ActivityLogAlertResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActivityLogAlertResource: """Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. + :param activity_log_alert_patch: Parameters supplied to the operation. Required. :type activity_log_alert_patch: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Required. + :type activity_log_alert_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: Union[_models.ActivityLogAlertResourcePatch, IO], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Is either a model type + or a IO type. Required. + :type activity_log_alert_patch: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - _json = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert_patch, (IO, bytes)): + _content = activity_log_alert_patch + else: + _json = self._serialize.body(activity_log_alert_patch, "ActivityLogAlertResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -296,10 +431,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,47 +441,42 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> AsyncIterable[_models.ActivityLogAlertList]: + def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActivityLogAlertResource"]: """Get a list of all activity log alerts in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertList or the result of + :return: An iterator like instance of either ActivityLogAlertResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -355,14 +484,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -378,10 +504,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -392,47 +516,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ActivityLogAlertList]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ActivityLogAlertResource"]: """Get a list of all activity log alerts in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActivityLogAlertList or the result of + :return: An iterator like instance of either ActivityLogAlertResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -440,15 +560,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -464,10 +580,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -478,8 +592,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py index bce8f3aac60e..e51b06f64508 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py @@ -15,20 +15,20 @@ from ._models_py3 import ActivityLogAlertResourcePatch from ._models_py3 import ErrorResponse from ._models_py3 import Resource - from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActivityLogAlertActionGroup', - 'ActivityLogAlertActionList', - 'ActivityLogAlertAllOfCondition', - 'ActivityLogAlertLeafCondition', - 'ActivityLogAlertList', - 'ActivityLogAlertResource', - 'ActivityLogAlertResourcePatch', - 'ErrorResponse', - 'Resource', + "ActivityLogAlertActionGroup", + "ActivityLogAlertActionList", + "ActivityLogAlertAllOfCondition", + "ActivityLogAlertLeafCondition", + "ActivityLogAlertList", + "ActivityLogAlertResource", + "ActivityLogAlertResourcePatch", + "ErrorResponse", + "Resource", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py index 8f74a6dfbdfd..e3f5abc767fd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_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. @@ -8,21 +9,20 @@ from typing import Dict, List, Optional, TYPE_CHECKING -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class ActivityLogAlertActionGroup(msrest.serialization.Model): +class ActivityLogAlertActionGroup(_serialization.Model): """A pointer to an Azure Action Group. All required parameters must be populated in order to send to Azure. - :ivar action_group_id: Required. The resourceId of the action group. This cannot be null or - empty. + :ivar action_group_id: The resourceId of the action group. This cannot be null or empty. + Required. :vartype action_group_id: str :ivar webhook_properties: The dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. @@ -30,35 +30,29 @@ class ActivityLogAlertActionGroup(msrest.serialization.Model): """ _validation = { - 'action_group_id': {'required': True}, + "action_group_id": {"required": True}, } _attribute_map = { - 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, - 'webhook_properties': {'key': 'webhookProperties', 'type': '{str}'}, + "action_group_id": {"key": "actionGroupId", "type": "str"}, + "webhook_properties": {"key": "webhookProperties", "type": "{str}"}, } - def __init__( - self, - *, - action_group_id: str, - webhook_properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, action_group_id: str, webhook_properties: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword action_group_id: Required. The resourceId of the action group. This cannot be null or - empty. + :keyword action_group_id: The resourceId of the action group. This cannot be null or empty. + Required. :paramtype action_group_id: str :keyword webhook_properties: The dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. :paramtype webhook_properties: dict[str, str] """ - super(ActivityLogAlertActionGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.action_group_id = action_group_id self.webhook_properties = webhook_properties -class ActivityLogAlertActionList(msrest.serialization.Model): +class ActivityLogAlertActionList(_serialization.Model): """A list of activity log alert actions. :ivar action_groups: The list of activity log alerts. @@ -67,105 +61,89 @@ class ActivityLogAlertActionList(msrest.serialization.Model): """ _attribute_map = { - 'action_groups': {'key': 'actionGroups', 'type': '[ActivityLogAlertActionGroup]'}, + "action_groups": {"key": "actionGroups", "type": "[ActivityLogAlertActionGroup]"}, } - def __init__( - self, - *, - action_groups: Optional[List["_models.ActivityLogAlertActionGroup"]] = None, - **kwargs - ): + def __init__(self, *, action_groups: Optional[List["_models.ActivityLogAlertActionGroup"]] = None, **kwargs): """ :keyword action_groups: The list of activity log alerts. :paramtype action_groups: list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertActionGroup] """ - super(ActivityLogAlertActionList, self).__init__(**kwargs) + super().__init__(**kwargs) self.action_groups = action_groups -class ActivityLogAlertAllOfCondition(msrest.serialization.Model): +class ActivityLogAlertAllOfCondition(_serialization.Model): """An Activity Log alert condition that is met when all its member conditions are met. All required parameters must be populated in order to send to Azure. - :ivar all_of: Required. The list of activity log alert conditions. + :ivar all_of: The list of activity log alert conditions. Required. :vartype all_of: list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertLeafCondition] """ _validation = { - 'all_of': {'required': True}, + "all_of": {"required": True}, } _attribute_map = { - 'all_of': {'key': 'allOf', 'type': '[ActivityLogAlertLeafCondition]'}, + "all_of": {"key": "allOf", "type": "[ActivityLogAlertLeafCondition]"}, } - def __init__( - self, - *, - all_of: List["_models.ActivityLogAlertLeafCondition"], - **kwargs - ): + def __init__(self, *, all_of: List["_models.ActivityLogAlertLeafCondition"], **kwargs): """ - :keyword all_of: Required. The list of activity log alert conditions. + :keyword all_of: The list of activity log alert conditions. Required. :paramtype all_of: list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertLeafCondition] """ - super(ActivityLogAlertAllOfCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.all_of = all_of -class ActivityLogAlertLeafCondition(msrest.serialization.Model): +class ActivityLogAlertLeafCondition(_serialization.Model): """An Activity Log alert condition that is met by comparing an activity log field and value. All required parameters must be populated in order to send to Azure. - :ivar field: Required. The name of the field that this condition will examine. The possible - values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', + :ivar field: The name of the field that this condition will examine. The possible values for + this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or - anything beginning with 'properties.'. + anything beginning with 'properties.'. Required. :vartype field: str - :ivar equals: Required. The field value will be compared to this value (case-insensitive) to - determine if the condition is met. + :ivar equals: The field value will be compared to this value (case-insensitive) to determine if + the condition is met. Required. :vartype equals: str """ _validation = { - 'field': {'required': True}, - 'equals': {'required': True}, + "field": {"required": True}, + "equals": {"required": True}, } _attribute_map = { - 'field': {'key': 'field', 'type': 'str'}, - 'equals': {'key': 'equals', 'type': 'str'}, + "field": {"key": "field", "type": "str"}, + "equals": {"key": "equals", "type": "str"}, } - def __init__( - self, - *, - field: str, - equals: str, - **kwargs - ): + def __init__(self, *, field: str, equals: str, **kwargs): """ - :keyword field: Required. The name of the field that this condition will examine. The possible - values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', + :keyword field: The name of the field that this condition will examine. The possible values for + this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or - anything beginning with 'properties.'. + anything beginning with 'properties.'. Required. :paramtype field: str - :keyword equals: Required. The field value will be compared to this value (case-insensitive) to - determine if the condition is met. + :keyword equals: The field value will be compared to this value (case-insensitive) to determine + if the condition is met. Required. :paramtype equals: str """ - super(ActivityLogAlertLeafCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.field = field self.equals = equals -class ActivityLogAlertList(msrest.serialization.Model): +class ActivityLogAlertList(_serialization.Model): """A list of activity log alerts. :ivar value: The list of activity log alerts. @@ -174,25 +152,20 @@ class ActivityLogAlertList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ActivityLogAlertResource]'}, + "value": {"key": "value", "type": "[ActivityLogAlertResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ActivityLogAlertResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ActivityLogAlertResource"]] = None, **kwargs): """ :keyword value: The list of activity log alerts. :paramtype value: list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource] """ - super(ActivityLogAlertList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -205,41 +178,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -260,9 +227,9 @@ class ActivityLogAlertResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar scopes: A list of resourceIds that will be used as prefixes. The alert will only apply to activityLogs with resourceIds that fall under one of these prefixes. This list must include at @@ -282,23 +249,23 @@ class ActivityLogAlertResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'ActivityLogAlertAllOfCondition'}, - 'actions': {'key': 'properties.actions', 'type': 'ActivityLogAlertActionList'}, - 'description': {'key': 'properties.description', 'type': 'str'}, + "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}"}, + "scopes": {"key": "properties.scopes", "type": "[str]"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "condition": {"key": "properties.condition", "type": "ActivityLogAlertAllOfCondition"}, + "actions": {"key": "properties.actions", "type": "ActivityLogAlertActionList"}, + "description": {"key": "properties.description", "type": "str"}, } def __init__( @@ -307,16 +274,16 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, scopes: Optional[List[str]] = None, - enabled: Optional[bool] = True, + enabled: bool = True, condition: Optional["_models.ActivityLogAlertAllOfCondition"] = None, actions: Optional["_models.ActivityLogAlertActionList"] = None, description: Optional[str] = None, **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword scopes: A list of resourceIds that will be used as prefixes. The alert will only apply to activityLogs with resourceIds that fall under one of these prefixes. This list must include @@ -334,7 +301,7 @@ def __init__( :keyword description: A description of this activity log alert. :paramtype description: str """ - super(ActivityLogAlertResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.scopes = scopes self.enabled = enabled self.condition = condition @@ -355,9 +322,9 @@ class ActivityLogAlertResourcePatch(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. @@ -365,43 +332,36 @@ class ActivityLogAlertResourcePatch(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "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}"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - enabled: Optional[bool] = True, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. :paramtype enabled: bool """ - super(ActivityLogAlertResourcePatch, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.enabled = enabled -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -411,23 +371,17 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/__init__.py index 26aff77830bf..605798ce7feb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActivityLogAlertsOperations', + "ActivityLogAlertsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py index f0171f2e62bc..b37828628832 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +25,207 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - activity_log_alert_name: str, - *, - json: Optional[_models.ActivityLogAlertResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - activity_log_alert_name: str, - *, - json: Optional[_models.ActivityLogAlertResourcePatch] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_id_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ActivityLogAlertsOperations: """ @@ -277,51 +246,117 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, activity_log_alert_name: str, activity_log_alert: _models.ActivityLogAlertResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActivityLogAlertResource: """Create a new activity log alert or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. + :param activity_log_alert: The activity log alert to create or use for the update. Required. :type activity_log_alert: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Required. + :type activity_log_alert: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: Union[_models.ActivityLogAlertResource, IO], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Is either a + model type or a IO type. Required. + :type activity_log_alert: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert, (IO, bytes)): + _content = activity_log_alert + else: + _json = self._serialize.body(activity_log_alert, "ActivityLogAlertResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -329,10 +364,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -341,55 +375,49 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any ) -> _models.ActivityLogAlertResource: """Get an activity log alert. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -397,10 +425,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -408,52 +435,46 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any ) -> None: """Delete an activity log alert. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -461,10 +482,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -475,54 +495,122 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, activity_log_alert_name: str, activity_log_alert_patch: _models.ActivityLogAlertResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActivityLogAlertResource: """Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. + :param activity_log_alert_patch: Parameters supplied to the operation. Required. :type activity_log_alert_patch: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Required. + :type activity_log_alert_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: Union[_models.ActivityLogAlertResourcePatch, IO], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Is either a model type + or a IO type. Required. + :type activity_log_alert_patch: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - _json = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert_patch, (IO, bytes)): + _content = activity_log_alert_patch + else: + _json = self._serialize.body(activity_log_alert_patch, "ActivityLogAlertResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +618,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,47 +628,42 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> Iterable[_models.ActivityLogAlertList]: + def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActivityLogAlertResource"]: """Get a list of all activity log alerts in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertList or the result of + :return: An iterator like instance of either ActivityLogAlertResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -589,14 +671,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -612,10 +691,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -626,47 +703,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.ActivityLogAlertList]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ActivityLogAlertResource"]: """Get a list of all activity log alerts in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActivityLogAlertList or the result of + :return: An iterator like instance of either ActivityLogAlertResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -674,15 +747,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -698,10 +767,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -712,8 +779,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py index 8c6bdb7fc024..84143abad445 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-04-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-04-01") # type: str + api_version = kwargs.pop("api_version", "2017-04-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json index 52b385c18990..dae78253fff5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py index 0923ad540488..79baafaa5c1d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, ActivityLogAlertsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations @@ -30,9 +30,9 @@ class MonitorManagementClient: :ivar activity_log_alerts: ActivityLogAlertsOperations operations :vartype activity_log_alerts: $(python-base-namespace).v2017_04_01.operations.ActivityLogAlertsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -48,26 +48,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.activity_log_alerts = ActivityLogAlertsOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -76,7 +71,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py index fd655e4fe02e..e23fd4940527 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-04-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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-04-01") # type: str + api_version = kwargs.pop("api_version", "2017-04-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py index 4ae19e8ff5b1..8a28d2c6a341 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, ActivityLogAlertsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations @@ -31,9 +31,9 @@ class MonitorManagementClient: :ivar activity_log_alerts: ActivityLogAlertsOperations operations :vartype activity_log_alerts: $(python-base-namespace).v2017_04_01.aio.operations.ActivityLogAlertsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -49,26 +49,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.activity_log_alerts = ActivityLogAlertsOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -77,7 +72,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/__init__.py index a576a3f19772..6e24b5fe0a02 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', - 'ActivityLogAlertsOperations', + "ActionGroupsOperations", + "ActivityLogAlertsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py index fb812882f0b6..87cf0a940cc7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._action_groups_operations import build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_request -T = TypeVar('T') +from ...operations._action_groups_operations import ( + build_create_or_update_request, + build_delete_request, + build_enable_receiver_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ActionGroupsOperations: """ .. warning:: @@ -43,41 +60,105 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -86,7 +167,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -94,10 +176,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -106,55 +187,47 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -162,10 +235,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,52 +245,46 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -226,10 +292,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -240,52 +305,118 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2017_04_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2017_04_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -293,10 +424,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -304,46 +434,41 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -351,14 +476,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -374,10 +496,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -388,46 +508,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -435,15 +551,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -459,10 +571,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -473,47 +583,112 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore - @distributed_trace_async + @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2017_04_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2017_04_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -522,7 +697,8 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +706,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -544,5 +719,4 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py index 5199b42061ee..c114a35f3aa5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._activity_log_alerts_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_request -T = TypeVar('T') +from ...operations._activity_log_alerts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ActivityLogAlertsOperations: """ .. warning:: @@ -43,50 +59,116 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload + async def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: _models.ActivityLogAlertResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Required. + :type activity_log_alert: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Required. + :type activity_log_alert: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert: _models.ActivityLogAlertResource, + activity_log_alert: Union[_models.ActivityLogAlertResource, IO], **kwargs: Any ) -> _models.ActivityLogAlertResource: """Create a new activity log alert or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. + :param activity_log_alert: The activity log alert to create or use for the update. Is either a + model type or a IO type. Required. :type activity_log_alert: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert, (IO, bytes)): + _content = activity_log_alert + else: + _json = self._serialize.body(activity_log_alert, "ActivityLogAlertResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -94,10 +176,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -106,55 +187,49 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any ) -> _models.ActivityLogAlertResource: """Get an activity log alert. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -162,10 +237,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,52 +247,46 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any ) -> None: """Delete an activity log alert. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -226,10 +294,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -240,54 +307,122 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, activity_log_alert_name: str, activity_log_alert_patch: _models.ActivityLogAlertPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActivityLogAlertResource: """Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. + :param activity_log_alert_patch: Parameters supplied to the operation. Required. :type activity_log_alert_patch: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Required. + :type activity_log_alert_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: Union[_models.ActivityLogAlertPatchBody, IO], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Is either a model type + or a IO type. Required. + :type activity_log_alert_patch: + ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertPatchBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - _json = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert_patch, (IO, bytes)): + _content = activity_log_alert_patch + else: + _json = self._serialize.body(activity_log_alert_patch, "ActivityLogAlertPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -295,10 +430,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -306,47 +440,42 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> AsyncIterable[_models.ActivityLogAlertList]: + def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActivityLogAlertResource"]: """Get a list of all activity log alerts in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertList or the result of + :return: An iterator like instance of either ActivityLogAlertResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -354,14 +483,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -377,10 +503,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -391,47 +515,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ActivityLogAlertList]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ActivityLogAlertResource"]: """Get a list of all activity log alerts in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActivityLogAlertList or the result of + :return: An iterator like instance of either ActivityLogAlertResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -439,15 +559,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -463,10 +579,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -477,8 +591,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py index e2685936e57c..5d72089a83ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py @@ -26,34 +26,32 @@ from ._models_py3 import SmsReceiver from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import ( - ReceiverStatus, -) +from ._monitor_management_client_enums import ReceiverStatus from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupList', - 'ActionGroupPatchBody', - 'ActionGroupResource', - 'ActivityLogAlertActionGroup', - 'ActivityLogAlertActionList', - 'ActivityLogAlertAllOfCondition', - 'ActivityLogAlertLeafCondition', - 'ActivityLogAlertList', - 'ActivityLogAlertPatchBody', - 'ActivityLogAlertResource', - 'AutomationRunbookReceiver', - 'AzureAppPushReceiver', - 'EmailReceiver', - 'EnableRequest', - 'ErrorResponse', - 'ItsmReceiver', - 'Resource', - 'SmsReceiver', - 'WebhookReceiver', - 'ReceiverStatus', + "ActionGroupList", + "ActionGroupPatchBody", + "ActionGroupResource", + "ActivityLogAlertActionGroup", + "ActivityLogAlertActionList", + "ActivityLogAlertAllOfCondition", + "ActivityLogAlertLeafCondition", + "ActivityLogAlertList", + "ActivityLogAlertPatchBody", + "ActivityLogAlertResource", + "AutomationRunbookReceiver", + "AzureAppPushReceiver", + "EmailReceiver", + "EnableRequest", + "ErrorResponse", + "ItsmReceiver", + "Resource", + "SmsReceiver", + "WebhookReceiver", + "ReceiverStatus", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py index ef82554e4dce..4766bbaa6165 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_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. @@ -8,15 +9,14 @@ from typing import Dict, List, Optional, TYPE_CHECKING -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class ActionGroupList(msrest.serialization.Model): +class ActionGroupList(_serialization.Model): """A list of action groups. :ivar value: The list of action groups. @@ -26,16 +26,12 @@ class ActionGroupList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ActionGroupResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of action groups. @@ -43,15 +39,15 @@ def __init__( :keyword next_link: Provides the link to retrieve the next set of elements. :paramtype next_link: str """ - super(ActionGroupList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ActionGroupPatchBody(msrest.serialization.Model): +class ActionGroupPatchBody(_serialization.Model): """An action group object for the body of patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. @@ -59,30 +55,24 @@ class ActionGroupPatchBody(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - enabled: Optional[bool] = True, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. :paramtype enabled: bool """ - super(ActionGroupPatchBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.enabled = enabled -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -95,41 +85,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -137,7 +121,7 @@ def __init__( self.tags = tags -class ActionGroupResource(Resource): +class ActionGroupResource(Resource): # pylint: disable=too-many-instance-attributes """An action group resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -150,9 +134,9 @@ class ActionGroupResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar group_short_name: The short name of the action group. This will be used in SMS messages. :vartype group_short_name: str @@ -178,27 +162,30 @@ class ActionGroupResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "group_short_name": {"max_length": 12}, } _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}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, + "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}"}, + "group_short_name": {"key": "properties.groupShortName", "type": "str"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, + "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, + "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, + "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, + "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, + "automation_runbook_receivers": { + "key": "properties.automationRunbookReceivers", + "type": "[AutomationRunbookReceiver]", + }, } def __init__( @@ -207,7 +194,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, - enabled: Optional[bool] = True, + enabled: bool = True, email_receivers: Optional[List["_models.EmailReceiver"]] = None, sms_receivers: Optional[List["_models.SmsReceiver"]] = None, webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, @@ -217,9 +204,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword group_short_name: The short name of the action group. This will be used in SMS messages. @@ -245,7 +232,7 @@ def __init__( :paramtype automation_runbook_receivers: list[~$(python-base-namespace).v2017_04_01.models.AutomationRunbookReceiver] """ - super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled self.email_receivers = email_receivers @@ -256,13 +243,13 @@ def __init__( self.automation_runbook_receivers = automation_runbook_receivers -class ActivityLogAlertActionGroup(msrest.serialization.Model): +class ActivityLogAlertActionGroup(_serialization.Model): """A pointer to an Azure Action Group. All required parameters must be populated in order to send to Azure. - :ivar action_group_id: Required. The resourceId of the action group. This cannot be null or - empty. + :ivar action_group_id: The resourceId of the action group. This cannot be null or empty. + Required. :vartype action_group_id: str :ivar webhook_properties: the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. @@ -270,35 +257,29 @@ class ActivityLogAlertActionGroup(msrest.serialization.Model): """ _validation = { - 'action_group_id': {'required': True}, + "action_group_id": {"required": True}, } _attribute_map = { - 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, - 'webhook_properties': {'key': 'webhookProperties', 'type': '{str}'}, + "action_group_id": {"key": "actionGroupId", "type": "str"}, + "webhook_properties": {"key": "webhookProperties", "type": "{str}"}, } - def __init__( - self, - *, - action_group_id: str, - webhook_properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, action_group_id: str, webhook_properties: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword action_group_id: Required. The resourceId of the action group. This cannot be null or - empty. + :keyword action_group_id: The resourceId of the action group. This cannot be null or empty. + Required. :paramtype action_group_id: str :keyword webhook_properties: the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. :paramtype webhook_properties: dict[str, str] """ - super(ActivityLogAlertActionGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.action_group_id = action_group_id self.webhook_properties = webhook_properties -class ActivityLogAlertActionList(msrest.serialization.Model): +class ActivityLogAlertActionList(_serialization.Model): """A list of activity log alert actions. :ivar action_groups: The list of activity log alerts. @@ -307,105 +288,89 @@ class ActivityLogAlertActionList(msrest.serialization.Model): """ _attribute_map = { - 'action_groups': {'key': 'actionGroups', 'type': '[ActivityLogAlertActionGroup]'}, + "action_groups": {"key": "actionGroups", "type": "[ActivityLogAlertActionGroup]"}, } - def __init__( - self, - *, - action_groups: Optional[List["_models.ActivityLogAlertActionGroup"]] = None, - **kwargs - ): + def __init__(self, *, action_groups: Optional[List["_models.ActivityLogAlertActionGroup"]] = None, **kwargs): """ :keyword action_groups: The list of activity log alerts. :paramtype action_groups: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertActionGroup] """ - super(ActivityLogAlertActionList, self).__init__(**kwargs) + super().__init__(**kwargs) self.action_groups = action_groups -class ActivityLogAlertAllOfCondition(msrest.serialization.Model): +class ActivityLogAlertAllOfCondition(_serialization.Model): """An Activity Log alert condition that is met when all its member conditions are met. All required parameters must be populated in order to send to Azure. - :ivar all_of: Required. The list of activity log alert conditions. + :ivar all_of: The list of activity log alert conditions. Required. :vartype all_of: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertLeafCondition] """ _validation = { - 'all_of': {'required': True}, + "all_of": {"required": True}, } _attribute_map = { - 'all_of': {'key': 'allOf', 'type': '[ActivityLogAlertLeafCondition]'}, + "all_of": {"key": "allOf", "type": "[ActivityLogAlertLeafCondition]"}, } - def __init__( - self, - *, - all_of: List["_models.ActivityLogAlertLeafCondition"], - **kwargs - ): + def __init__(self, *, all_of: List["_models.ActivityLogAlertLeafCondition"], **kwargs): """ - :keyword all_of: Required. The list of activity log alert conditions. + :keyword all_of: The list of activity log alert conditions. Required. :paramtype all_of: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertLeafCondition] """ - super(ActivityLogAlertAllOfCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.all_of = all_of -class ActivityLogAlertLeafCondition(msrest.serialization.Model): +class ActivityLogAlertLeafCondition(_serialization.Model): """An Activity Log alert condition that is met by comparing an activity log field and value. All required parameters must be populated in order to send to Azure. - :ivar field: Required. The name of the field that this condition will examine. The possible - values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', + :ivar field: The name of the field that this condition will examine. The possible values for + this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or - anything beginning with 'properties.'. + anything beginning with 'properties.'. Required. :vartype field: str - :ivar equals: Required. The field value will be compared to this value (case-insensitive) to - determine if the condition is met. + :ivar equals: The field value will be compared to this value (case-insensitive) to determine if + the condition is met. Required. :vartype equals: str """ _validation = { - 'field': {'required': True}, - 'equals': {'required': True}, + "field": {"required": True}, + "equals": {"required": True}, } _attribute_map = { - 'field': {'key': 'field', 'type': 'str'}, - 'equals': {'key': 'equals', 'type': 'str'}, + "field": {"key": "field", "type": "str"}, + "equals": {"key": "equals", "type": "str"}, } - def __init__( - self, - *, - field: str, - equals: str, - **kwargs - ): + def __init__(self, *, field: str, equals: str, **kwargs): """ - :keyword field: Required. The name of the field that this condition will examine. The possible - values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', + :keyword field: The name of the field that this condition will examine. The possible values for + this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or - anything beginning with 'properties.'. + anything beginning with 'properties.'. Required. :paramtype field: str - :keyword equals: Required. The field value will be compared to this value (case-insensitive) to - determine if the condition is met. + :keyword equals: The field value will be compared to this value (case-insensitive) to determine + if the condition is met. Required. :paramtype equals: str """ - super(ActivityLogAlertLeafCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.field = field self.equals = equals -class ActivityLogAlertList(msrest.serialization.Model): +class ActivityLogAlertList(_serialization.Model): """A list of activity log alerts. :ivar value: The list of activity log alerts. @@ -415,8 +380,8 @@ class ActivityLogAlertList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ActivityLogAlertResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ActivityLogAlertResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -432,15 +397,15 @@ def __init__( :keyword next_link: Provides the link to retrieve the next set of elements. :paramtype next_link: str """ - super(ActivityLogAlertList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ActivityLogAlertPatchBody(msrest.serialization.Model): +class ActivityLogAlertPatchBody(_serialization.Model): """An activity log alert object for the body of patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. @@ -448,25 +413,19 @@ class ActivityLogAlertPatchBody(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - enabled: Optional[bool] = True, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. :paramtype enabled: bool """ - super(ActivityLogAlertPatchBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.enabled = enabled @@ -484,9 +443,9 @@ class ActivityLogAlertResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar scopes: A list of resourceIds that will be used as prefixes. The alert will only apply to activityLogs with resourceIds that fall under one of these prefixes. This list must include at @@ -504,23 +463,23 @@ class ActivityLogAlertResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'ActivityLogAlertAllOfCondition'}, - 'actions': {'key': 'properties.actions', 'type': 'ActivityLogAlertActionList'}, - 'description': {'key': 'properties.description', 'type': 'str'}, + "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}"}, + "scopes": {"key": "properties.scopes", "type": "[str]"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "condition": {"key": "properties.condition", "type": "ActivityLogAlertAllOfCondition"}, + "actions": {"key": "properties.actions", "type": "ActivityLogAlertActionList"}, + "description": {"key": "properties.description", "type": "str"}, } def __init__( @@ -529,16 +488,16 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, scopes: Optional[List[str]] = None, - enabled: Optional[bool] = True, + enabled: bool = True, condition: Optional["_models.ActivityLogAlertAllOfCondition"] = None, actions: Optional["_models.ActivityLogAlertActionList"] = None, description: Optional[str] = None, **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword scopes: A list of resourceIds that will be used as prefixes. The alert will only apply to activityLogs with resourceIds that fall under one of these prefixes. This list must include @@ -555,7 +514,7 @@ def __init__( :keyword description: A description of this activity log alert. :paramtype description: str """ - super(ActivityLogAlertResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.scopes = scopes self.enabled = enabled self.condition = condition @@ -563,19 +522,19 @@ def __init__( self.description = description -class AutomationRunbookReceiver(msrest.serialization.Model): +class AutomationRunbookReceiver(_serialization.Model): """The Azure Automation Runbook notification receiver. All required parameters must be populated in order to send to Azure. - :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook - and authenticate to Azure resource. + :ivar automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :vartype automation_account_id: str - :ivar runbook_name: Required. The name for this runbook. + :ivar runbook_name: The name for this runbook. Required. :vartype runbook_name: str - :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. :vartype webhook_resource_id: str - :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. :vartype is_global_runbook: bool :ivar name: Indicates name of the webhook. :vartype name: str @@ -584,19 +543,19 @@ class AutomationRunbookReceiver(msrest.serialization.Model): """ _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, + "automation_account_id": {"required": True}, + "runbook_name": {"required": True}, + "webhook_resource_id": {"required": True}, + "is_global_runbook": {"required": True}, } _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, + "automation_account_id": {"key": "automationAccountId", "type": "str"}, + "runbook_name": {"key": "runbookName", "type": "str"}, + "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, + "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, } def __init__( @@ -611,21 +570,21 @@ def __init__( **kwargs ): """ - :keyword automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. + :keyword automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :paramtype automation_account_id: str - :keyword runbook_name: Required. The name for this runbook. + :keyword runbook_name: The name for this runbook. Required. :paramtype runbook_name: str - :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. :paramtype webhook_resource_id: str - :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. :paramtype is_global_runbook: bool :keyword name: Indicates name of the webhook. :paramtype name: str :keyword service_uri: The URI where webhooks should be sent. :paramtype service_uri: str """ - super(AutomationRunbookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name self.webhook_resource_id = webhook_resource_id @@ -634,128 +593,111 @@ def __init__( self.service_uri = service_uri -class AzureAppPushReceiver(msrest.serialization.Model): +class AzureAppPushReceiver(_serialization.Model): """The Azure mobile App push notification receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :vartype name: str - :ivar email_address: Required. The email address registered for the Azure mobile app. + :ivar email_address: The email address registered for the Azure mobile app. Required. :vartype email_address: str """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, + "name": {"required": True}, + "email_address": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, **kwargs): """ - :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address registered for the Azure mobile app. + :keyword email_address: The email address registered for the Azure mobile app. Required. :paramtype email_address: str """ - super(AzureAppPushReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address -class EmailReceiver(msrest.serialization.Model): +class EmailReceiver(_serialization.Model): """An email receiver. Variables are only 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 name: Required. The name of the email receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the email receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar email_address: Required. The email address of this receiver. + :ivar email_address: The email address of this receiver. Required. :vartype email_address: str :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - "Disabled". + and "Disabled". :vartype status: str or ~$(python-base-namespace).v2017_04_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "email_address": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, **kwargs): """ - :keyword name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the email receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address of this receiver. + :keyword email_address: The email address of this receiver. Required. :paramtype email_address: str """ - super(EmailReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address self.status = None -class EnableRequest(msrest.serialization.Model): +class EnableRequest(_serialization.Model): """Describes a receiver that should be resubscribed. All required parameters must be populated in order to send to Azure. - :ivar receiver_name: Required. The name of the receiver to resubscribe. + :ivar receiver_name: The name of the receiver to resubscribe. Required. :vartype receiver_name: str """ _validation = { - 'receiver_name': {'required': True}, + "receiver_name": {"required": True}, } _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, + "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__( - self, - *, - receiver_name: str, - **kwargs - ): + def __init__(self, *, receiver_name: str, **kwargs): """ - :keyword receiver_name: Required. The name of the receiver to resubscribe. + :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str """ - super(EnableRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.receiver_name = receiver_name -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -765,92 +707,81 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ItsmReceiver(msrest.serialization.Model): +class ItsmReceiver(_serialization.Model): """An Itsm receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar workspace_id: Required. OMS LA instance identifier. + :ivar workspace_id: OMS LA instance identifier. Required. :vartype workspace_id: str - :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined - in above workspace. + :ivar connection_id: Unique identification of ITSM connection among multiple defined in above + workspace. Required. :vartype connection_id: str - :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :vartype ticket_configuration: str - :ivar region: Required. Region in which workspace resides. Supported + :ivar region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :vartype region: str """ _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, + "name": {"required": True}, + "workspace_id": {"required": True}, + "connection_id": {"required": True}, + "ticket_configuration": {"required": True}, + "region": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "connection_id": {"key": "connectionId", "type": "str"}, + "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, + "region": {"key": "region", "type": "str"}, } def __init__( - self, - *, - name: str, - workspace_id: str, - connection_id: str, - ticket_configuration: str, - region: str, - **kwargs + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs ): """ - :keyword name: Required. The name of the Itsm receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword workspace_id: Required. OMS LA instance identifier. + :keyword workspace_id: OMS LA instance identifier. Required. :paramtype workspace_id: str - :keyword connection_id: Required. Unique identification of ITSM connection among multiple - defined in above workspace. + :keyword connection_id: Unique identification of ITSM connection among multiple defined in + above workspace. Required. :paramtype connection_id: str - :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :paramtype ticket_configuration: str - :keyword region: Required. Region in which workspace resides. Supported + :keyword region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :paramtype region: str """ - super(ItsmReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.workspace_id = workspace_id self.connection_id = connection_id @@ -858,99 +789,86 @@ def __init__( self.region = region -class SmsReceiver(msrest.serialization.Model): +class SmsReceiver(_serialization.Model): """An SMS receiver. Variables are only 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 name: Required. The name of the SMS receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the SMS receiver. + :ivar country_code: The country code of the SMS receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the SMS receiver. + :ivar phone_number: The phone number of the SMS receiver. Required. :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and "Disabled". :vartype status: str or ~$(python-base-namespace).v2017_04_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the SMS receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the SMS receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the SMS receiver. + :keyword country_code: The country code of the SMS receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the SMS receiver. + :keyword phone_number: The phone number of the SMS receiver. Required. :paramtype phone_number: str """ - super(SmsReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number self.status = None -class WebhookReceiver(msrest.serialization.Model): +class WebhookReceiver(_serialization.Model): """A webhook receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the webhook receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar service_uri: Required. The URI where webhooks should be sent. + :ivar service_uri: The URI where webhooks should be sent. Required. :vartype service_uri: str """ _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, + "name": {"required": True}, + "service_uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, } - def __init__( - self, - *, - name: str, - service_uri: str, - **kwargs - ): + def __init__(self, *, name: str, service_uri: str, **kwargs): """ - :keyword name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the webhook receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword service_uri: Required. The URI where webhooks should be sent. + :keyword service_uri: The URI where webhooks should be sent. Required. :paramtype service_uri: str """ - super(WebhookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.service_uri = service_uri diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/__init__.py index a576a3f19772..6e24b5fe0a02 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', - 'ActivityLogAlertsOperations', + "ActionGroupsOperations", + "ActivityLogAlertsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py index 15f309343ff3..e49878de281f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,288 +25,243 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.ActionGroupResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - action_group_name: str, - *, - json: Optional[_models.ActionGroupPatchBody] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_id_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_enable_receiver_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.EnableRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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 ActionGroupsOperations: """ @@ -322,41 +282,105 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -365,7 +389,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -373,10 +398,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -385,55 +409,47 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -441,10 +457,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,52 +467,46 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -505,10 +514,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -519,52 +527,118 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2017_04_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2017_04_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -572,10 +646,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -583,46 +656,41 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -630,14 +698,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -653,10 +718,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -667,46 +730,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -714,15 +773,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -738,10 +793,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -752,47 +805,112 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore - @distributed_trace + @overload def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2017_04_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2017_04_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -801,7 +919,8 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -809,10 +928,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -823,5 +941,4 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py index db14becba5f9..e82010f43627 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +25,207 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - activity_log_alert_name: str, - *, - json: Optional[_models.ActivityLogAlertResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - activity_log_alert_name: str, - *, - json: Optional[_models.ActivityLogAlertPatchBody] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_id_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ActivityLogAlertsOperations: """ @@ -277,50 +246,116 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload + def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: _models.ActivityLogAlertResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Required. + :type activity_log_alert: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Required. + :type activity_log_alert: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert: _models.ActivityLogAlertResource, + activity_log_alert: Union[_models.ActivityLogAlertResource, IO], **kwargs: Any ) -> _models.ActivityLogAlertResource: """Create a new activity log alert or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. + :param activity_log_alert: The activity log alert to create or use for the update. Is either a + model type or a IO type. Required. :type activity_log_alert: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert, (IO, bytes)): + _content = activity_log_alert + else: + _json = self._serialize.body(activity_log_alert, "ActivityLogAlertResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -328,10 +363,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -340,55 +374,49 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any ) -> _models.ActivityLogAlertResource: """Get an activity log alert. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -396,10 +424,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,52 +434,46 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any ) -> None: """Delete an activity log alert. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -460,10 +481,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -474,54 +494,122 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, activity_log_alert_name: str, activity_log_alert_patch: _models.ActivityLogAlertPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActivityLogAlertResource: """Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. + :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. + :param activity_log_alert_patch: Parameters supplied to the operation. Required. :type activity_log_alert_patch: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Required. + :type activity_log_alert_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: Union[_models.ActivityLogAlertPatchBody, IO], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Is either a model type + or a IO type. Required. + :type activity_log_alert_patch: + ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertPatchBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - _json = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert_patch, (IO, bytes)): + _content = activity_log_alert_patch + else: + _json = self._serialize.body(activity_log_alert_patch, "ActivityLogAlertPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -529,10 +617,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -540,47 +627,42 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> Iterable[_models.ActivityLogAlertList]: + def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActivityLogAlertResource"]: """Get a list of all activity log alerts in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertList or the result of + :return: An iterator like instance of either ActivityLogAlertResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -588,14 +670,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -611,10 +690,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -625,47 +702,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.ActivityLogAlertList]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ActivityLogAlertResource"]: """Get a list of all activity log alerts in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActivityLogAlertList or the result of + :return: An iterator like instance of either ActivityLogAlertResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -673,15 +746,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -697,10 +766,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -711,8 +778,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py index f0b9640c35c9..878fafd77a97 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-05-01-preview") # type: str + api_version = kwargs.pop("api_version", "2017-05-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json index 02a0a3071b81..91b170de63e4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py index 40064fbf7070..8fab54b78b41 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py @@ -9,20 +9,26 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import DiagnosticSettingsCategoryOperations, DiagnosticSettingsOperations, MetricDefinitionsOperations, MetricsOperations, SubscriptionDiagnosticSettingsOperations +from .operations import ( + DiagnosticSettingsCategoryOperations, + DiagnosticSettingsOperations, + MetricDefinitionsOperations, + MetricsOperations, + SubscriptionDiagnosticSettingsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar diagnostic_settings_category: DiagnosticSettingsCategoryOperations operations @@ -39,9 +45,9 @@ class MonitorManagementClient: :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations :vartype subscription_diagnostic_settings: $(python-base-namespace).v2017_05_01_preview.operations.SubscriptionDiagnosticSettingsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,7 +63,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -73,19 +81,12 @@ def __init__( self.metric_definitions = MetricDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.metrics = MetricsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -94,7 +95,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py index 2ffbaa6983ff..1af7a1025c5c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-05-01-preview") # type: str + api_version = kwargs.pop("api_version", "2017-05-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py index bae3402af43e..88cce542c171 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py @@ -9,20 +9,26 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import DiagnosticSettingsCategoryOperations, DiagnosticSettingsOperations, MetricDefinitionsOperations, MetricsOperations, SubscriptionDiagnosticSettingsOperations +from .operations import ( + DiagnosticSettingsCategoryOperations, + DiagnosticSettingsOperations, + MetricDefinitionsOperations, + MetricsOperations, + SubscriptionDiagnosticSettingsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar diagnostic_settings_category: DiagnosticSettingsCategoryOperations operations @@ -39,9 +45,9 @@ class MonitorManagementClient: :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations :vartype subscription_diagnostic_settings: $(python-base-namespace).v2017_05_01_preview.aio.operations.SubscriptionDiagnosticSettingsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,7 +63,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -73,19 +81,12 @@ def __init__( self.metric_definitions = MetricDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.metrics = MetricsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -94,7 +95,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/__init__.py index 01b52d1d4e00..17173bb65e2d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/__init__.py @@ -15,12 +15,13 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DiagnosticSettingsCategoryOperations', - 'DiagnosticSettingsOperations', - 'MetricDefinitionsOperations', - 'MetricsOperations', - 'SubscriptionDiagnosticSettingsOperations', + "DiagnosticSettingsCategoryOperations", + "DiagnosticSettingsOperations", + "MetricDefinitionsOperations", + "MetricsOperations", + "SubscriptionDiagnosticSettingsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py index 32070cbc9f19..fca8f971ef0d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._diagnostic_settings_category_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DiagnosticSettingsCategoryOperations: """ .. warning:: @@ -41,42 +49,33 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get( - self, - resource_uri: str, - name: str, - **kwargs: Any - ) -> _models.DiagnosticSettingsCategoryResource: + async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResource: """Gets the diagnostic settings category for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsCategoryResource, or the result of cls(response) + :return: DiagnosticSettingsCategoryResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] - request = build_get_request( resource_uri=resource_uri, name=name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -84,10 +83,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,48 +93,40 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsCategoryResource', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsCategoryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore - + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore @distributed_trace_async - async def list( - self, - resource_uri: str, - **kwargs: Any - ) -> _models.DiagnosticSettingsCategoryResourceCollection: + async def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResourceCollection: """Lists the diagnostic settings categories for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsCategoryResourceCollection, or the result of cls(response) + :return: DiagnosticSettingsCategoryResourceCollection or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] - request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -144,10 +134,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -155,12 +144,11 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsCategoryResourceCollection', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsCategoryResourceCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore - + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py index 89ad8c46ef42..0a762a2423c3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py @@ -6,9 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +24,17 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._diagnostic_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._diagnostic_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DiagnosticSettingsOperations: """ .. warning:: @@ -41,42 +54,33 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get( - self, - resource_uri: str, - name: str, - **kwargs: Any - ) -> _models.DiagnosticSettingsResource: + async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource, or the result of cls(response) + :return: DiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] - request = build_get_request( resource_uri=resource_uri, name=name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -84,10 +88,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,51 +98,103 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_uri: str, name: str, parameters: _models.DiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DiagnosticSettingsResource: """Creates or updates diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_uri: str, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. 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: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_uri: str, name: str, parameters: Union[_models.DiagnosticSettingsResource, IO], **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DiagnosticSettingsResource, or the result of cls(response) + :return: DiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'DiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticSettingsResource") request = build_create_or_update_request( resource_uri=resource_uri, @@ -147,7 +202,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -155,10 +211,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -166,51 +221,44 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_uri: str, - name: str, - **kwargs: Any + self, resource_uri: str, name: str, **kwargs: Any ) -> None: """Deletes existing diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_uri=resource_uri, name=name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -218,10 +266,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -232,41 +279,33 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace_async - async def list( - self, - resource_uri: str, - **kwargs: Any - ) -> _models.DiagnosticSettingsResourceCollection: + async def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsResourceCollection: """Gets the active diagnostic settings list for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResourceCollection, or the result of cls(response) + :return: DiagnosticSettingsResourceCollection or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResourceCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] - request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -274,10 +313,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -285,12 +323,11 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsResourceCollection', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsResourceCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore - + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py index 0b5422b19f9f..09e9b65ce831 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._metric_definitions_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MetricDefinitionsOperations: """ .. warning:: @@ -42,41 +51,34 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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, - resource_uri: str, - **kwargs: Any - ) -> AsyncIterable[_models.MetricDefinitionCollection]: + def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.MetricDefinition"]: """Lists the metric definitions for the resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of - cls(response) + :return: An iterator like instance of either MetricDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinitionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -84,14 +86,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -107,10 +106,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -121,8 +118,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py index 266c872fc49b..b272215ec6cc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py @@ -9,7 +9,13 @@ import datetime from typing import Any, Callable, Dict, Optional, TypeVar, Union -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +26,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._metrics_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MetricsOperations: """ .. warning:: @@ -42,7 +50,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 list( self, @@ -59,7 +66,7 @@ async def list( ) -> _models.Response: """**Lists the metric values for a resource**. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param timespan: The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. Default value is None. @@ -90,28 +97,25 @@ async def list( B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. :type filter: str :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Default value is None. + operation. See the operation's description for details. Known values are: "Data" and + "Metadata". Default value is None. :type result_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.ResultType :keyword callable cls: A custom type or function that will be passed the direct response - :return: Response, or the result of cls(response) + :return: Response or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.Response - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Response] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Response] - request = build_list_request( resource_uri=resource_uri, - api_version=api_version, timespan=timespan, interval=interval, metric=metric, @@ -120,7 +124,8 @@ async def list( orderby=orderby, filter=filter, result_type=result_type, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -128,10 +133,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,12 +143,11 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Response', pipeline_response) + deserialized = self._deserialize("Response", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore - + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py index f7f3a3769072..8031778943a6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py @@ -6,9 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +24,17 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._subscription_diagnostic_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._subscription_diagnostic_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SubscriptionDiagnosticSettingsOperations: """ .. warning:: @@ -41,40 +54,32 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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, - name: str, - **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: + async def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResource: """Gets the active subscription diagnostic settings for the specified resource. - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource, or the result of cls(response) + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] - request = build_get_request( - subscription_id=self._config.subscription_id, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -82,10 +87,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -93,57 +97,109 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, name: str, parameters: _models.SubscriptionDiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SubscriptionDiagnosticSettingsResource: """Creates or updates subscription diagnostic settings for the specified resource. - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: SubscriptionDiagnosticSettingsResource, or the result of cls(response) + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. 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: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, name: str, parameters: Union[_models.SubscriptionDiagnosticSettingsResource, IO], **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionDiagnosticSettingsResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -151,10 +207,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -162,48 +217,40 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - name: str, - **kwargs: Any - ) -> None: + async def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes existing subscription diagnostic settings for the specified resource. - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -211,10 +258,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,38 +271,31 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace_async - async def list( - self, - **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResourceCollection: + async def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResourceCollection: """Gets the active subscription diagnostic settings list for the specified subscriptionId. :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResourceCollection, or the result of cls(response) + :return: SubscriptionDiagnosticSettingsResourceCollection or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] - request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -264,10 +303,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -275,12 +313,11 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionDiagnosticSettingsResourceCollection', pipeline_response) + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResourceCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py index a0d8d31ee25b..2dac6e181440 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py @@ -29,43 +29,41 @@ from ._models_py3 import SubscriptionProxyOnlyResource from ._models_py3 import TimeSeriesElement - -from ._monitor_management_client_enums import ( - AggregationType, - CategoryType, - ResultType, - Unit, -) +from ._monitor_management_client_enums import AggregationType +from ._monitor_management_client_enums import CategoryType +from ._monitor_management_client_enums import ResultType +from ._monitor_management_client_enums import Unit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DiagnosticSettingsCategoryResource', - 'DiagnosticSettingsCategoryResourceCollection', - 'DiagnosticSettingsResource', - 'DiagnosticSettingsResourceCollection', - 'ErrorResponse', - 'LocalizableString', - 'LogSettings', - 'MetadataValue', - 'Metric', - 'MetricAvailability', - 'MetricDefinition', - 'MetricDefinitionCollection', - 'MetricSettings', - 'MetricValue', - 'ProxyOnlyResource', - 'Response', - 'RetentionPolicy', - 'SubscriptionDiagnosticSettingsResource', - 'SubscriptionDiagnosticSettingsResourceCollection', - 'SubscriptionLogSettings', - 'SubscriptionProxyOnlyResource', - 'TimeSeriesElement', - 'AggregationType', - 'CategoryType', - 'ResultType', - 'Unit', + "DiagnosticSettingsCategoryResource", + "DiagnosticSettingsCategoryResourceCollection", + "DiagnosticSettingsResource", + "DiagnosticSettingsResourceCollection", + "ErrorResponse", + "LocalizableString", + "LogSettings", + "MetadataValue", + "Metric", + "MetricAvailability", + "MetricDefinition", + "MetricDefinitionCollection", + "MetricSettings", + "MetricValue", + "ProxyOnlyResource", + "Response", + "RetentionPolicy", + "SubscriptionDiagnosticSettingsResource", + "SubscriptionDiagnosticSettingsResourceCollection", + "SubscriptionLogSettings", + "SubscriptionProxyOnlyResource", + "TimeSeriesElement", + "AggregationType", + "CategoryType", + "ResultType", + "Unit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py index 7883498202d0..b88a92982851 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_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. @@ -9,15 +10,14 @@ import datetime from typing import List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class ProxyOnlyResource(msrest.serialization.Model): +class ProxyOnlyResource(_serialization.Model): """A proxy only azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -31,24 +31,20 @@ class ProxyOnlyResource(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(ProxyOnlyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -65,42 +61,37 @@ class DiagnosticSettingsCategoryResource(ProxyOnlyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar category_type: The type of the diagnostic settings category. Known values are: "Metrics", - "Logs". + :ivar category_type: The type of the diagnostic settings category. Known values are: "Metrics" + and "Logs". :vartype category_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.CategoryType """ _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'}, - 'category_type': {'key': 'properties.categoryType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "category_type": {"key": "properties.categoryType", "type": "str"}, } - def __init__( - self, - *, - category_type: Optional[Union[str, "_models.CategoryType"]] = None, - **kwargs - ): + def __init__(self, *, category_type: Optional[Union[str, "_models.CategoryType"]] = None, **kwargs): """ :keyword category_type: The type of the diagnostic settings category. Known values are: - "Metrics", "Logs". + "Metrics" and "Logs". :paramtype category_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.CategoryType """ - super(DiagnosticSettingsCategoryResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.category_type = category_type -class DiagnosticSettingsCategoryResourceCollection(msrest.serialization.Model): +class DiagnosticSettingsCategoryResourceCollection(_serialization.Model): """Represents a collection of diagnostic setting category resources. :ivar value: The collection of diagnostic settings category resources. @@ -109,25 +100,20 @@ class DiagnosticSettingsCategoryResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DiagnosticSettingsCategoryResource]'}, + "value": {"key": "value", "type": "[DiagnosticSettingsCategoryResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.DiagnosticSettingsCategoryResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DiagnosticSettingsCategoryResource"]] = None, **kwargs): """ :keyword value: The collection of diagnostic settings category resources. :paramtype value: list[~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResource] """ - super(DiagnosticSettingsCategoryResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DiagnosticSettingsResource(ProxyOnlyResource): +class DiagnosticSettingsResource(ProxyOnlyResource): # pylint: disable=too-many-instance-attributes """The diagnostic setting resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -165,23 +151,23 @@ class DiagnosticSettingsResource(ProxyOnlyResource): """ _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'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'event_hub_name': {'key': 'properties.eventHubName', 'type': 'str'}, - 'metrics': {'key': 'properties.metrics', 'type': '[MetricSettings]'}, - 'logs': {'key': 'properties.logs', 'type': '[LogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, - 'log_analytics_destination_type': {'key': 'properties.logAnalyticsDestinationType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, + "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, + "metrics": {"key": "properties.metrics", "type": "[MetricSettings]"}, + "logs": {"key": "properties.logs", "type": "[LogSettings]"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, + "log_analytics_destination_type": {"key": "properties.logAnalyticsDestinationType", "type": "str"}, } def __init__( @@ -223,7 +209,7 @@ def __init__( name>`. Possible values are: Dedicated and null (null is default.). :paramtype log_analytics_destination_type: str """ - super(DiagnosticSettingsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id self.event_hub_authorization_rule_id = event_hub_authorization_rule_id @@ -234,7 +220,7 @@ def __init__( self.log_analytics_destination_type = log_analytics_destination_type -class DiagnosticSettingsResourceCollection(msrest.serialization.Model): +class DiagnosticSettingsResourceCollection(_serialization.Model): """Represents a collection of alert rule resources. :ivar value: The collection of diagnostic settings resources;. @@ -243,25 +229,20 @@ class DiagnosticSettingsResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DiagnosticSettingsResource]'}, + "value": {"key": "value", "type": "[DiagnosticSettingsResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.DiagnosticSettingsResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DiagnosticSettingsResource"]] = None, **kwargs): """ :keyword value: The collection of diagnostic settings resources;. :paramtype value: list[~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource] """ - super(DiagnosticSettingsResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -271,67 +252,55 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class LocalizableString(msrest.serialization.Model): +class LocalizableString(_serialization.Model): """The localizable string class. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the invariant value. + :ivar value: the invariant value. Required. :vartype value: str :ivar localized_value: the locale specific value. :vartype localized_value: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: str, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs): """ - :keyword value: Required. the invariant value. + :keyword value: the invariant value. Required. :paramtype value: str :keyword localized_value: the locale specific value. :paramtype localized_value: str """ - super(LocalizableString, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class LogSettings(msrest.serialization.Model): +class LogSettings(_serialization.Model): """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. All required parameters must be populated in order to send to Azure. @@ -340,20 +309,20 @@ class LogSettings(msrest.serialization.Model): to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. :vartype category: str - :ivar enabled: Required. a value indicating whether this log is enabled. + :ivar enabled: a value indicating whether this log is enabled. Required. :vartype enabled: bool :ivar retention_policy: the retention policy for this log. :vartype retention_policy: ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy """ _validation = { - 'enabled': {'required': True}, + "enabled": {"required": True}, } _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, + "category": {"key": "category", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, } def __init__( @@ -369,19 +338,19 @@ def __init__( applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. :paramtype category: str - :keyword enabled: Required. a value indicating whether this log is enabled. + :keyword enabled: a value indicating whether this log is enabled. Required. :paramtype enabled: bool :keyword retention_policy: the retention policy for this log. :paramtype retention_policy: ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy """ - super(LogSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.category = category self.enabled = enabled self.retention_policy = retention_policy -class MetadataValue(msrest.serialization.Model): +class MetadataValue(_serialization.Model): """Represents a metric metadata value. :ivar name: the name of the metadata. @@ -391,39 +360,33 @@ class MetadataValue(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "LocalizableString"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: Optional["_models.LocalizableString"] = None, - value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional["_models.LocalizableString"] = None, value: Optional[str] = None, **kwargs): """ :keyword name: the name of the metadata. :paramtype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString :keyword value: the value of the metadata. :paramtype value: str """ - super(MetadataValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class Metric(msrest.serialization.Model): +class Metric(_serialization.Model): """The result data of a query. All required parameters must be populated in order to send to Azure. - :ivar id: Required. the metric Id. + :ivar id: the metric Id. Required. :vartype id: str - :ivar type: Required. the resource type of the metric resource. + :ivar type: the resource type of the metric resource. Required. :vartype type: str - :ivar name: Required. the name and the display name of the metric, i.e. it is localizable - string. + :ivar name: the name and the display name of the metric, i.e. it is localizable string. + Required. :vartype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString :ivar display_description: Detailed description of this metric. :vartype display_description: str @@ -431,38 +394,38 @@ class Metric(msrest.serialization.Model): :vartype error_code: str :ivar error_message: Error message encountered querying this specific metric. :vartype error_message: str - :ivar unit: Required. the unit of the metric. Known values are: "Count", "Bytes", "Seconds", + :ivar unit: the unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". :vartype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit - :ivar timeseries: Required. the time series returned when a data query is performed. + :ivar timeseries: the time series returned when a data query is performed. Required. :vartype timeseries: list[~$(python-base-namespace).v2017_05_01_preview.models.TimeSeriesElement] """ _validation = { - 'id': {'required': True}, - 'type': {'required': True}, - 'name': {'required': True}, - 'unit': {'required': True}, - 'timeseries': {'required': True}, + "id": {"required": True}, + "type": {"required": True}, + "name": {"required": True}, + "unit": {"required": True}, + "timeseries": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'timeseries': {'key': 'timeseries', 'type': '[TimeSeriesElement]'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "LocalizableString"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "timeseries": {"key": "timeseries", "type": "[TimeSeriesElement]"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin type: str, name: "_models.LocalizableString", unit: Union[str, "_models.Unit"], @@ -473,12 +436,12 @@ def __init__( **kwargs ): """ - :keyword id: Required. the metric Id. + :keyword id: the metric Id. Required. :paramtype id: str - :keyword type: Required. the resource type of the metric resource. + :keyword type: the resource type of the metric resource. Required. :paramtype type: str - :keyword name: Required. the name and the display name of the metric, i.e. it is localizable - string. + :keyword name: the name and the display name of the metric, i.e. it is localizable string. + Required. :paramtype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString :keyword display_description: Detailed description of this metric. :paramtype display_description: str @@ -486,15 +449,15 @@ def __init__( :paramtype error_code: str :keyword error_message: Error message encountered querying this specific metric. :paramtype error_message: str - :keyword unit: Required. the unit of the metric. Known values are: "Count", "Bytes", "Seconds", + :keyword unit: the unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". :paramtype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit - :keyword timeseries: Required. the time series returned when a data query is performed. + :keyword timeseries: the time series returned when a data query is performed. Required. :paramtype timeseries: list[~$(python-base-namespace).v2017_05_01_preview.models.TimeSeriesElement] """ - super(Metric, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.name = name @@ -505,7 +468,7 @@ def __init__( self.timeseries = timeseries -class MetricAvailability(msrest.serialization.Model): +class MetricAvailability(_serialization.Model): """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed @@ -517,8 +480,8 @@ class MetricAvailability(msrest.serialization.Model): """ _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'retention': {'key': 'retention', 'type': 'duration'}, + "time_grain": {"key": "timeGrain", "type": "duration"}, + "retention": {"key": "retention", "type": "duration"}, } def __init__( @@ -536,12 +499,12 @@ def __init__( as a duration 'PT1M', 'P1D', etc. :paramtype retention: ~datetime.timedelta """ - super(MetricAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_grain = time_grain self.retention = retention -class MetricDefinition(msrest.serialization.Model): +class MetricDefinition(_serialization.Model): """Metric definition class specifies the metadata for a metric. :ivar is_dimension_required: Flag to indicate whether the dimension is required. @@ -556,10 +519,10 @@ class MetricDefinition(msrest.serialization.Model): :vartype category: str :ivar unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". :vartype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and "Total". :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.AggregationType @@ -576,16 +539,16 @@ class MetricDefinition(msrest.serialization.Model): """ _attribute_map = { - 'is_dimension_required': {'key': 'isDimensionRequired', 'type': 'bool'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'primary_aggregation_type': {'key': 'primaryAggregationType', 'type': 'str'}, - 'metric_availabilities': {'key': 'metricAvailabilities', 'type': '[MetricAvailability]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[LocalizableString]'}, + "is_dimension_required": {"key": "isDimensionRequired", "type": "bool"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "name": {"key": "name", "type": "LocalizableString"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "primary_aggregation_type": {"key": "primaryAggregationType", "type": "str"}, + "metric_availabilities": {"key": "metricAvailabilities", "type": "[MetricAvailability]"}, + "id": {"key": "id", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[LocalizableString]"}, } def __init__( @@ -599,7 +562,7 @@ def __init__( unit: Optional[Union[str, "_models.Unit"]] = None, primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin dimensions: Optional[List["_models.LocalizableString"]] = None, **kwargs ): @@ -616,10 +579,10 @@ def __init__( :paramtype category: str :keyword unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". :paramtype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and "Total". :paramtype primary_aggregation_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.AggregationType @@ -634,7 +597,7 @@ def __init__( :paramtype dimensions: list[~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString] """ - super(MetricDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_dimension_required = is_dimension_required self.resource_id = resource_id self.name = name @@ -647,38 +610,33 @@ def __init__( self.dimensions = dimensions -class MetricDefinitionCollection(msrest.serialization.Model): +class MetricDefinitionCollection(_serialization.Model): """Represents collection of metric definitions. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the values for the metric definitions. + :ivar value: the values for the metric definitions. Required. :vartype value: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinition] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricDefinition]'}, + "value": {"key": "value", "type": "[MetricDefinition]"}, } - def __init__( - self, - *, - value: List["_models.MetricDefinition"], - **kwargs - ): + def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs): """ - :keyword value: Required. the values for the metric definitions. + :keyword value: the values for the metric definitions. Required. :paramtype value: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinition] """ - super(MetricDefinitionCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class MetricSettings(msrest.serialization.Model): +class MetricSettings(_serialization.Model): """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. All required parameters must be populated in order to send to Azure. @@ -689,21 +647,21 @@ class MetricSettings(msrest.serialization.Model): applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation. :vartype category: str - :ivar enabled: Required. a value indicating whether this category is enabled. + :ivar enabled: a value indicating whether this category is enabled. Required. :vartype enabled: bool :ivar retention_policy: the retention policy for this category. :vartype retention_policy: ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy """ _validation = { - 'enabled': {'required': True}, + "enabled": {"required": True}, } _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, + "time_grain": {"key": "timeGrain", "type": "duration"}, + "category": {"key": "category", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, } def __init__( @@ -722,25 +680,25 @@ def __init__( applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation. :paramtype category: str - :keyword enabled: Required. a value indicating whether this category is enabled. + :keyword enabled: a value indicating whether this category is enabled. Required. :paramtype enabled: bool :keyword retention_policy: the retention policy for this category. :paramtype retention_policy: ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy """ - super(MetricSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_grain = time_grain self.category = category self.enabled = enabled self.retention_policy = retention_policy -class MetricValue(msrest.serialization.Model): +class MetricValue(_serialization.Model): """Represents a metric value. All required parameters must be populated in order to send to Azure. - :ivar time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :ivar time_stamp: the timestamp for the metric value in ISO 8601 format. Required. :vartype time_stamp: ~datetime.datetime :ivar average: the average value in the time range. :vartype average: float @@ -752,20 +710,20 @@ class MetricValue(msrest.serialization.Model): :vartype total: float :ivar count: the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. - :vartype count: long + :vartype count: int """ _validation = { - 'time_stamp': {'required': True}, + "time_stamp": {"required": True}, } _attribute_map = { - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'average': {'key': 'average', 'type': 'float'}, - 'minimum': {'key': 'minimum', 'type': 'float'}, - 'maximum': {'key': 'maximum', 'type': 'float'}, - 'total': {'key': 'total', 'type': 'float'}, - 'count': {'key': 'count', 'type': 'long'}, + "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, + "average": {"key": "average", "type": "float"}, + "minimum": {"key": "minimum", "type": "float"}, + "maximum": {"key": "maximum", "type": "float"}, + "total": {"key": "total", "type": "float"}, + "count": {"key": "count", "type": "int"}, } def __init__( @@ -780,7 +738,7 @@ def __init__( **kwargs ): """ - :keyword time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. :paramtype time_stamp: ~datetime.datetime :keyword average: the average value in the time range. :paramtype average: float @@ -792,9 +750,9 @@ def __init__( :paramtype total: float :keyword count: the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. - :paramtype count: long + :paramtype count: int """ - super(MetricValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_stamp = time_stamp self.average = average self.minimum = minimum @@ -803,36 +761,36 @@ def __init__( self.count = count -class Response(msrest.serialization.Model): +class Response(_serialization.Model): """The response to a metrics query. All required parameters must be populated in order to send to Azure. :ivar cost: The integer value representing the relative cost of the query. :vartype cost: int - :ivar timespan: Required. The timespan for which the data was retrieved. Its value consists of - two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned - back from what was originally requested. + :ivar timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. Required. :vartype timespan: str :ivar interval: The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. :vartype interval: ~datetime.timedelta - :ivar value: Required. the value of the collection. + :ivar value: the value of the collection. Required. :vartype value: list[~$(python-base-namespace).v2017_05_01_preview.models.Metric] """ _validation = { - 'cost': {'minimum': 0}, - 'timespan': {'required': True}, - 'value': {'required': True}, + "cost": {"minimum": 0}, + "timespan": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'cost': {'key': 'cost', 'type': 'int'}, - 'timespan': {'key': 'timespan', 'type': 'str'}, - 'interval': {'key': 'interval', 'type': 'duration'}, - 'value': {'key': 'value', 'type': '[Metric]'}, + "cost": {"key": "cost", "type": "int"}, + "timespan": {"key": "timespan", "type": "str"}, + "interval": {"key": "interval", "type": "duration"}, + "value": {"key": "value", "type": "[Metric]"}, } def __init__( @@ -847,66 +805,60 @@ def __init__( """ :keyword cost: The integer value representing the relative cost of the query. :paramtype cost: int - :keyword timespan: Required. The timespan for which the data was retrieved. Its value consists - of two datetimes concatenated, separated by '/'. This may be adjusted in the future and - returned back from what was originally requested. + :keyword timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. Required. :paramtype timespan: str :keyword interval: The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. :paramtype interval: ~datetime.timedelta - :keyword value: Required. the value of the collection. + :keyword value: the value of the collection. Required. :paramtype value: list[~$(python-base-namespace).v2017_05_01_preview.models.Metric] """ - super(Response, self).__init__(**kwargs) + super().__init__(**kwargs) self.cost = cost self.timespan = timespan self.interval = interval self.value = value -class RetentionPolicy(msrest.serialization.Model): +class RetentionPolicy(_serialization.Model): """Specifies the retention policy for the log. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :ivar enabled: a value indicating whether the retention policy is enabled. Required. :vartype enabled: bool - :ivar days: Required. the number of days for the retention in days. A value of 0 will retain - the events indefinitely. + :ivar days: the number of days for the retention in days. A value of 0 will retain the events + indefinitely. Required. :vartype days: int """ _validation = { - 'enabled': {'required': True}, - 'days': {'required': True, 'minimum': 0}, + "enabled": {"required": True}, + "days": {"required": True, "minimum": 0}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: bool, - days: int, - **kwargs - ): + def __init__(self, *, enabled: bool, days: int, **kwargs): """ - :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :keyword enabled: a value indicating whether the retention policy is enabled. Required. :paramtype enabled: bool - :keyword days: Required. the number of days for the retention in days. A value of 0 will retain - the events indefinitely. + :keyword days: the number of days for the retention in days. A value of 0 will retain the + events indefinitely. Required. :paramtype days: int """ - super(RetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class SubscriptionProxyOnlyResource(msrest.serialization.Model): +class SubscriptionProxyOnlyResource(_serialization.Model): """A proxy only azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -922,29 +874,24 @@ class SubscriptionProxyOnlyResource(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'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, **kwargs): """ :keyword location: Location of the resource. :paramtype location: str """ - super(SubscriptionProxyOnlyResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -985,22 +932,22 @@ class SubscriptionDiagnosticSettingsResource(SubscriptionProxyOnlyResource): """ _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'event_hub_name': {'key': 'properties.eventHubName', 'type': 'str'}, - 'logs': {'key': 'properties.logs', 'type': '[SubscriptionLogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, + "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, + "logs": {"key": "properties.logs", "type": "[SubscriptionLogSettings]"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, } def __init__( @@ -1037,7 +984,7 @@ def __init__( /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. :paramtype workspace_id: str """ - super(SubscriptionDiagnosticSettingsResource, self).__init__(location=location, **kwargs) + super().__init__(location=location, **kwargs) self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id self.event_hub_authorization_rule_id = event_hub_authorization_rule_id @@ -1046,7 +993,7 @@ def __init__( self.workspace_id = workspace_id -class SubscriptionDiagnosticSettingsResourceCollection(msrest.serialization.Model): +class SubscriptionDiagnosticSettingsResourceCollection(_serialization.Model): """Represents a collection of subscription diagnostic settings resources. :ivar value: The collection of subscription diagnostic settings resources. @@ -1055,25 +1002,20 @@ class SubscriptionDiagnosticSettingsResourceCollection(msrest.serialization.Mode """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SubscriptionDiagnosticSettingsResource]'}, + "value": {"key": "value", "type": "[SubscriptionDiagnosticSettingsResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.SubscriptionDiagnosticSettingsResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SubscriptionDiagnosticSettingsResource"]] = None, **kwargs): """ :keyword value: The collection of subscription diagnostic settings resources. :paramtype value: list[~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource] """ - super(SubscriptionDiagnosticSettingsResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class SubscriptionLogSettings(msrest.serialization.Model): +class SubscriptionLogSettings(_serialization.Model): """Part of Subscription diagnostic setting. Specifies the settings for a particular log. All required parameters must be populated in order to send to Azure. @@ -1081,39 +1023,33 @@ class SubscriptionLogSettings(msrest.serialization.Model): :ivar category: Name of a Subscription Diagnostic Log category for a resource type this setting is applied to. :vartype category: str - :ivar enabled: Required. a value indicating whether this log is enabled. + :ivar enabled: a value indicating whether this log is enabled. Required. :vartype enabled: bool """ _validation = { - 'enabled': {'required': True}, + "enabled": {"required": True}, } _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "category": {"key": "category", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: bool, - category: Optional[str] = None, - **kwargs - ): + def __init__(self, *, enabled: bool, category: Optional[str] = None, **kwargs): """ :keyword category: Name of a Subscription Diagnostic Log category for a resource type this setting is applied to. :paramtype category: str - :keyword enabled: Required. a value indicating whether this log is enabled. + :keyword enabled: a value indicating whether this log is enabled. Required. :paramtype enabled: bool """ - super(SubscriptionLogSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.category = category self.enabled = enabled -class TimeSeriesElement(msrest.serialization.Model): +class TimeSeriesElement(_serialization.Model): """A time series result type. The discriminator value is always TimeSeries in this case. :ivar metadatavalues: the metadata values returned if $filter was specified in the call. @@ -1125,8 +1061,8 @@ class TimeSeriesElement(msrest.serialization.Model): """ _attribute_map = { - 'metadatavalues': {'key': 'metadatavalues', 'type': '[MetadataValue]'}, - 'data': {'key': 'data', 'type': '[MetricValue]'}, + "metadatavalues": {"key": "metadatavalues", "type": "[MetadataValue]"}, + "data": {"key": "data", "type": "[MetricValue]"}, } def __init__( @@ -1144,6 +1080,6 @@ def __init__( if a result type of data is specified. :paramtype data: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricValue] """ - super(TimeSeriesElement, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadatavalues = metadatavalues self.data = data diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py index e0b68ed9e799..eeb4aaf62f45 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py @@ -11,8 +11,7 @@ class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the primary aggregation type value defining how to use the values for display. - """ + """the primary aggregation type value defining how to use the values for display.""" NONE = "None" AVERAGE = "Average" @@ -21,21 +20,23 @@ class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): MAXIMUM = "Maximum" TOTAL = "Total" + class CategoryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the diagnostic settings category. - """ + """The type of the diagnostic settings category.""" METRICS = "Metrics" LOGS = "Logs" + class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ResultType.""" DATA = "Data" METADATA = "Metadata" + class Unit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of the metric. - """ + """The unit of the metric.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/__init__.py index 01b52d1d4e00..17173bb65e2d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/__init__.py @@ -15,12 +15,13 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DiagnosticSettingsCategoryOperations', - 'DiagnosticSettingsOperations', - 'MetricDefinitionsOperations', - 'MetricsOperations', - 'SubscriptionDiagnosticSettingsOperations', + "DiagnosticSettingsCategoryOperations", + "DiagnosticSettingsOperations", + "MetricDefinitionsOperations", + "MetricsOperations", + "SubscriptionDiagnosticSettingsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py index 7674e5ae9dfc..58fe6ffb57bb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,79 +23,64 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - resource_uri: str, - name: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_uri: str, - **kwargs: Any -) -> HttpRequest: +def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DiagnosticSettingsCategoryOperations: """ @@ -112,42 +101,33 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get( - self, - resource_uri: str, - name: str, - **kwargs: Any - ) -> _models.DiagnosticSettingsCategoryResource: + def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResource: """Gets the diagnostic settings category for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsCategoryResource, or the result of cls(response) + :return: DiagnosticSettingsCategoryResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] - request = build_get_request( resource_uri=resource_uri, name=name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -155,10 +135,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -166,48 +145,40 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsCategoryResource', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsCategoryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore - + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore @distributed_trace - def list( - self, - resource_uri: str, - **kwargs: Any - ) -> _models.DiagnosticSettingsCategoryResourceCollection: + def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResourceCollection: """Lists the diagnostic settings categories for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsCategoryResourceCollection, or the result of cls(response) + :return: DiagnosticSettingsCategoryResourceCollection or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] - request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -215,10 +186,9 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -226,12 +196,11 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsCategoryResourceCollection', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsCategoryResourceCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore - + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py index 12a10c2c972b..6c5b81db265c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,157 +23,117 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - resource_uri: str, - name: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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( - resource_uri: str, - name: str, - *, - json: Optional[_models.DiagnosticSettingsResource] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_uri: str, - name: str, - **kwargs: Any -) -> HttpRequest: + _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(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_uri: str, - **kwargs: Any -) -> HttpRequest: +def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DiagnosticSettingsOperations: """ @@ -190,42 +154,33 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get( - self, - resource_uri: str, - name: str, - **kwargs: Any - ) -> _models.DiagnosticSettingsResource: + def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource, or the result of cls(response) + :return: DiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] - request = build_get_request( resource_uri=resource_uri, name=name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -233,10 +188,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -244,51 +198,103 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_uri: str, name: str, parameters: _models.DiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DiagnosticSettingsResource: """Creates or updates diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DiagnosticSettingsResource, or the result of cls(response) + :return: DiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, resource_uri: str, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. 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: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_uri: str, name: str, parameters: Union[_models.DiagnosticSettingsResource, IO], **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'DiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticSettingsResource") request = build_create_or_update_request( resource_uri=resource_uri, @@ -296,7 +302,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +311,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -315,51 +321,44 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_uri: str, - name: str, - **kwargs: Any + self, resource_uri: str, name: str, **kwargs: Any ) -> None: """Deletes existing diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_uri=resource_uri, name=name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -367,10 +366,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -381,41 +379,33 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace - def list( - self, - resource_uri: str, - **kwargs: Any - ) -> _models.DiagnosticSettingsResourceCollection: + def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsResourceCollection: """Gets the active diagnostic settings list for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResourceCollection, or the result of cls(response) + :return: DiagnosticSettingsResourceCollection or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResourceCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] - request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -423,10 +413,9 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -434,12 +423,11 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsResourceCollection', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsResourceCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore - + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py index 0cb26dc2584a..732ac2c77812 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +25,39 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_uri: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metricDefinitions") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MetricDefinitionsOperations: """ @@ -78,41 +78,34 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - resource_uri: str, - **kwargs: Any - ) -> Iterable[_models.MetricDefinitionCollection]: + def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.MetricDefinition"]: """Lists the metric definitions for the resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of - cls(response) + :return: An iterator like instance of either MetricDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinitionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -120,14 +113,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -143,10 +133,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -157,8 +145,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py index 208a7bd5d1fe..d4f250b3da28 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py @@ -9,9 +9,13 @@ import datetime from typing import Any, Callable, Dict, Optional, TypeVar, Union -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -20,13 +24,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( resource_uri: str, *, @@ -43,46 +50,41 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metrics") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters if timespan is not None: - _params['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") if interval is not None: - _params['interval'] = _SERIALIZER.query("interval", interval, 'duration') + _params["interval"] = _SERIALIZER.query("interval", interval, "duration") if metric is not None: - _params['metric'] = _SERIALIZER.query("metric", metric, 'str') + _params["metric"] = _SERIALIZER.query("metric", metric, "str") if aggregation is not None: - _params['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") if orderby is not None: - _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if result_type is not None: - _params['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["resultType"] = _SERIALIZER.query("result_type", result_type, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MetricsOperations: """ @@ -103,7 +105,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, @@ -120,7 +121,7 @@ def list( ) -> _models.Response: """**Lists the metric values for a resource**. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param timespan: The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. Default value is None. @@ -151,28 +152,25 @@ def list( B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. :type filter: str :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Default value is None. + operation. See the operation's description for details. Known values are: "Data" and + "Metadata". Default value is None. :type result_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.ResultType :keyword callable cls: A custom type or function that will be passed the direct response - :return: Response, or the result of cls(response) + :return: Response or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.Response - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Response] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Response] - request = build_list_request( resource_uri=resource_uri, - api_version=api_version, timespan=timespan, interval=interval, metric=metric, @@ -181,7 +179,8 @@ def list( orderby=orderby, filter=filter, result_type=result_type, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -189,10 +188,9 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -200,12 +198,11 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Response', pipeline_response) + deserialized = self._deserialize("Response", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore - + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py index 4ba47a5f7a2c..f054a84aee8b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py @@ -6,11 +6,15 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,157 +23,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - name: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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( - subscription_id: str, - name: str, - *, - json: Optional[_models.SubscriptionDiagnosticSettingsResource] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - subscription_id: str, - name: str, - **kwargs: Any -) -> HttpRequest: + _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(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SubscriptionDiagnosticSettingsOperations: """ @@ -190,40 +160,32 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - name: str, - **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: + def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResource: """Gets the active subscription diagnostic settings for the specified resource. - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource, or the result of cls(response) + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] - request = build_get_request( - subscription_id=self._config.subscription_id, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -231,10 +193,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -242,57 +203,109 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, name: str, parameters: _models.SubscriptionDiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SubscriptionDiagnosticSettingsResource: """Creates or updates subscription diagnostic settings for the specified resource. - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. 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: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, name: str, parameters: Union[_models.SubscriptionDiagnosticSettingsResource, IO], **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: SubscriptionDiagnosticSettingsResource, or the result of cls(response) + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionDiagnosticSettingsResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -300,10 +313,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -311,48 +323,40 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - name: str, - **kwargs: Any - ) -> None: + def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes existing subscription diagnostic settings for the specified resource. - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -360,10 +364,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -374,38 +377,31 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResourceCollection: + def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResourceCollection: """Gets the active subscription diagnostic settings list for the specified subscriptionId. :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResourceCollection, or the result of cls(response) + :return: SubscriptionDiagnosticSettingsResourceCollection or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] - request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -413,10 +409,9 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -424,12 +419,11 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionDiagnosticSettingsResourceCollection', pipeline_response) + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResourceCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py index c74500c3adc6..0298e2b7bade 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py @@ -25,43 +25,40 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 :keyword api_version: Api Version. Default value is "2017-12-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-12-01-preview") # type: str + api_version = kwargs.pop("api_version", "2017-12-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json index 847e5716bee0..08f2fd24d485 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json @@ -10,14 +10,14 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 } @@ -25,7 +25,7 @@ "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 } @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py index dec4ac466f00..f9f22a1f9605 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import MetricNamespacesOperations @@ -22,13 +21,14 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar metric_namespaces: MetricNamespacesOperations operations :vartype metric_namespaces: $(python-base-namespace).v2017_12_01_preview.operations.MetricNamespacesOperations - :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 base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -38,10 +38,7 @@ class MonitorManagementClient: """ def __init__( - self, - credential: "TokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -54,12 +51,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -68,7 +60,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py index 0298239a6810..f1c5c1ea1f31 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py @@ -25,42 +25,37 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 :keyword api_version: Api Version. Default value is "2017-12-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-12-01-preview") # type: str + api_version = kwargs.pop("api_version", "2017-12-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py index e6fc42918449..547061f581bf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import MetricNamespacesOperations @@ -22,13 +21,14 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar metric_namespaces: MetricNamespacesOperations operations :vartype metric_namespaces: $(python-base-namespace).v2017_12_01_preview.aio.operations.MetricNamespacesOperations - :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 base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -38,10 +38,7 @@ class MonitorManagementClient: """ def __init__( - self, - credential: "AsyncTokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -54,12 +51,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -68,7 +60,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/__init__.py index 680cb8018ae1..6e29688e0b33 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'MetricNamespacesOperations', + "MetricNamespacesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py index d8a6db5a974d..eb01cdd9e8b2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._metric_namespaces_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MetricNamespacesOperations: """ .. warning:: @@ -42,46 +51,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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, - resource_uri: str, - start_time: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[_models.MetricNamespaceCollection]: + self, resource_uri: str, start_time: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.MetricNamespace"]: """Lists the metric namespaces for the resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param start_time: The ISO 8601 conform Date start time from which to query for metric namespaces. Default value is None. :type start_time: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricNamespaceCollection or the result of - cls(response) + :return: An iterator like instance of either MetricNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricNamespaceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricNamespaceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, start_time=start_time, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -89,15 +92,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - start_time=start_time, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -113,10 +112,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,8 +124,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/metricNamespaces"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricNamespaces"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py index 76df247f92cd..5794ea50a2a0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py @@ -11,19 +11,17 @@ from ._models_py3 import MetricNamespaceCollection from ._models_py3 import MetricNamespaceName - -from ._monitor_management_client_enums import ( - NamespaceClassification, -) +from ._monitor_management_client_enums import NamespaceClassification from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ErrorResponse', - 'MetricNamespace', - 'MetricNamespaceCollection', - 'MetricNamespaceName', - 'NamespaceClassification', + "ErrorResponse", + "MetricNamespace", + "MetricNamespaceCollection", + "MetricNamespaceName", + "NamespaceClassification", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py index 23c13532b1eb..a5774788c12c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_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. @@ -8,15 +9,14 @@ from typing import List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -26,29 +26,23 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class MetricNamespace(msrest.serialization.Model): +class MetricNamespace(_serialization.Model): """Metric namespace class specifies the metadata for a metric namespace. :ivar id: The ID of the metric namespace. @@ -57,7 +51,7 @@ class MetricNamespace(msrest.serialization.Model): :vartype type: str :ivar name: The escaped name of the namespace. :vartype name: str - :ivar classification: Kind of namespace. Known values are: "Platform", "Custom", "Qos". + :ivar classification: Kind of namespace. Known values are: "Platform", "Custom", and "Qos". :vartype classification: str or ~$(python-base-namespace).v2017_12_01_preview.models.NamespaceClassification :ivar properties: Properties which include the fully qualified namespace name. @@ -65,17 +59,17 @@ class MetricNamespace(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'classification': {'key': 'classification', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'MetricNamespaceName'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "classification": {"key": "classification", "type": "str"}, + "properties": {"key": "properties", "type": "MetricNamespaceName"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, name: Optional[str] = None, classification: Optional[Union[str, "_models.NamespaceClassification"]] = None, @@ -89,13 +83,13 @@ def __init__( :paramtype type: str :keyword name: The escaped name of the namespace. :paramtype name: str - :keyword classification: Kind of namespace. Known values are: "Platform", "Custom", "Qos". + :keyword classification: Kind of namespace. Known values are: "Platform", "Custom", and "Qos". :paramtype classification: str or ~$(python-base-namespace).v2017_12_01_preview.models.NamespaceClassification :keyword properties: Properties which include the fully qualified namespace name. :paramtype properties: ~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceName """ - super(MetricNamespace, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.name = name @@ -103,38 +97,33 @@ def __init__( self.properties = properties -class MetricNamespaceCollection(msrest.serialization.Model): +class MetricNamespaceCollection(_serialization.Model): """Represents collection of metric namespaces. All required parameters must be populated in order to send to Azure. - :ivar value: Required. The values for the metric namespaces. + :ivar value: The values for the metric namespaces. Required. :vartype value: list[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespace] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricNamespace]'}, + "value": {"key": "value", "type": "[MetricNamespace]"}, } - def __init__( - self, - *, - value: List["_models.MetricNamespace"], - **kwargs - ): + def __init__(self, *, value: List["_models.MetricNamespace"], **kwargs): """ - :keyword value: Required. The values for the metric namespaces. + :keyword value: The values for the metric namespaces. Required. :paramtype value: list[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespace] """ - super(MetricNamespaceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class MetricNamespaceName(msrest.serialization.Model): +class MetricNamespaceName(_serialization.Model): """The fully qualified metric namespace name. :ivar metric_namespace_name: The metric namespace name. @@ -142,18 +131,13 @@ class MetricNamespaceName(msrest.serialization.Model): """ _attribute_map = { - 'metric_namespace_name': {'key': 'metricNamespaceName', 'type': 'str'}, + "metric_namespace_name": {"key": "metricNamespaceName", "type": "str"}, } - def __init__( - self, - *, - metric_namespace_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, metric_namespace_name: Optional[str] = None, **kwargs): """ :keyword metric_namespace_name: The metric namespace name. :paramtype metric_namespace_name: str """ - super(MetricNamespaceName, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_namespace_name = metric_namespace_name diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py index e0c9e012e5aa..8800607a4dac 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py @@ -11,8 +11,7 @@ class NamespaceClassification(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Kind of namespace - """ + """Kind of namespace.""" PLATFORM = "Platform" CUSTOM = "Custom" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/__init__.py index 680cb8018ae1..6e29688e0b33 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'MetricNamespacesOperations', + "MetricNamespacesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py index aa46fc3407cf..f2c7545e939e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,48 +25,41 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_uri: str, - *, - start_time: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_uri: str, *, start_time: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metricNamespaces") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if start_time is not None: - _params['startTime'] = _SERIALIZER.query("start_time", start_time, 'str') + _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MetricNamespacesOperations: """ @@ -82,46 +80,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - resource_uri: str, - start_time: Optional[str] = None, - **kwargs: Any - ) -> Iterable[_models.MetricNamespaceCollection]: + self, resource_uri: str, start_time: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.MetricNamespace"]: """Lists the metric namespaces for the resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param start_time: The ISO 8601 conform Date start time from which to query for metric namespaces. Default value is None. :type start_time: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricNamespaceCollection or the result of - cls(response) + :return: An iterator like instance of either MetricNamespace or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricNamespaceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricNamespaceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, start_time=start_time, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -129,15 +121,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - start_time=start_time, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -153,10 +141,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -167,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/metricNamespaces"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricNamespaces"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py index 2b64ba9b08e4..552e4bc3bdbf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py @@ -25,43 +25,40 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 :keyword api_version: Api Version. Default value is "2018-01-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-01-01") # type: str + api_version = kwargs.pop("api_version", "2018-01-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json index d26da9081753..554f2b254864 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json @@ -10,14 +10,14 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 } @@ -25,7 +25,7 @@ "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 } @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py index 87aa11a4c710..e0b44c10e1bf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import MetricDefinitionsOperations, MetricsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar metric_definitions: MetricDefinitionsOperations operations @@ -30,7 +30,7 @@ class MonitorManagementClient: $(python-base-namespace).v2018_01_01.operations.MetricDefinitionsOperations :ivar metrics: MetricsOperations operations :vartype metrics: $(python-base-namespace).v2018_01_01.operations.MetricsOperations - :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 base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -40,10 +40,7 @@ class MonitorManagementClient: """ def __init__( - self, - credential: "TokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -55,16 +52,9 @@ def __init__( self.metric_definitions = MetricDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.metrics = MetricsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -73,7 +63,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py index 628dab438b99..70b621b9c805 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py @@ -25,42 +25,37 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 :keyword api_version: Api Version. Default value is "2018-01-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-01-01") # type: str + api_version = kwargs.pop("api_version", "2018-01-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py index c17fa4c37e5a..9e6a7ac9a08a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import MetricDefinitionsOperations, MetricsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar metric_definitions: MetricDefinitionsOperations operations @@ -30,7 +30,7 @@ class MonitorManagementClient: $(python-base-namespace).v2018_01_01.aio.operations.MetricDefinitionsOperations :ivar metrics: MetricsOperations operations :vartype metrics: $(python-base-namespace).v2018_01_01.aio.operations.MetricsOperations - :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 base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -40,10 +40,7 @@ class MonitorManagementClient: """ def __init__( - self, - credential: "AsyncTokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -55,16 +52,9 @@ def __init__( self.metric_definitions = MetricDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.metrics = MetricsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -73,7 +63,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/__init__.py index 5cd38a6007e2..adca96b9481a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'MetricDefinitionsOperations', - 'MetricsOperations', + "MetricDefinitionsOperations", + "MetricsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py index 56fdf7d07cdd..bfc55c20aad3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._metric_definitions_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MetricDefinitionsOperations: """ .. warning:: @@ -42,46 +51,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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, - resource_uri: str, - metricnamespace: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[_models.MetricDefinitionCollection]: + self, resource_uri: str, metricnamespace: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.MetricDefinition"]: """Lists the metric definitions for the resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param metricnamespace: Metric namespace to query metric definitions for. Default value is None. :type metricnamespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of - cls(response) + :return: An iterator like instance of either MetricDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_01_01.models.MetricDefinitionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_01_01.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, metricnamespace=metricnamespace, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -89,15 +92,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - metricnamespace=metricnamespace, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -113,10 +112,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,8 +124,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py index 792d4e4dcb54..19fd9ec5d170 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py @@ -9,7 +9,13 @@ import datetime from typing import Any, Callable, Dict, Optional, TypeVar, Union -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +26,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._metrics_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MetricsOperations: """ .. warning:: @@ -42,7 +50,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 list( self, @@ -60,7 +67,7 @@ async def list( ) -> _models.Response: """**Lists the metric values for a resource**. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param timespan: The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. Default value is None. @@ -96,31 +103,28 @@ async def list( %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. Default value is None. :type filter: str :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Default value is None. + operation. See the operation's description for details. Known values are: "Data" and + "Metadata". Default value is None. :type result_type: str or ~$(python-base-namespace).v2018_01_01.models.ResultType :param metricnamespace: Metric namespace to query metric definitions for. Default value is None. :type metricnamespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Response, or the result of cls(response) + :return: Response or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_01_01.models.Response - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Response] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Response] - request = build_list_request( resource_uri=resource_uri, - api_version=api_version, timespan=timespan, interval=interval, metricnames=metricnames, @@ -130,7 +134,8 @@ async def list( filter=filter, result_type=result_type, metricnamespace=metricnamespace, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -138,10 +143,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -149,12 +153,11 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Response', pipeline_response) + deserialized = self._deserialize("Response", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/metrics"} # type: ignore - + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metrics"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py index 2f080e37bffa..c828b61f896d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py @@ -17,31 +17,29 @@ from ._models_py3 import Response from ._models_py3 import TimeSeriesElement - -from ._monitor_management_client_enums import ( - AggregationType, - MetricClass, - MetricUnit, - ResultType, -) +from ._monitor_management_client_enums import AggregationType +from ._monitor_management_client_enums import MetricClass +from ._monitor_management_client_enums import MetricUnit +from ._monitor_management_client_enums import ResultType from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ErrorResponse', - 'LocalizableString', - 'MetadataValue', - 'Metric', - 'MetricAvailability', - 'MetricDefinition', - 'MetricDefinitionCollection', - 'MetricValue', - 'Response', - 'TimeSeriesElement', - 'AggregationType', - 'MetricClass', - 'MetricUnit', - 'ResultType', + "ErrorResponse", + "LocalizableString", + "MetadataValue", + "Metric", + "MetricAvailability", + "MetricDefinition", + "MetricDefinitionCollection", + "MetricValue", + "Response", + "TimeSeriesElement", + "AggregationType", + "MetricClass", + "MetricUnit", + "ResultType", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py index 2db6bfe8590d..bcd3df3cbeaf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_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. @@ -9,15 +10,14 @@ import datetime from typing import List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -27,67 +27,55 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class LocalizableString(msrest.serialization.Model): +class LocalizableString(_serialization.Model): """The localizable string class. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the invariant value. + :ivar value: the invariant value. Required. :vartype value: str :ivar localized_value: the locale specific value. :vartype localized_value: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: str, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs): """ - :keyword value: Required. the invariant value. + :keyword value: the invariant value. Required. :paramtype value: str :keyword localized_value: the locale specific value. :paramtype localized_value: str """ - super(LocalizableString, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class MetadataValue(msrest.serialization.Model): +class MetadataValue(_serialization.Model): """Represents a metric metadata value. :ivar name: the name of the metadata. @@ -97,39 +85,33 @@ class MetadataValue(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "LocalizableString"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: Optional["_models.LocalizableString"] = None, - value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional["_models.LocalizableString"] = None, value: Optional[str] = None, **kwargs): """ :keyword name: the name of the metadata. :paramtype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString :keyword value: the value of the metadata. :paramtype value: str """ - super(MetadataValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class Metric(msrest.serialization.Model): +class Metric(_serialization.Model): """The result data of a query. All required parameters must be populated in order to send to Azure. - :ivar id: Required. the metric Id. + :ivar id: the metric Id. Required. :vartype id: str - :ivar type: Required. the resource type of the metric resource. + :ivar type: the resource type of the metric resource. Required. :vartype type: str - :ivar name: Required. the name and the display name of the metric, i.e. it is localizable - string. + :ivar name: the name and the display name of the metric, i.e. it is localizable string. + Required. :vartype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString :ivar display_description: Detailed description of this metric. :vartype display_description: str @@ -137,37 +119,37 @@ class Metric(msrest.serialization.Model): :vartype error_code: str :ivar error_message: Error message encountered querying this specific metric. :vartype error_message: str - :ivar unit: Required. The unit of the metric. Known values are: "Count", "Bytes", "Seconds", + :ivar unit: The unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". :vartype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit - :ivar timeseries: Required. the time series returned when a data query is performed. + :ivar timeseries: the time series returned when a data query is performed. Required. :vartype timeseries: list[~$(python-base-namespace).v2018_01_01.models.TimeSeriesElement] """ _validation = { - 'id': {'required': True}, - 'type': {'required': True}, - 'name': {'required': True}, - 'unit': {'required': True}, - 'timeseries': {'required': True}, + "id": {"required": True}, + "type": {"required": True}, + "name": {"required": True}, + "unit": {"required": True}, + "timeseries": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'timeseries': {'key': 'timeseries', 'type': '[TimeSeriesElement]'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "LocalizableString"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "timeseries": {"key": "timeseries", "type": "[TimeSeriesElement]"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin type: str, name: "_models.LocalizableString", unit: Union[str, "_models.MetricUnit"], @@ -178,12 +160,12 @@ def __init__( **kwargs ): """ - :keyword id: Required. the metric Id. + :keyword id: the metric Id. Required. :paramtype id: str - :keyword type: Required. the resource type of the metric resource. + :keyword type: the resource type of the metric resource. Required. :paramtype type: str - :keyword name: Required. the name and the display name of the metric, i.e. it is localizable - string. + :keyword name: the name and the display name of the metric, i.e. it is localizable string. + Required. :paramtype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString :keyword display_description: Detailed description of this metric. :paramtype display_description: str @@ -191,14 +173,14 @@ def __init__( :paramtype error_code: str :keyword error_message: Error message encountered querying this specific metric. :paramtype error_message: str - :keyword unit: Required. The unit of the metric. Known values are: "Count", "Bytes", "Seconds", + :keyword unit: The unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". :paramtype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit - :keyword timeseries: Required. the time series returned when a data query is performed. + :keyword timeseries: the time series returned when a data query is performed. Required. :paramtype timeseries: list[~$(python-base-namespace).v2018_01_01.models.TimeSeriesElement] """ - super(Metric, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.name = name @@ -209,7 +191,7 @@ def __init__( self.timeseries = timeseries -class MetricAvailability(msrest.serialization.Model): +class MetricAvailability(_serialization.Model): """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed @@ -221,8 +203,8 @@ class MetricAvailability(msrest.serialization.Model): """ _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'retention': {'key': 'retention', 'type': 'duration'}, + "time_grain": {"key": "timeGrain", "type": "duration"}, + "retention": {"key": "retention", "type": "duration"}, } def __init__( @@ -240,12 +222,12 @@ def __init__( as a duration 'PT1M', 'P1D', etc. :paramtype retention: ~datetime.timedelta """ - super(MetricAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_grain = time_grain self.retention = retention -class MetricDefinition(msrest.serialization.Model): +class MetricDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Metric definition class specifies the metadata for a metric. :ivar is_dimension_required: Flag to indicate whether the dimension is required. @@ -261,14 +243,14 @@ class MetricDefinition(msrest.serialization.Model): :ivar category: Custom category name for this metric. :vartype category: str :ivar metric_class: The class of the metric. Known values are: "Availability", "Transactions", - "Errors", "Latency", "Saturation". + "Errors", "Latency", and "Saturation". :vartype metric_class: str or ~$(python-base-namespace).v2018_01_01.models.MetricClass :ivar unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". :vartype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and "Total". :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2018_01_01.models.AggregationType @@ -287,19 +269,19 @@ class MetricDefinition(msrest.serialization.Model): """ _attribute_map = { - 'is_dimension_required': {'key': 'isDimensionRequired', 'type': 'bool'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'metric_class': {'key': 'metricClass', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'primary_aggregation_type': {'key': 'primaryAggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'metric_availabilities': {'key': 'metricAvailabilities', 'type': '[MetricAvailability]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[LocalizableString]'}, + "is_dimension_required": {"key": "isDimensionRequired", "type": "bool"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "name": {"key": "name", "type": "LocalizableString"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "metric_class": {"key": "metricClass", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "primary_aggregation_type": {"key": "primaryAggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "metric_availabilities": {"key": "metricAvailabilities", "type": "[MetricAvailability]"}, + "id": {"key": "id", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[LocalizableString]"}, } def __init__( @@ -316,7 +298,7 @@ def __init__( primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, supported_aggregation_types: Optional[List[Union[str, "_models.AggregationType"]]] = None, metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin dimensions: Optional[List["_models.LocalizableString"]] = None, **kwargs ): @@ -334,14 +316,14 @@ def __init__( :keyword category: Custom category name for this metric. :paramtype category: str :keyword metric_class: The class of the metric. Known values are: "Availability", - "Transactions", "Errors", "Latency", "Saturation". + "Transactions", "Errors", "Latency", and "Saturation". :paramtype metric_class: str or ~$(python-base-namespace).v2018_01_01.models.MetricClass :keyword unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". :paramtype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and "Total". :paramtype primary_aggregation_type: str or ~$(python-base-namespace).v2018_01_01.models.AggregationType @@ -358,7 +340,7 @@ def __init__( string. :paramtype dimensions: list[~$(python-base-namespace).v2018_01_01.models.LocalizableString] """ - super(MetricDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_dimension_required = is_dimension_required self.resource_id = resource_id self.namespace = namespace @@ -374,43 +356,38 @@ def __init__( self.dimensions = dimensions -class MetricDefinitionCollection(msrest.serialization.Model): +class MetricDefinitionCollection(_serialization.Model): """Represents collection of metric definitions. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the values for the metric definitions. + :ivar value: the values for the metric definitions. Required. :vartype value: list[~$(python-base-namespace).v2018_01_01.models.MetricDefinition] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricDefinition]'}, + "value": {"key": "value", "type": "[MetricDefinition]"}, } - def __init__( - self, - *, - value: List["_models.MetricDefinition"], - **kwargs - ): + def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs): """ - :keyword value: Required. the values for the metric definitions. + :keyword value: the values for the metric definitions. Required. :paramtype value: list[~$(python-base-namespace).v2018_01_01.models.MetricDefinition] """ - super(MetricDefinitionCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class MetricValue(msrest.serialization.Model): +class MetricValue(_serialization.Model): """Represents a metric value. All required parameters must be populated in order to send to Azure. - :ivar time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :ivar time_stamp: the timestamp for the metric value in ISO 8601 format. Required. :vartype time_stamp: ~datetime.datetime :ivar average: the average value in the time range. :vartype average: float @@ -426,16 +403,16 @@ class MetricValue(msrest.serialization.Model): """ _validation = { - 'time_stamp': {'required': True}, + "time_stamp": {"required": True}, } _attribute_map = { - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'average': {'key': 'average', 'type': 'float'}, - 'minimum': {'key': 'minimum', 'type': 'float'}, - 'maximum': {'key': 'maximum', 'type': 'float'}, - 'total': {'key': 'total', 'type': 'float'}, - 'count': {'key': 'count', 'type': 'float'}, + "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, + "average": {"key": "average", "type": "float"}, + "minimum": {"key": "minimum", "type": "float"}, + "maximum": {"key": "maximum", "type": "float"}, + "total": {"key": "total", "type": "float"}, + "count": {"key": "count", "type": "float"}, } def __init__( @@ -450,7 +427,7 @@ def __init__( **kwargs ): """ - :keyword time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. :paramtype time_stamp: ~datetime.datetime :keyword average: the average value in the time range. :paramtype average: float @@ -464,7 +441,7 @@ def __init__( values that contributed to the average value. :paramtype count: float """ - super(MetricValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_stamp = time_stamp self.average = average self.minimum = minimum @@ -473,16 +450,16 @@ def __init__( self.count = count -class Response(msrest.serialization.Model): +class Response(_serialization.Model): """The response to a metrics query. All required parameters must be populated in order to send to Azure. :ivar cost: The integer value representing the relative cost of the query. :vartype cost: int - :ivar timespan: Required. The timespan for which the data was retrieved. Its value consists of - two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned - back from what was originally requested. + :ivar timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. Required. :vartype timespan: str :ivar interval: The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not @@ -492,23 +469,23 @@ class Response(msrest.serialization.Model): :vartype namespace: str :ivar resourceregion: The region of the resource being queried for metrics. :vartype resourceregion: str - :ivar value: Required. the value of the collection. + :ivar value: the value of the collection. Required. :vartype value: list[~$(python-base-namespace).v2018_01_01.models.Metric] """ _validation = { - 'cost': {'minimum': 0}, - 'timespan': {'required': True}, - 'value': {'required': True}, + "cost": {"minimum": 0}, + "timespan": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'cost': {'key': 'cost', 'type': 'int'}, - 'timespan': {'key': 'timespan', 'type': 'str'}, - 'interval': {'key': 'interval', 'type': 'duration'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'resourceregion': {'key': 'resourceregion', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Metric]'}, + "cost": {"key": "cost", "type": "int"}, + "timespan": {"key": "timespan", "type": "str"}, + "interval": {"key": "interval", "type": "duration"}, + "namespace": {"key": "namespace", "type": "str"}, + "resourceregion": {"key": "resourceregion", "type": "str"}, + "value": {"key": "value", "type": "[Metric]"}, } def __init__( @@ -525,9 +502,9 @@ def __init__( """ :keyword cost: The integer value representing the relative cost of the query. :paramtype cost: int - :keyword timespan: Required. The timespan for which the data was retrieved. Its value consists - of two datetimes concatenated, separated by '/'. This may be adjusted in the future and - returned back from what was originally requested. + :keyword timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. Required. :paramtype timespan: str :keyword interval: The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is @@ -537,10 +514,10 @@ def __init__( :paramtype namespace: str :keyword resourceregion: The region of the resource being queried for metrics. :paramtype resourceregion: str - :keyword value: Required. the value of the collection. + :keyword value: the value of the collection. Required. :paramtype value: list[~$(python-base-namespace).v2018_01_01.models.Metric] """ - super(Response, self).__init__(**kwargs) + super().__init__(**kwargs) self.cost = cost self.timespan = timespan self.interval = interval @@ -549,7 +526,7 @@ def __init__( self.value = value -class TimeSeriesElement(msrest.serialization.Model): +class TimeSeriesElement(_serialization.Model): """A time series result type. The discriminator value is always TimeSeries in this case. :ivar metadatavalues: the metadata values returned if $filter was specified in the call. @@ -560,8 +537,8 @@ class TimeSeriesElement(msrest.serialization.Model): """ _attribute_map = { - 'metadatavalues': {'key': 'metadatavalues', 'type': '[MetadataValue]'}, - 'data': {'key': 'data', 'type': '[MetricValue]'}, + "metadatavalues": {"key": "metadatavalues", "type": "[MetadataValue]"}, + "data": {"key": "data", "type": "[MetricValue]"}, } def __init__( @@ -578,6 +555,6 @@ def __init__( if a result type of data is specified. :paramtype data: list[~$(python-base-namespace).v2018_01_01.models.MetricValue] """ - super(TimeSeriesElement, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadatavalues = metadatavalues self.data = data diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py index 2550683eb494..5fe91232cac4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py @@ -11,8 +11,7 @@ class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the aggregation type of the metric. - """ + """the aggregation type of the metric.""" NONE = "None" AVERAGE = "Average" @@ -21,9 +20,9 @@ class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): MAXIMUM = "Maximum" TOTAL = "Total" + class MetricClass(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The class of the metric. - """ + """The class of the metric.""" AVAILABILITY = "Availability" TRANSACTIONS = "Transactions" @@ -31,9 +30,9 @@ class MetricClass(str, Enum, metaclass=CaseInsensitiveEnumMeta): LATENCY = "Latency" SATURATION = "Saturation" + class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of the metric. - """ + """The unit of the metric.""" COUNT = "Count" BYTES = "Bytes" @@ -49,7 +48,9 @@ class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): NANO_CORES = "NanoCores" BITS_PER_SECOND = "BitsPerSecond" + class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ResultType.""" DATA = "Data" METADATA = "Metadata" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/__init__.py index 5cd38a6007e2..adca96b9481a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'MetricDefinitionsOperations', - 'MetricsOperations', + "MetricDefinitionsOperations", + "MetricsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py index ade5e1c22bf1..ac2334e0521c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,48 +25,41 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_uri: str, - *, - metricnamespace: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_uri: str, *, metricnamespace: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if metricnamespace is not None: - _params['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') + _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MetricDefinitionsOperations: """ @@ -82,46 +80,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - resource_uri: str, - metricnamespace: Optional[str] = None, - **kwargs: Any - ) -> Iterable[_models.MetricDefinitionCollection]: + self, resource_uri: str, metricnamespace: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.MetricDefinition"]: """Lists the metric definitions for the resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param metricnamespace: Metric namespace to query metric definitions for. Default value is None. :type metricnamespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of - cls(response) + :return: An iterator like instance of either MetricDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_01_01.models.MetricDefinitionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_01_01.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, metricnamespace=metricnamespace, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -129,15 +121,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - metricnamespace=metricnamespace, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -153,10 +141,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -167,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py index 4ad8177fd803..0329bde5c858 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py @@ -9,9 +9,13 @@ import datetime from typing import Any, Callable, Dict, Optional, TypeVar, Union -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -20,13 +24,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( resource_uri: str, *, @@ -44,48 +51,43 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metrics") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters if timespan is not None: - _params['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") if interval is not None: - _params['interval'] = _SERIALIZER.query("interval", interval, 'duration') + _params["interval"] = _SERIALIZER.query("interval", interval, "duration") if metricnames is not None: - _params['metricnames'] = _SERIALIZER.query("metricnames", metricnames, 'str') + _params["metricnames"] = _SERIALIZER.query("metricnames", metricnames, "str") if aggregation is not None: - _params['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") if top is not None: - _params['top'] = _SERIALIZER.query("top", top, 'int') + _params["top"] = _SERIALIZER.query("top", top, "int") if orderby is not None: - _params['orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params["orderby"] = _SERIALIZER.query("orderby", orderby, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if result_type is not None: - _params['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["resultType"] = _SERIALIZER.query("result_type", result_type, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if metricnamespace is not None: - _params['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') + _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MetricsOperations: """ @@ -106,7 +108,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, @@ -124,7 +125,7 @@ def list( ) -> _models.Response: """**Lists the metric values for a resource**. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param timespan: The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. Default value is None. @@ -160,31 +161,28 @@ def list( %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. Default value is None. :type filter: str :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Default value is None. + operation. See the operation's description for details. Known values are: "Data" and + "Metadata". Default value is None. :type result_type: str or ~$(python-base-namespace).v2018_01_01.models.ResultType :param metricnamespace: Metric namespace to query metric definitions for. Default value is None. :type metricnamespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Response, or the result of cls(response) + :return: Response or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_01_01.models.Response - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Response] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Response] - request = build_list_request( resource_uri=resource_uri, - api_version=api_version, timespan=timespan, interval=interval, metricnames=metricnames, @@ -194,7 +192,8 @@ def list( filter=filter, result_type=result_type, metricnamespace=metricnamespace, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -202,10 +201,9 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -213,12 +211,11 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Response', pipeline_response) + deserialized = self._deserialize("Response", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/metrics"} # type: ignore - + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metrics"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py index d38615cce33f..8146f966a635 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-03-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", "2018-03-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json index 4b154548b576..41cb09faca9b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py index 6e477a41bc94..4641d8caf631 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, MetricAlertsOperations, MetricAlertsStatusOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations @@ -32,9 +32,9 @@ class MonitorManagementClient: :ivar metric_alerts_status: MetricAlertsStatusOperations operations :vartype metric_alerts_status: $(python-base-namespace).v2018_03_01.operations.MetricAlertsStatusOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,29 +50,22 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.metric_alerts = MetricAlertsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_alerts = MetricAlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.metric_alerts_status = MetricAlertsStatusOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -81,7 +74,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py index 956d837ce56c..4544634ac52f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-03-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-03-01") # type: str + api_version = kwargs.pop("api_version", "2018-03-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py index d5fbcaa29189..be454df6d46f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, MetricAlertsOperations, MetricAlertsStatusOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations @@ -34,9 +34,9 @@ class MonitorManagementClient: :ivar metric_alerts_status: MetricAlertsStatusOperations operations :vartype metric_alerts_status: $(python-base-namespace).v2018_03_01.aio.operations.MetricAlertsStatusOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -52,29 +52,22 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.metric_alerts = MetricAlertsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_alerts = MetricAlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.metric_alerts_status = MetricAlertsStatusOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -83,7 +76,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/__init__.py index abf34ef0b771..08442f934dbe 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/__init__.py @@ -13,10 +13,11 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', - 'MetricAlertsOperations', - 'MetricAlertsStatusOperations', + "ActionGroupsOperations", + "MetricAlertsOperations", + "MetricAlertsStatusOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py index 217c01d64135..16ea03e2b296 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._action_groups_operations import build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_request -T = TypeVar('T') +from ...operations._action_groups_operations import ( + build_create_or_update_request, + build_delete_request, + build_enable_receiver_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ActionGroupsOperations: """ .. warning:: @@ -43,41 +60,105 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -86,7 +167,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -94,10 +176,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -106,55 +187,47 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -162,10 +235,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,52 +245,46 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -226,10 +292,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -240,52 +305,118 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2018_03_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2018_03_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -293,10 +424,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -304,46 +434,41 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -351,14 +476,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -374,10 +496,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -388,46 +508,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -435,15 +551,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -459,10 +571,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -473,47 +583,112 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore - @distributed_trace_async + @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2018_03_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2018_03_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -522,7 +697,8 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +706,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -544,5 +719,4 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py index 6ae5edc546e5..25dc19d3ddc9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._metric_alerts_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._metric_alerts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MetricAlertsOperations: """ .. warning:: @@ -43,38 +59,32 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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, - **kwargs: Any - ) -> AsyncIterable[_models.MetricAlertResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.MetricAlertResource"]: """Retrieve alert rule definitions in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricAlertResourceCollection or the result of - cls(response) + :return: An iterator like instance of either MetricAlertResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -82,14 +92,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -105,10 +112,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -119,47 +124,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MetricAlertResourceCollection]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MetricAlertResource"]: """Retrieve alert rule definitions in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 MetricAlertResourceCollection or the result of - cls(response) + :return: An iterator like instance of either MetricAlertResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -167,15 +167,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -191,10 +187,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -205,48 +199,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.MetricAlertResource: + async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.MetricAlertResource: """Retrieve an alert rule definition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource, or the result of cls(response) + :return: MetricAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -254,10 +239,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -265,59 +249,124 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MetricAlertResource', pipeline_response) + deserialized = self._deserialize("MetricAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, rule_name: str, parameters: _models.MetricAlertResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.MetricAlertResource: """Create or update an metric alert definition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. + :param parameters: The parameters of the rule to create or update. Required. :type parameters: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: MetricAlertResource, or the result of cls(response) + :return: MetricAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetricAlertResource: + """Create or update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. 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: MetricAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.MetricAlertResource, IO], + **kwargs: Any + ) -> _models.MetricAlertResource: + """Create or update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a model type or a + IO type. Required. + :type parameters: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: MetricAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResource] - _json = self._serialize.body(parameters, 'MetricAlertResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MetricAlertResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -325,10 +374,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,59 +384,124 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MetricAlertResource', pipeline_response) + deserialized = self._deserialize("MetricAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, rule_name: str, parameters: _models.MetricAlertResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.MetricAlertResource: """Update an metric alert definition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to update. + :param parameters: The parameters of the rule to update. Required. :type parameters: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: MetricAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetricAlertResource: + """Update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. 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: MetricAlertResource, or the result of cls(response) + :return: MetricAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.MetricAlertResourcePatch, IO], + **kwargs: Any + ) -> _models.MetricAlertResource: + """Update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Is either a model type or a IO type. + Required. + :type parameters: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: MetricAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResource] - _json = self._serialize.body(parameters, 'MetricAlertResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MetricAlertResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -396,10 +509,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,52 +519,46 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MetricAlertResource', pipeline_response) + deserialized = self._deserialize("MetricAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, **kwargs: Any ) -> None: """Delete an alert rule definition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -460,10 +566,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -474,5 +579,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py index 25816eb63c32..da5ddc6a272e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._metric_alerts_status_operations import build_list_by_name_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MetricAlertsStatusOperations: """ .. warning:: @@ -41,43 +49,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 list( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, **kwargs: Any ) -> _models.MetricAlertStatusCollection: """Retrieve an alert rule status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertStatusCollection, or the result of cls(response) + :return: MetricAlertStatusCollection or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertStatusCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertStatusCollection] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -85,10 +87,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,56 +97,49 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MetricAlertStatusCollection', pipeline_response) + deserialized = self._deserialize("MetricAlertStatusCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status"} # type: ignore @distributed_trace_async async def list_by_name( - self, - resource_group_name: str, - rule_name: str, - status_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, status_name: str, **kwargs: Any ) -> _models.MetricAlertStatusCollection: """Retrieve an alert rule status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param status_name: The name of the status. + :param status_name: The name of the status. Required. :type status_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertStatusCollection, or the result of cls(response) + :return: MetricAlertStatusCollection or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertStatusCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertStatusCollection] - request = build_list_by_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, status_name=status_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_name.metadata['url'], + template_url=self.list_by_name.metadata["url"], headers=_headers, params=_params, ) @@ -153,10 +147,9 @@ async def list_by_name( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -164,12 +157,11 @@ async def list_by_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MetricAlertStatusCollection', pipeline_response) + deserialized = self._deserialize("MetricAlertStatusCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}"} # type: ignore - + list_by_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py index 469cf245f692..ba7081ca121c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py @@ -38,58 +38,56 @@ from ._models_py3 import WebhookReceiver from ._models_py3 import WebtestLocationAvailabilityCriteria - -from ._monitor_management_client_enums import ( - AggregationTypeEnum, - CriterionType, - DynamicThresholdOperator, - DynamicThresholdSensitivity, - Odatatype, - Operator, - ReceiverStatus, -) +from ._monitor_management_client_enums import AggregationTypeEnum +from ._monitor_management_client_enums import CriterionType +from ._monitor_management_client_enums import DynamicThresholdOperator +from ._monitor_management_client_enums import DynamicThresholdSensitivity +from ._monitor_management_client_enums import Odatatype +from ._monitor_management_client_enums import Operator +from ._monitor_management_client_enums import ReceiverStatus from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupList', - 'ActionGroupPatchBody', - 'ActionGroupResource', - 'AutomationRunbookReceiver', - 'AzureAppPushReceiver', - 'AzureFunctionReceiver', - 'DynamicMetricCriteria', - 'DynamicThresholdFailingPeriods', - 'EmailReceiver', - 'EnableRequest', - 'ErrorResponse', - 'ItsmReceiver', - 'LogicAppReceiver', - 'MetricAlertAction', - 'MetricAlertCriteria', - 'MetricAlertMultipleResourceMultipleMetricCriteria', - 'MetricAlertResource', - 'MetricAlertResourceCollection', - 'MetricAlertResourcePatch', - 'MetricAlertSingleResourceMultipleMetricCriteria', - 'MetricAlertStatus', - 'MetricAlertStatusCollection', - 'MetricAlertStatusProperties', - 'MetricCriteria', - 'MetricDimension', - 'MultiMetricCriteria', - 'Resource', - 'SmsReceiver', - 'VoiceReceiver', - 'WebhookReceiver', - 'WebtestLocationAvailabilityCriteria', - 'AggregationTypeEnum', - 'CriterionType', - 'DynamicThresholdOperator', - 'DynamicThresholdSensitivity', - 'Odatatype', - 'Operator', - 'ReceiverStatus', + "ActionGroupList", + "ActionGroupPatchBody", + "ActionGroupResource", + "AutomationRunbookReceiver", + "AzureAppPushReceiver", + "AzureFunctionReceiver", + "DynamicMetricCriteria", + "DynamicThresholdFailingPeriods", + "EmailReceiver", + "EnableRequest", + "ErrorResponse", + "ItsmReceiver", + "LogicAppReceiver", + "MetricAlertAction", + "MetricAlertCriteria", + "MetricAlertMultipleResourceMultipleMetricCriteria", + "MetricAlertResource", + "MetricAlertResourceCollection", + "MetricAlertResourcePatch", + "MetricAlertSingleResourceMultipleMetricCriteria", + "MetricAlertStatus", + "MetricAlertStatusCollection", + "MetricAlertStatusProperties", + "MetricCriteria", + "MetricDimension", + "MultiMetricCriteria", + "Resource", + "SmsReceiver", + "VoiceReceiver", + "WebhookReceiver", + "WebtestLocationAvailabilityCriteria", + "AggregationTypeEnum", + "CriterionType", + "DynamicThresholdOperator", + "DynamicThresholdSensitivity", + "Odatatype", + "Operator", + "ReceiverStatus", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py index 24749f1dc7e0..cb6297144d30 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_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,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class ActionGroupList(msrest.serialization.Model): +class ActionGroupList(_serialization.Model): """A list of action groups. :ivar value: The list of action groups. @@ -27,16 +33,12 @@ class ActionGroupList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ActionGroupResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of action groups. @@ -44,15 +46,15 @@ def __init__( :keyword next_link: Provides the link to retrieve the next set of elements. :paramtype next_link: str """ - super(ActionGroupList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ActionGroupPatchBody(msrest.serialization.Model): +class ActionGroupPatchBody(_serialization.Model): """An action group object for the body of patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. @@ -60,30 +62,24 @@ class ActionGroupPatchBody(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - enabled: Optional[bool] = True, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. :paramtype enabled: bool """ - super(ActionGroupPatchBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.enabled = enabled -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -96,41 +92,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -138,7 +128,7 @@ def __init__( self.tags = tags -class ActionGroupResource(Resource): +class ActionGroupResource(Resource): # pylint: disable=too-many-instance-attributes """An action group resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -151,9 +141,9 @@ class ActionGroupResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar group_short_name: The short name of the action group. This will be used in SMS messages. :vartype group_short_name: str @@ -188,30 +178,33 @@ class ActionGroupResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "group_short_name": {"max_length": 12}, } _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}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, + "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}"}, + "group_short_name": {"key": "properties.groupShortName", "type": "str"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, + "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, + "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, + "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, + "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, + "automation_runbook_receivers": { + "key": "properties.automationRunbookReceivers", + "type": "[AutomationRunbookReceiver]", + }, + "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, + "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, + "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, } def __init__( @@ -220,7 +213,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, - enabled: Optional[bool] = True, + enabled: bool = True, email_receivers: Optional[List["_models.EmailReceiver"]] = None, sms_receivers: Optional[List["_models.SmsReceiver"]] = None, webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, @@ -233,9 +226,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword group_short_name: The short name of the action group. This will be used in SMS messages. @@ -271,7 +264,7 @@ def __init__( :paramtype azure_function_receivers: list[~$(python-base-namespace).v2018_03_01.models.AzureFunctionReceiver] """ - super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled self.email_receivers = email_receivers @@ -285,19 +278,19 @@ def __init__( self.azure_function_receivers = azure_function_receivers -class AutomationRunbookReceiver(msrest.serialization.Model): +class AutomationRunbookReceiver(_serialization.Model): """The Azure Automation Runbook notification receiver. All required parameters must be populated in order to send to Azure. - :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook - and authenticate to Azure resource. + :ivar automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :vartype automation_account_id: str - :ivar runbook_name: Required. The name for this runbook. + :ivar runbook_name: The name for this runbook. Required. :vartype runbook_name: str - :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. :vartype webhook_resource_id: str - :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. :vartype is_global_runbook: bool :ivar name: Indicates name of the webhook. :vartype name: str @@ -306,19 +299,19 @@ class AutomationRunbookReceiver(msrest.serialization.Model): """ _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, + "automation_account_id": {"required": True}, + "runbook_name": {"required": True}, + "webhook_resource_id": {"required": True}, + "is_global_runbook": {"required": True}, } _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, + "automation_account_id": {"key": "automationAccountId", "type": "str"}, + "runbook_name": {"key": "runbookName", "type": "str"}, + "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, + "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, } def __init__( @@ -333,21 +326,21 @@ def __init__( **kwargs ): """ - :keyword automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. + :keyword automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :paramtype automation_account_id: str - :keyword runbook_name: Required. The name for this runbook. + :keyword runbook_name: The name for this runbook. Required. :paramtype runbook_name: str - :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. :paramtype webhook_resource_id: str - :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. :paramtype is_global_runbook: bool :keyword name: Indicates name of the webhook. :paramtype name: str :keyword service_uri: The URI where webhooks should be sent. :paramtype service_uri: str """ - super(AutomationRunbookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name self.webhook_resource_id = webhook_resource_id @@ -356,126 +349,114 @@ def __init__( self.service_uri = service_uri -class AzureAppPushReceiver(msrest.serialization.Model): +class AzureAppPushReceiver(_serialization.Model): """The Azure mobile App push notification receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :vartype name: str - :ivar email_address: Required. The email address registered for the Azure mobile app. + :ivar email_address: The email address registered for the Azure mobile app. Required. :vartype email_address: str """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, + "name": {"required": True}, + "email_address": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, **kwargs): """ - :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address registered for the Azure mobile app. + :keyword email_address: The email address registered for the Azure mobile app. Required. :paramtype email_address: str """ - super(AzureAppPushReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address -class AzureFunctionReceiver(msrest.serialization.Model): +class AzureFunctionReceiver(_serialization.Model): """An azure function receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the azure function receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the azure function receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar function_app_resource_id: Required. The azure resource id of the function app. + :ivar function_app_resource_id: The azure resource id of the function app. Required. :vartype function_app_resource_id: str - :ivar function_name: Required. The function name in the function app. + :ivar function_name: The function name in the function app. Required. :vartype function_name: str - :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :ivar http_trigger_url: The http trigger url where http request sent to. Required. :vartype http_trigger_url: str """ _validation = { - 'name': {'required': True}, - 'function_app_resource_id': {'required': True}, - 'function_name': {'required': True}, - 'http_trigger_url': {'required': True}, + "name": {"required": True}, + "function_app_resource_id": {"required": True}, + "function_name": {"required": True}, + "http_trigger_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, - 'function_name': {'key': 'functionName', 'type': 'str'}, - 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, + "function_name": {"key": "functionName", "type": "str"}, + "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, } def __init__( - self, - *, - name: str, - function_app_resource_id: str, - function_name: str, - http_trigger_url: str, - **kwargs + self, *, name: str, function_app_resource_id: str, function_name: str, http_trigger_url: str, **kwargs ): """ - :keyword name: Required. The name of the azure function receiver. Names must be unique across - all receivers within an action group. + :keyword name: The name of the azure function receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword function_app_resource_id: Required. The azure resource id of the function app. + :keyword function_app_resource_id: The azure resource id of the function app. Required. :paramtype function_app_resource_id: str - :keyword function_name: Required. The function name in the function app. + :keyword function_name: The function name in the function app. Required. :paramtype function_name: str - :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :keyword http_trigger_url: The http trigger url where http request sent to. Required. :paramtype http_trigger_url: str """ - super(AzureFunctionReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.function_app_resource_id = function_app_resource_id self.function_name = function_name self.http_trigger_url = http_trigger_url -class MultiMetricCriteria(msrest.serialization.Model): +class MultiMetricCriteria(_serialization.Model): """The types of conditions for a multi resource alert. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DynamicMetricCriteria, MetricCriteria. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DynamicMetricCriteria, MetricCriteria All required parameters must be populated in order to send to Azure. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar criterion_type: Required. Specifies the type of threshold criteria.Constant filled by - server. Known values are: "StaticThresholdCriterion", "DynamicThresholdCriterion". + :vartype additional_properties: dict[str, JSON] + :ivar criterion_type: Specifies the type of threshold criteria. Required. Known values are: + "StaticThresholdCriterion" and "DynamicThresholdCriterion". :vartype criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType - :ivar name: Required. Name of the criteria. + :ivar name: Name of the criteria. Required. :vartype name: str - :ivar metric_name: Required. Name of the metric. + :ivar metric_name: Name of the metric. Required. :vartype metric_name: str :ivar metric_namespace: Namespace of the metric. :vartype metric_namespace: str - :ivar time_aggregation: Required. the criteria time aggregation types. Known values are: - "Average", "Count", "Minimum", "Maximum", "Total". + :ivar time_aggregation: the criteria time aggregation types. Required. Known values are: + "Average", "Count", "Minimum", "Maximum", and "Total". :vartype time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum :ivar dimensions: List of dimension conditions. @@ -486,25 +467,28 @@ class MultiMetricCriteria(msrest.serialization.Model): """ _validation = { - 'criterion_type': {'required': True}, - 'name': {'required': True}, - 'metric_name': {'required': True}, - 'time_aggregation': {'required': True}, + "criterion_type": {"required": True}, + "name": {"required": True}, + "metric_name": {"required": True}, + "time_aggregation": {"required": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'criterion_type': {'key': 'criterionType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'skip_metric_validation': {'key': 'skipMetricValidation', 'type': 'bool'}, + "additional_properties": {"key": "", "type": "{object}"}, + "criterion_type": {"key": "criterionType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "metric_name": {"key": "metricName", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "skip_metric_validation": {"key": "skipMetricValidation", "type": "bool"}, } _subtype_map = { - 'criterion_type': {'DynamicThresholdCriterion': 'DynamicMetricCriteria', 'StaticThresholdCriterion': 'MetricCriteria'} + "criterion_type": { + "DynamicThresholdCriterion": "DynamicMetricCriteria", + "StaticThresholdCriterion": "MetricCriteria", + } } def __init__( @@ -513,7 +497,7 @@ def __init__( name: str, metric_name: str, time_aggregation: Union[str, "_models.AggregationTypeEnum"], - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, metric_namespace: Optional[str] = None, dimensions: Optional[List["_models.MetricDimension"]] = None, skip_metric_validation: Optional[bool] = None, @@ -522,15 +506,15 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] - :keyword name: Required. Name of the criteria. + :paramtype additional_properties: dict[str, JSON] + :keyword name: Name of the criteria. Required. :paramtype name: str - :keyword metric_name: Required. Name of the metric. + :keyword metric_name: Name of the metric. Required. :paramtype metric_name: str :keyword metric_namespace: Namespace of the metric. :paramtype metric_namespace: str - :keyword time_aggregation: Required. the criteria time aggregation types. Known values are: - "Average", "Count", "Minimum", "Maximum", "Total". + :keyword time_aggregation: the criteria time aggregation types. Required. Known values are: + "Average", "Count", "Minimum", "Maximum", and "Total". :paramtype time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum :keyword dimensions: List of dimension conditions. @@ -539,9 +523,9 @@ def __init__( yet emitted, by causing the metric validation to be skipped. :paramtype skip_metric_validation: bool """ - super(MultiMetricCriteria, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties - self.criterion_type = 'MultiMetricCriteria' # type: str + self.criterion_type = None # type: Optional[str] self.name = name self.metric_name = metric_name self.metric_namespace = metric_namespace @@ -550,25 +534,25 @@ def __init__( self.skip_metric_validation = skip_metric_validation -class DynamicMetricCriteria(MultiMetricCriteria): +class DynamicMetricCriteria(MultiMetricCriteria): # pylint: disable=too-many-instance-attributes """Criterion for dynamic threshold. All required parameters must be populated in order to send to Azure. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar criterion_type: Required. Specifies the type of threshold criteria.Constant filled by - server. Known values are: "StaticThresholdCriterion", "DynamicThresholdCriterion". + :vartype additional_properties: dict[str, JSON] + :ivar criterion_type: Specifies the type of threshold criteria. Required. Known values are: + "StaticThresholdCriterion" and "DynamicThresholdCriterion". :vartype criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType - :ivar name: Required. Name of the criteria. + :ivar name: Name of the criteria. Required. :vartype name: str - :ivar metric_name: Required. Name of the metric. + :ivar metric_name: Name of the metric. Required. :vartype metric_name: str :ivar metric_namespace: Namespace of the metric. :vartype metric_namespace: str - :ivar time_aggregation: Required. the criteria time aggregation types. Known values are: - "Average", "Count", "Minimum", "Maximum", "Total". + :ivar time_aggregation: the criteria time aggregation types. Required. Known values are: + "Average", "Count", "Minimum", "Maximum", and "Total". :vartype time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum :ivar dimensions: List of dimension conditions. @@ -576,16 +560,16 @@ class DynamicMetricCriteria(MultiMetricCriteria): :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. :vartype skip_metric_validation: bool - :ivar operator: Required. The operator used to compare the metric value against the threshold. - Known values are: "GreaterThan", "LessThan", "GreaterOrLessThan". + :ivar operator: The operator used to compare the metric value against the threshold. Required. + Known values are: "GreaterThan", "LessThan", and "GreaterOrLessThan". :vartype operator: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdOperator - :ivar alert_sensitivity: Required. The extent of deviation required to trigger an alert. This - will affect how tight the threshold is to the metric series pattern. Known values are: "Low", - "Medium", "High". + :ivar alert_sensitivity: The extent of deviation required to trigger an alert. This will affect + how tight the threshold is to the metric series pattern. Required. Known values are: "Low", + "Medium", and "High". :vartype alert_sensitivity: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdSensitivity - :ivar failing_periods: Required. The minimum number of violations required within the selected - lookback time window required to raise an alert. + :ivar failing_periods: The minimum number of violations required within the selected lookback + time window required to raise an alert. Required. :vartype failing_periods: ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdFailingPeriods :ivar ignore_data_before: Use this option to set the date from which to start learning the @@ -594,28 +578,28 @@ class DynamicMetricCriteria(MultiMetricCriteria): """ _validation = { - 'criterion_type': {'required': True}, - 'name': {'required': True}, - 'metric_name': {'required': True}, - 'time_aggregation': {'required': True}, - 'operator': {'required': True}, - 'alert_sensitivity': {'required': True}, - 'failing_periods': {'required': True}, + "criterion_type": {"required": True}, + "name": {"required": True}, + "metric_name": {"required": True}, + "time_aggregation": {"required": True}, + "operator": {"required": True}, + "alert_sensitivity": {"required": True}, + "failing_periods": {"required": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'criterion_type': {'key': 'criterionType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'skip_metric_validation': {'key': 'skipMetricValidation', 'type': 'bool'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'alert_sensitivity': {'key': 'alertSensitivity', 'type': 'str'}, - 'failing_periods': {'key': 'failingPeriods', 'type': 'DynamicThresholdFailingPeriods'}, - 'ignore_data_before': {'key': 'ignoreDataBefore', 'type': 'iso-8601'}, + "additional_properties": {"key": "", "type": "{object}"}, + "criterion_type": {"key": "criterionType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "metric_name": {"key": "metricName", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "skip_metric_validation": {"key": "skipMetricValidation", "type": "bool"}, + "operator": {"key": "operator", "type": "str"}, + "alert_sensitivity": {"key": "alertSensitivity", "type": "str"}, + "failing_periods": {"key": "failingPeriods", "type": "DynamicThresholdFailingPeriods"}, + "ignore_data_before": {"key": "ignoreDataBefore", "type": "iso-8601"}, } def __init__( @@ -627,7 +611,7 @@ def __init__( operator: Union[str, "_models.DynamicThresholdOperator"], alert_sensitivity: Union[str, "_models.DynamicThresholdSensitivity"], failing_periods: "_models.DynamicThresholdFailingPeriods", - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, metric_namespace: Optional[str] = None, dimensions: Optional[List["_models.MetricDimension"]] = None, skip_metric_validation: Optional[bool] = None, @@ -637,15 +621,15 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] - :keyword name: Required. Name of the criteria. + :paramtype additional_properties: dict[str, JSON] + :keyword name: Name of the criteria. Required. :paramtype name: str - :keyword metric_name: Required. Name of the metric. + :keyword metric_name: Name of the metric. Required. :paramtype metric_name: str :keyword metric_namespace: Namespace of the metric. :paramtype metric_namespace: str - :keyword time_aggregation: Required. the criteria time aggregation types. Known values are: - "Average", "Count", "Minimum", "Maximum", "Total". + :keyword time_aggregation: the criteria time aggregation types. Required. Known values are: + "Average", "Count", "Minimum", "Maximum", and "Total". :paramtype time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum :keyword dimensions: List of dimension conditions. @@ -653,157 +637,149 @@ def __init__( :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. :paramtype skip_metric_validation: bool - :keyword operator: Required. The operator used to compare the metric value against the - threshold. Known values are: "GreaterThan", "LessThan", "GreaterOrLessThan". + :keyword operator: The operator used to compare the metric value against the threshold. + Required. Known values are: "GreaterThan", "LessThan", and "GreaterOrLessThan". :paramtype operator: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdOperator - :keyword alert_sensitivity: Required. The extent of deviation required to trigger an alert. - This will affect how tight the threshold is to the metric series pattern. Known values are: - "Low", "Medium", "High". + :keyword alert_sensitivity: The extent of deviation required to trigger an alert. This will + affect how tight the threshold is to the metric series pattern. Required. Known values are: + "Low", "Medium", and "High". :paramtype alert_sensitivity: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdSensitivity - :keyword failing_periods: Required. The minimum number of violations required within the - selected lookback time window required to raise an alert. + :keyword failing_periods: The minimum number of violations required within the selected + lookback time window required to raise an alert. Required. :paramtype failing_periods: ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdFailingPeriods :keyword ignore_data_before: Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format). :paramtype ignore_data_before: ~datetime.datetime """ - super(DynamicMetricCriteria, self).__init__(additional_properties=additional_properties, name=name, metric_name=metric_name, metric_namespace=metric_namespace, time_aggregation=time_aggregation, dimensions=dimensions, skip_metric_validation=skip_metric_validation, **kwargs) - self.criterion_type = 'DynamicThresholdCriterion' # type: str + super().__init__( + additional_properties=additional_properties, + name=name, + metric_name=metric_name, + metric_namespace=metric_namespace, + time_aggregation=time_aggregation, + dimensions=dimensions, + skip_metric_validation=skip_metric_validation, + **kwargs + ) + self.criterion_type = "DynamicThresholdCriterion" # type: str self.operator = operator self.alert_sensitivity = alert_sensitivity self.failing_periods = failing_periods self.ignore_data_before = ignore_data_before -class DynamicThresholdFailingPeriods(msrest.serialization.Model): +class DynamicThresholdFailingPeriods(_serialization.Model): """The minimum number of violations required within the selected lookback time window required to raise an alert. All required parameters must be populated in order to send to Azure. - :ivar number_of_evaluation_periods: Required. The number of aggregated lookback points. The - lookback time window is calculated based on the aggregation granularity (windowSize) and the - selected number of aggregated points. + :ivar number_of_evaluation_periods: The number of aggregated lookback points. The lookback time + window is calculated based on the aggregation granularity (windowSize) and the selected number + of aggregated points. Required. :vartype number_of_evaluation_periods: float - :ivar min_failing_periods_to_alert: Required. The number of violations to trigger an alert. - Should be smaller or equal to numberOfEvaluationPeriods. + :ivar min_failing_periods_to_alert: The number of violations to trigger an alert. Should be + smaller or equal to numberOfEvaluationPeriods. Required. :vartype min_failing_periods_to_alert: float """ _validation = { - 'number_of_evaluation_periods': {'required': True}, - 'min_failing_periods_to_alert': {'required': True}, + "number_of_evaluation_periods": {"required": True}, + "min_failing_periods_to_alert": {"required": True}, } _attribute_map = { - 'number_of_evaluation_periods': {'key': 'numberOfEvaluationPeriods', 'type': 'float'}, - 'min_failing_periods_to_alert': {'key': 'minFailingPeriodsToAlert', 'type': 'float'}, + "number_of_evaluation_periods": {"key": "numberOfEvaluationPeriods", "type": "float"}, + "min_failing_periods_to_alert": {"key": "minFailingPeriodsToAlert", "type": "float"}, } - def __init__( - self, - *, - number_of_evaluation_periods: float, - min_failing_periods_to_alert: float, - **kwargs - ): + def __init__(self, *, number_of_evaluation_periods: float, min_failing_periods_to_alert: float, **kwargs): """ - :keyword number_of_evaluation_periods: Required. The number of aggregated lookback points. The - lookback time window is calculated based on the aggregation granularity (windowSize) and the - selected number of aggregated points. + :keyword number_of_evaluation_periods: The number of aggregated lookback points. The lookback + time window is calculated based on the aggregation granularity (windowSize) and the selected + number of aggregated points. Required. :paramtype number_of_evaluation_periods: float - :keyword min_failing_periods_to_alert: Required. The number of violations to trigger an alert. - Should be smaller or equal to numberOfEvaluationPeriods. + :keyword min_failing_periods_to_alert: The number of violations to trigger an alert. Should be + smaller or equal to numberOfEvaluationPeriods. Required. :paramtype min_failing_periods_to_alert: float """ - super(DynamicThresholdFailingPeriods, self).__init__(**kwargs) + super().__init__(**kwargs) self.number_of_evaluation_periods = number_of_evaluation_periods self.min_failing_periods_to_alert = min_failing_periods_to_alert -class EmailReceiver(msrest.serialization.Model): +class EmailReceiver(_serialization.Model): """An email receiver. Variables are only 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 name: Required. The name of the email receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the email receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar email_address: Required. The email address of this receiver. + :ivar email_address: The email address of this receiver. Required. :vartype email_address: str :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - "Disabled". + and "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_03_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "email_address": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, **kwargs): """ - :keyword name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the email receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address of this receiver. + :keyword email_address: The email address of this receiver. Required. :paramtype email_address: str """ - super(EmailReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address self.status = None -class EnableRequest(msrest.serialization.Model): +class EnableRequest(_serialization.Model): """Describes a receiver that should be resubscribed. All required parameters must be populated in order to send to Azure. - :ivar receiver_name: Required. The name of the receiver to resubscribe. + :ivar receiver_name: The name of the receiver to resubscribe. Required. :vartype receiver_name: str """ _validation = { - 'receiver_name': {'required': True}, + "receiver_name": {"required": True}, } _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, + "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__( - self, - *, - receiver_name: str, - **kwargs - ): + def __init__(self, *, receiver_name: str, **kwargs): """ - :keyword receiver_name: Required. The name of the receiver to resubscribe. + :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str """ - super(EnableRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.receiver_name = receiver_name -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -813,92 +789,81 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ItsmReceiver(msrest.serialization.Model): +class ItsmReceiver(_serialization.Model): """An Itsm receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar workspace_id: Required. OMS LA instance identifier. + :ivar workspace_id: OMS LA instance identifier. Required. :vartype workspace_id: str - :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined - in above workspace. + :ivar connection_id: Unique identification of ITSM connection among multiple defined in above + workspace. Required. :vartype connection_id: str - :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :vartype ticket_configuration: str - :ivar region: Required. Region in which workspace resides. Supported + :ivar region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :vartype region: str """ _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, + "name": {"required": True}, + "workspace_id": {"required": True}, + "connection_id": {"required": True}, + "ticket_configuration": {"required": True}, + "region": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "connection_id": {"key": "connectionId", "type": "str"}, + "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, + "region": {"key": "region", "type": "str"}, } def __init__( - self, - *, - name: str, - workspace_id: str, - connection_id: str, - ticket_configuration: str, - region: str, - **kwargs + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs ): """ - :keyword name: Required. The name of the Itsm receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword workspace_id: Required. OMS LA instance identifier. + :keyword workspace_id: OMS LA instance identifier. Required. :paramtype workspace_id: str - :keyword connection_id: Required. Unique identification of ITSM connection among multiple - defined in above workspace. + :keyword connection_id: Unique identification of ITSM connection among multiple defined in + above workspace. Required. :paramtype connection_id: str - :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :paramtype ticket_configuration: str - :keyword region: Required. Region in which workspace resides. Supported + :keyword region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :paramtype region: str """ - super(ItsmReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.workspace_id = workspace_id self.connection_id = connection_id @@ -906,56 +871,49 @@ def __init__( self.region = region -class LogicAppReceiver(msrest.serialization.Model): +class LogicAppReceiver(_serialization.Model): """A logic app receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar resource_id: Required. The azure resource id of the logic app receiver. + :ivar resource_id: The azure resource id of the logic app receiver. Required. :vartype resource_id: str - :ivar callback_url: Required. The callback url where http request sent to. + :ivar callback_url: The callback url where http request sent to. Required. :vartype callback_url: str """ _validation = { - 'name': {'required': True}, - 'resource_id': {'required': True}, - 'callback_url': {'required': True}, + "name": {"required": True}, + "resource_id": {"required": True}, + "callback_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "callback_url": {"key": "callbackUrl", "type": "str"}, } - def __init__( - self, - *, - name: str, - resource_id: str, - callback_url: str, - **kwargs - ): + def __init__(self, *, name: str, resource_id: str, callback_url: str, **kwargs): """ - :keyword name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword resource_id: Required. The azure resource id of the logic app receiver. + :keyword resource_id: The azure resource id of the logic app receiver. Required. :paramtype resource_id: str - :keyword callback_url: Required. The callback url where http request sent to. + :keyword callback_url: The callback url where http request sent to. Required. :paramtype callback_url: str """ - super(LogicAppReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.resource_id = resource_id self.callback_url = callback_url -class MetricAlertAction(msrest.serialization.Model): +class MetricAlertAction(_serialization.Model): """An alert action. :ivar action_group_id: the id of the action group to use. @@ -966,16 +924,12 @@ class MetricAlertAction(msrest.serialization.Model): """ _attribute_map = { - 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, - 'web_hook_properties': {'key': 'webHookProperties', 'type': '{str}'}, + "action_group_id": {"key": "actionGroupId", "type": "str"}, + "web_hook_properties": {"key": "webHookProperties", "type": "{str}"}, } def __init__( - self, - *, - action_group_id: Optional[str] = None, - web_hook_properties: Optional[Dict[str, str]] = None, - **kwargs + self, *, action_group_id: Optional[str] = None, web_hook_properties: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword action_group_id: the id of the action group to use. @@ -984,56 +938,56 @@ def __init__( appended to the alert payload sent as input to the webhook. :paramtype web_hook_properties: dict[str, str] """ - super(MetricAlertAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.action_group_id = action_group_id self.web_hook_properties = web_hook_properties -class MetricAlertCriteria(msrest.serialization.Model): +class MetricAlertCriteria(_serialization.Model): """The rule criteria that defines the conditions of the alert rule. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: MetricAlertMultipleResourceMultipleMetricCriteria, MetricAlertSingleResourceMultipleMetricCriteria, WebtestLocationAvailabilityCriteria. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + MetricAlertMultipleResourceMultipleMetricCriteria, + MetricAlertSingleResourceMultipleMetricCriteria, WebtestLocationAvailabilityCriteria All required parameters must be populated in order to send to Azure. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. - Known values are: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", - "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + :vartype additional_properties: dict[str, JSON] + :ivar odata_type: specifies the type of the alert criteria. Required. Known values are: + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", and "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, + "additional_properties": {"key": "", "type": "{object}"}, + "odata_type": {"key": "odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria': 'MetricAlertMultipleResourceMultipleMetricCriteria', 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria': 'MetricAlertSingleResourceMultipleMetricCriteria', 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria': 'WebtestLocationAvailabilityCriteria'} + "odata_type": { + "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria": "MetricAlertMultipleResourceMultipleMetricCriteria", + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria": "MetricAlertSingleResourceMultipleMetricCriteria", + "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria": "WebtestLocationAvailabilityCriteria", + } } - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - **kwargs - ): + def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] """ - super(MetricAlertCriteria, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties - self.odata_type = 'MetricAlertCriteria' # type: str + self.odata_type = None # type: Optional[str] class MetricAlertMultipleResourceMultipleMetricCriteria(MetricAlertCriteria): @@ -1043,10 +997,10 @@ class MetricAlertMultipleResourceMultipleMetricCriteria(MetricAlertCriteria): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. - Known values are: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", - "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + :vartype additional_properties: dict[str, JSON] + :ivar odata_type: specifies the type of the alert criteria. Required. Known values are: + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", and "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype :ivar all_of: the list of multiple metric criteria for this 'all of' operation. @@ -1054,35 +1008,35 @@ class MetricAlertMultipleResourceMultipleMetricCriteria(MetricAlertCriteria): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'all_of': {'key': 'allOf', 'type': '[MultiMetricCriteria]'}, + "additional_properties": {"key": "", "type": "{object}"}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "all_of": {"key": "allOf", "type": "[MultiMetricCriteria]"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, all_of: Optional[List["_models.MultiMetricCriteria"]] = None, **kwargs ): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword all_of: the list of multiple metric criteria for this 'all of' operation. :paramtype all_of: list[~$(python-base-namespace).v2018_03_01.models.MultiMetricCriteria] """ - super(MetricAlertMultipleResourceMultipleMetricCriteria, self).__init__(additional_properties=additional_properties, **kwargs) - self.odata_type = 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' # type: str + super().__init__(additional_properties=additional_properties, **kwargs) + self.odata_type = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" # type: str self.all_of = all_of -class MetricAlertResource(Resource): +class MetricAlertResource(Resource): # pylint: disable=too-many-instance-attributes """The metric alert resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1095,24 +1049,24 @@ class MetricAlertResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar description: the description of the metric alert that will be included in the alert email. :vartype description: str - :ivar severity: Required. Alert severity {0, 1, 2, 3, 4}. + :ivar severity: Alert severity {0, 1, 2, 3, 4}. Required. :vartype severity: int - :ivar enabled: Required. the flag that indicates whether the metric alert is enabled. + :ivar enabled: the flag that indicates whether the metric alert is enabled. Required. :vartype enabled: bool - :ivar scopes: Required. the list of resource id's that this metric alert is scoped to. + :ivar scopes: the list of resource id's that this metric alert is scoped to. Required. :vartype scopes: list[str] - :ivar evaluation_frequency: Required. how often the metric alert is evaluated represented in - ISO 8601 duration format. + :ivar evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 + duration format. Required. :vartype evaluation_frequency: ~datetime.timedelta - :ivar window_size: Required. the period of time (in ISO 8601 duration format) that is used to - monitor alert activity based on the threshold. + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. Required. :vartype window_size: ~datetime.timedelta :ivar target_resource_type: the resource type of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than @@ -1122,7 +1076,7 @@ class MetricAlertResource(Resource): created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. :vartype target_resource_region: str - :ivar criteria: Required. defines the specific alert criteria information. + :ivar criteria: defines the specific alert criteria information. Required. :vartype criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria :ivar auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. The default is true. @@ -1137,39 +1091,39 @@ class MetricAlertResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'severity': {'required': True}, - 'enabled': {'required': True}, - 'scopes': {'required': True}, - 'evaluation_frequency': {'required': True}, - 'window_size': {'required': True}, - 'criteria': {'required': True}, - 'last_updated_time': {'readonly': True}, - 'is_migrated': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "severity": {"required": True}, + "enabled": {"required": True}, + "scopes": {"required": True}, + "evaluation_frequency": {"required": True}, + "window_size": {"required": True}, + "criteria": {"required": True}, + "last_updated_time": {"readonly": True}, + "is_migrated": {"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}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'int'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'evaluation_frequency': {'key': 'properties.evaluationFrequency', 'type': 'duration'}, - 'window_size': {'key': 'properties.windowSize', 'type': 'duration'}, - 'target_resource_type': {'key': 'properties.targetResourceType', 'type': 'str'}, - 'target_resource_region': {'key': 'properties.targetResourceRegion', 'type': 'str'}, - 'criteria': {'key': 'properties.criteria', 'type': 'MetricAlertCriteria'}, - 'auto_mitigate': {'key': 'properties.autoMitigate', 'type': 'bool'}, - 'actions': {'key': 'properties.actions', 'type': '[MetricAlertAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - 'is_migrated': {'key': 'properties.isMigrated', 'type': 'bool'}, + "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}"}, + "description": {"key": "properties.description", "type": "str"}, + "severity": {"key": "properties.severity", "type": "int"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "scopes": {"key": "properties.scopes", "type": "[str]"}, + "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, + "window_size": {"key": "properties.windowSize", "type": "duration"}, + "target_resource_type": {"key": "properties.targetResourceType", "type": "str"}, + "target_resource_region": {"key": "properties.targetResourceRegion", "type": "str"}, + "criteria": {"key": "properties.criteria", "type": "MetricAlertCriteria"}, + "auto_mitigate": {"key": "properties.autoMitigate", "type": "bool"}, + "actions": {"key": "properties.actions", "type": "[MetricAlertAction]"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, + "is_migrated": {"key": "properties.isMigrated", "type": "bool"}, } def __init__( @@ -1191,24 +1145,24 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword description: the description of the metric alert that will be included in the alert email. :paramtype description: str - :keyword severity: Required. Alert severity {0, 1, 2, 3, 4}. + :keyword severity: Alert severity {0, 1, 2, 3, 4}. Required. :paramtype severity: int - :keyword enabled: Required. the flag that indicates whether the metric alert is enabled. + :keyword enabled: the flag that indicates whether the metric alert is enabled. Required. :paramtype enabled: bool - :keyword scopes: Required. the list of resource id's that this metric alert is scoped to. + :keyword scopes: the list of resource id's that this metric alert is scoped to. Required. :paramtype scopes: list[str] - :keyword evaluation_frequency: Required. how often the metric alert is evaluated represented in - ISO 8601 duration format. + :keyword evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 + duration format. Required. :paramtype evaluation_frequency: ~datetime.timedelta - :keyword window_size: Required. the period of time (in ISO 8601 duration format) that is used - to monitor alert activity based on the threshold. + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. Required. :paramtype window_size: ~datetime.timedelta :keyword target_resource_type: the resource type of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more @@ -1218,7 +1172,7 @@ def __init__( created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. :paramtype target_resource_region: str - :keyword criteria: Required. defines the specific alert criteria information. + :keyword criteria: defines the specific alert criteria information. Required. :paramtype criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria :keyword auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. The default is true. @@ -1227,7 +1181,7 @@ def __init__( and when an alert condition is resolved. :paramtype actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] """ - super(MetricAlertResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.description = description self.severity = severity self.enabled = enabled @@ -1243,7 +1197,7 @@ def __init__( self.is_migrated = None -class MetricAlertResourceCollection(msrest.serialization.Model): +class MetricAlertResourceCollection(_serialization.Model): """Represents a collection of alert rule resources. :ivar value: the values for the alert rule resources. @@ -1251,29 +1205,24 @@ class MetricAlertResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricAlertResource]'}, + "value": {"key": "value", "type": "[MetricAlertResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.MetricAlertResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.MetricAlertResource"]] = None, **kwargs): """ :keyword value: the values for the alert rule resources. :paramtype value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertResource] """ - super(MetricAlertResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class MetricAlertResourcePatch(msrest.serialization.Model): +class MetricAlertResourcePatch(_serialization.Model): # pylint: disable=too-many-instance-attributes """The metric alert resource for patch operations. Variables are only populated by the server, and will be ignored when sending a request. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar description: the description of the metric alert that will be included in the alert email. @@ -1311,25 +1260,25 @@ class MetricAlertResourcePatch(msrest.serialization.Model): """ _validation = { - 'last_updated_time': {'readonly': True}, - 'is_migrated': {'readonly': True}, + "last_updated_time": {"readonly": True}, + "is_migrated": {"readonly": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'int'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'evaluation_frequency': {'key': 'properties.evaluationFrequency', 'type': 'duration'}, - 'window_size': {'key': 'properties.windowSize', 'type': 'duration'}, - 'target_resource_type': {'key': 'properties.targetResourceType', 'type': 'str'}, - 'target_resource_region': {'key': 'properties.targetResourceRegion', 'type': 'str'}, - 'criteria': {'key': 'properties.criteria', 'type': 'MetricAlertCriteria'}, - 'auto_mitigate': {'key': 'properties.autoMitigate', 'type': 'bool'}, - 'actions': {'key': 'properties.actions', 'type': '[MetricAlertAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - 'is_migrated': {'key': 'properties.isMigrated', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "severity": {"key": "properties.severity", "type": "int"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "scopes": {"key": "properties.scopes", "type": "[str]"}, + "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, + "window_size": {"key": "properties.windowSize", "type": "duration"}, + "target_resource_type": {"key": "properties.targetResourceType", "type": "str"}, + "target_resource_region": {"key": "properties.targetResourceRegion", "type": "str"}, + "criteria": {"key": "properties.criteria", "type": "MetricAlertCriteria"}, + "auto_mitigate": {"key": "properties.autoMitigate", "type": "bool"}, + "actions": {"key": "properties.actions", "type": "[MetricAlertAction]"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, + "is_migrated": {"key": "properties.isMigrated", "type": "bool"}, } def __init__( @@ -1350,7 +1299,7 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword description: the description of the metric alert that will be included in the alert email. @@ -1382,7 +1331,7 @@ def __init__( and when an alert condition is resolved. :paramtype actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] """ - super(MetricAlertResourcePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.description = description self.severity = severity @@ -1406,10 +1355,10 @@ class MetricAlertSingleResourceMultipleMetricCriteria(MetricAlertCriteria): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. - Known values are: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", - "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + :vartype additional_properties: dict[str, JSON] + :ivar odata_type: specifies the type of the alert criteria. Required. Known values are: + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", and "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype :ivar all_of: The list of metric criteria for this 'all of' operation. @@ -1417,35 +1366,35 @@ class MetricAlertSingleResourceMultipleMetricCriteria(MetricAlertCriteria): """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'all_of': {'key': 'allOf', 'type': '[MetricCriteria]'}, + "additional_properties": {"key": "", "type": "{object}"}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "all_of": {"key": "allOf", "type": "[MetricCriteria]"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, all_of: Optional[List["_models.MetricCriteria"]] = None, **kwargs ): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword all_of: The list of metric criteria for this 'all of' operation. :paramtype all_of: list[~$(python-base-namespace).v2018_03_01.models.MetricCriteria] """ - super(MetricAlertSingleResourceMultipleMetricCriteria, self).__init__(additional_properties=additional_properties, **kwargs) - self.odata_type = 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' # type: str + super().__init__(additional_properties=additional_properties, **kwargs) + self.odata_type = "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria" # type: str self.all_of = all_of -class MetricAlertStatus(msrest.serialization.Model): +class MetricAlertStatus(_serialization.Model): """An alert status. :ivar name: The status name. @@ -1459,17 +1408,17 @@ class MetricAlertStatus(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'MetricAlertStatusProperties'}, + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "MetricAlertStatusProperties"}, } def __init__( self, *, name: Optional[str] = None, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, properties: Optional["_models.MetricAlertStatusProperties"] = None, **kwargs @@ -1484,14 +1433,14 @@ def __init__( :keyword properties: The alert status properties of the metric alert status. :paramtype properties: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusProperties """ - super(MetricAlertStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.id = id self.type = type self.properties = properties -class MetricAlertStatusCollection(msrest.serialization.Model): +class MetricAlertStatusCollection(_serialization.Model): """Represents a collection of alert rule resources. :ivar value: the values for the alert rule resources. @@ -1499,24 +1448,19 @@ class MetricAlertStatusCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricAlertStatus]'}, + "value": {"key": "value", "type": "[MetricAlertStatus]"}, } - def __init__( - self, - *, - value: Optional[List["_models.MetricAlertStatus"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.MetricAlertStatus"]] = None, **kwargs): """ :keyword value: the values for the alert rule resources. :paramtype value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertStatus] """ - super(MetricAlertStatusCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class MetricAlertStatusProperties(msrest.serialization.Model): +class MetricAlertStatusProperties(_serialization.Model): """An alert status properties. :ivar dimensions: An object describing the type of the dimensions. @@ -1528,9 +1472,9 @@ class MetricAlertStatusProperties(msrest.serialization.Model): """ _attribute_map = { - 'dimensions': {'key': 'dimensions', 'type': '{str}'}, - 'status': {'key': 'status', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "dimensions": {"key": "dimensions", "type": "{str}"}, + "status": {"key": "status", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } def __init__( @@ -1549,7 +1493,7 @@ def __init__( :keyword timestamp: UTC time when the status was checked. :paramtype timestamp: ~datetime.datetime """ - super(MetricAlertStatusProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.dimensions = dimensions self.status = status self.timestamp = timestamp @@ -1562,18 +1506,18 @@ class MetricCriteria(MultiMetricCriteria): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar criterion_type: Required. Specifies the type of threshold criteria.Constant filled by - server. Known values are: "StaticThresholdCriterion", "DynamicThresholdCriterion". + :vartype additional_properties: dict[str, JSON] + :ivar criterion_type: Specifies the type of threshold criteria. Required. Known values are: + "StaticThresholdCriterion" and "DynamicThresholdCriterion". :vartype criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType - :ivar name: Required. Name of the criteria. + :ivar name: Name of the criteria. Required. :vartype name: str - :ivar metric_name: Required. Name of the metric. + :ivar metric_name: Name of the metric. Required. :vartype metric_name: str :ivar metric_namespace: Namespace of the metric. :vartype metric_namespace: str - :ivar time_aggregation: Required. the criteria time aggregation types. Known values are: - "Average", "Count", "Minimum", "Maximum", "Total". + :ivar time_aggregation: the criteria time aggregation types. Required. Known values are: + "Average", "Count", "Minimum", "Maximum", and "Total". :vartype time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum :ivar dimensions: List of dimension conditions. @@ -1581,33 +1525,33 @@ class MetricCriteria(MultiMetricCriteria): :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. :vartype skip_metric_validation: bool - :ivar operator: Required. the criteria operator. Known values are: "Equals", "GreaterThan", - "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :ivar operator: the criteria operator. Required. Known values are: "Equals", "GreaterThan", + "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2018_03_01.models.Operator - :ivar threshold: Required. the criteria threshold value that activates the alert. + :ivar threshold: the criteria threshold value that activates the alert. Required. :vartype threshold: float """ _validation = { - 'criterion_type': {'required': True}, - 'name': {'required': True}, - 'metric_name': {'required': True}, - 'time_aggregation': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, + "criterion_type": {"required": True}, + "name": {"required": True}, + "metric_name": {"required": True}, + "time_aggregation": {"required": True}, + "operator": {"required": True}, + "threshold": {"required": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'criterion_type': {'key': 'criterionType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'skip_metric_validation': {'key': 'skipMetricValidation', 'type': 'bool'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, + "additional_properties": {"key": "", "type": "{object}"}, + "criterion_type": {"key": "criterionType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "metric_name": {"key": "metricName", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "skip_metric_validation": {"key": "skipMetricValidation", "type": "bool"}, + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, } def __init__( @@ -1618,7 +1562,7 @@ def __init__( time_aggregation: Union[str, "_models.AggregationTypeEnum"], operator: Union[str, "_models.Operator"], threshold: float, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, metric_namespace: Optional[str] = None, dimensions: Optional[List["_models.MetricDimension"]] = None, skip_metric_validation: Optional[bool] = None, @@ -1627,15 +1571,15 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] - :keyword name: Required. Name of the criteria. + :paramtype additional_properties: dict[str, JSON] + :keyword name: Name of the criteria. Required. :paramtype name: str - :keyword metric_name: Required. Name of the metric. + :keyword metric_name: Name of the metric. Required. :paramtype metric_name: str :keyword metric_namespace: Namespace of the metric. :paramtype metric_namespace: str - :keyword time_aggregation: Required. the criteria time aggregation types. Known values are: - "Average", "Count", "Minimum", "Maximum", "Total". + :keyword time_aggregation: the criteria time aggregation types. Required. Known values are: + "Average", "Count", "Minimum", "Maximum", and "Total". :paramtype time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum :keyword dimensions: List of dimension conditions. @@ -1643,209 +1587,191 @@ def __init__( :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. :paramtype skip_metric_validation: bool - :keyword operator: Required. the criteria operator. Known values are: "Equals", "GreaterThan", - "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :keyword operator: the criteria operator. Required. Known values are: "Equals", "GreaterThan", + "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2018_03_01.models.Operator - :keyword threshold: Required. the criteria threshold value that activates the alert. + :keyword threshold: the criteria threshold value that activates the alert. Required. :paramtype threshold: float """ - super(MetricCriteria, self).__init__(additional_properties=additional_properties, name=name, metric_name=metric_name, metric_namespace=metric_namespace, time_aggregation=time_aggregation, dimensions=dimensions, skip_metric_validation=skip_metric_validation, **kwargs) - self.criterion_type = 'StaticThresholdCriterion' # type: str + super().__init__( + additional_properties=additional_properties, + name=name, + metric_name=metric_name, + metric_namespace=metric_namespace, + time_aggregation=time_aggregation, + dimensions=dimensions, + skip_metric_validation=skip_metric_validation, + **kwargs + ) + self.criterion_type = "StaticThresholdCriterion" # type: str self.operator = operator self.threshold = threshold -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """Specifies a metric dimension. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the dimension. + :ivar name: Name of the dimension. Required. :vartype name: str - :ivar operator: Required. the dimension operator. Only 'Include' and 'Exclude' are supported. + :ivar operator: the dimension operator. Only 'Include' and 'Exclude' are supported. Required. :vartype operator: str - :ivar values: Required. list of dimension values. + :ivar values: list of dimension values. Required. :vartype values: list[str] """ _validation = { - 'name': {'required': True}, - 'operator': {'required': True}, - 'values': {'required': True}, + "name": {"required": True}, + "operator": {"required": True}, + "values": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "operator": {"key": "operator", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, } - def __init__( - self, - *, - name: str, - operator: str, - values: List[str], - **kwargs - ): + def __init__(self, *, name: str, operator: str, values: List[str], **kwargs): """ - :keyword name: Required. Name of the dimension. + :keyword name: Name of the dimension. Required. :paramtype name: str - :keyword operator: Required. the dimension operator. Only 'Include' and 'Exclude' are - supported. + :keyword operator: the dimension operator. Only 'Include' and 'Exclude' are supported. + Required. :paramtype operator: str - :keyword values: Required. list of dimension values. + :keyword values: list of dimension values. Required. :paramtype values: list[str] """ - super(MetricDimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.operator = operator self.values = values -class SmsReceiver(msrest.serialization.Model): +class SmsReceiver(_serialization.Model): """An SMS receiver. Variables are only 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 name: Required. The name of the SMS receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the SMS receiver. + :ivar country_code: The country code of the SMS receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the SMS receiver. + :ivar phone_number: The phone number of the SMS receiver. Required. :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_03_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the SMS receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the SMS receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the SMS receiver. + :keyword country_code: The country code of the SMS receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the SMS receiver. + :keyword phone_number: The phone number of the SMS receiver. Required. :paramtype phone_number: str """ - super(SmsReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number self.status = None -class VoiceReceiver(msrest.serialization.Model): +class VoiceReceiver(_serialization.Model): """A voice receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the voice receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the voice receiver. + :ivar country_code: The country code of the voice receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the voice receiver. + :ivar phone_number: The phone number of the voice receiver. Required. :vartype phone_number: str """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the voice receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the voice receiver. + :keyword country_code: The country code of the voice receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the voice receiver. + :keyword phone_number: The phone number of the voice receiver. Required. :paramtype phone_number: str """ - super(VoiceReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number -class WebhookReceiver(msrest.serialization.Model): +class WebhookReceiver(_serialization.Model): """A webhook receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the webhook receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar service_uri: Required. The URI where webhooks should be sent. + :ivar service_uri: The URI where webhooks should be sent. Required. :vartype service_uri: str """ _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, + "name": {"required": True}, + "service_uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, } - def __init__( - self, - *, - name: str, - service_uri: str, - **kwargs - ): + def __init__(self, *, name: str, service_uri: str, **kwargs): """ - :keyword name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the webhook receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword service_uri: Required. The URI where webhooks should be sent. + :keyword service_uri: The URI where webhooks should be sent. Required. :paramtype service_uri: str """ - super(WebhookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.service_uri = service_uri @@ -1857,33 +1783,33 @@ class WebtestLocationAvailabilityCriteria(MetricAlertCriteria): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. - Known values are: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", - "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + :vartype additional_properties: dict[str, JSON] + :ivar odata_type: specifies the type of the alert criteria. Required. Known values are: + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", and "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype - :ivar web_test_id: Required. The Application Insights web test Id. + :ivar web_test_id: The Application Insights web test Id. Required. :vartype web_test_id: str - :ivar component_id: Required. The Application Insights resource Id. + :ivar component_id: The Application Insights resource Id. Required. :vartype component_id: str - :ivar failed_location_count: Required. The number of failed locations. + :ivar failed_location_count: The number of failed locations. Required. :vartype failed_location_count: float """ _validation = { - 'odata_type': {'required': True}, - 'web_test_id': {'required': True}, - 'component_id': {'required': True}, - 'failed_location_count': {'required': True}, + "odata_type": {"required": True}, + "web_test_id": {"required": True}, + "component_id": {"required": True}, + "failed_location_count": {"required": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'web_test_id': {'key': 'webTestId', 'type': 'str'}, - 'component_id': {'key': 'componentId', 'type': 'str'}, - 'failed_location_count': {'key': 'failedLocationCount', 'type': 'float'}, + "additional_properties": {"key": "", "type": "{object}"}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "web_test_id": {"key": "webTestId", "type": "str"}, + "component_id": {"key": "componentId", "type": "str"}, + "failed_location_count": {"key": "failedLocationCount", "type": "float"}, } def __init__( @@ -1892,22 +1818,22 @@ def __init__( web_test_id: str, component_id: str, failed_location_count: float, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, **kwargs ): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] - :keyword web_test_id: Required. The Application Insights web test Id. + :paramtype additional_properties: dict[str, JSON] + :keyword web_test_id: The Application Insights web test Id. Required. :paramtype web_test_id: str - :keyword component_id: Required. The Application Insights resource Id. + :keyword component_id: The Application Insights resource Id. Required. :paramtype component_id: str - :keyword failed_location_count: Required. The number of failed locations. + :keyword failed_location_count: The number of failed locations. Required. :paramtype failed_location_count: float """ - super(WebtestLocationAvailabilityCriteria, self).__init__(additional_properties=additional_properties, **kwargs) - self.odata_type = 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria' # type: str + super().__init__(additional_properties=additional_properties, **kwargs) + self.odata_type = "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" # type: str self.web_test_id = web_test_id self.component_id = component_id self.failed_location_count = failed_location_count diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py index 91f4c47b665b..2310232dcd2f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py @@ -11,8 +11,7 @@ class AggregationTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the criteria time aggregation types. - """ + """the criteria time aggregation types.""" AVERAGE = "Average" COUNT = "Count" @@ -20,21 +19,22 @@ class AggregationTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): MAXIMUM = "Maximum" TOTAL = "Total" + class CriterionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the type of threshold criteria - """ + """Specifies the type of threshold criteria.""" STATIC_THRESHOLD_CRITERION = "StaticThresholdCriterion" DYNAMIC_THRESHOLD_CRITERION = "DynamicThresholdCriterion" + class DynamicThresholdOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operator used to compare the metric value against the threshold. - """ + """The operator used to compare the metric value against the threshold.""" GREATER_THAN = "GreaterThan" LESS_THAN = "LessThan" GREATER_OR_LESS_THAN = "GreaterOrLessThan" + class DynamicThresholdSensitivity(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. @@ -44,17 +44,23 @@ class DynamicThresholdSensitivity(str, Enum, metaclass=CaseInsensitiveEnumMeta): MEDIUM = "Medium" HIGH = "High" + class Odatatype(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """specifies the type of the alert criteria. - """ + """specifies the type of the alert criteria.""" + + MICROSOFT_AZURE_MONITOR_SINGLE_RESOURCE_MULTIPLE_METRIC_CRITERIA = ( + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria" + ) + MICROSOFT_AZURE_MONITOR_MULTIPLE_RESOURCE_MULTIPLE_METRIC_CRITERIA = ( + "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" + ) + MICROSOFT_AZURE_MONITOR_WEBTEST_LOCATION_AVAILABILITY_CRITERIA = ( + "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" + ) - MICROSOFT_AZURE_MONITOR_SINGLE_RESOURCE_MULTIPLE_METRIC_CRITERIA = "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria" - MICROSOFT_AZURE_MONITOR_MULTIPLE_RESOURCE_MULTIPLE_METRIC_CRITERIA = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" - MICROSOFT_AZURE_MONITOR_WEBTEST_LOCATION_AVAILABILITY_CRITERIA = "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" class Operator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the criteria operator. - """ + """the criteria operator.""" EQUALS = "Equals" GREATER_THAN = "GreaterThan" @@ -62,6 +68,7 @@ class Operator(str, Enum, metaclass=CaseInsensitiveEnumMeta): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/__init__.py index abf34ef0b771..08442f934dbe 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/__init__.py @@ -13,10 +13,11 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', - 'MetricAlertsOperations', - 'MetricAlertsStatusOperations', + "ActionGroupsOperations", + "MetricAlertsOperations", + "MetricAlertsStatusOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py index 97eee198d4fb..0e512e1753b3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,288 +25,243 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.ActionGroupResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - action_group_name: str, - *, - json: Optional[_models.ActionGroupPatchBody] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_id_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_enable_receiver_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.EnableRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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 ActionGroupsOperations: """ @@ -322,41 +282,105 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -365,7 +389,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -373,10 +398,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -385,55 +409,47 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -441,10 +457,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,52 +467,46 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -505,10 +514,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -519,52 +527,118 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2018_03_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2018_03_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -572,10 +646,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -583,46 +656,41 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -630,14 +698,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -653,10 +718,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -667,46 +730,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -714,15 +773,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -738,10 +793,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -752,47 +805,112 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore - @distributed_trace + @overload def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2018_03_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2018_03_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -801,7 +919,8 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -809,10 +928,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -823,5 +941,4 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py index 3c7864c95469..5d27452e22d7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +25,201 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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( - subscription_id: str, - resource_group_name: str, - rule_name: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - rule_name: str, - *, - json: Optional[_models.MetricAlertResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_update_request( - subscription_id: str, - resource_group_name: str, - rule_name: str, - *, - json: Optional[_models.MetricAlertResourcePatch] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _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_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - subscription_id: str, - resource_group_name: str, - rule_name: str, - **kwargs: Any -) -> HttpRequest: + _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_delete_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MetricAlertsOperations: """ @@ -277,38 +240,32 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - **kwargs: Any - ) -> Iterable[_models.MetricAlertResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.MetricAlertResource"]: """Retrieve alert rule definitions in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricAlertResourceCollection or the result of - cls(response) + :return: An iterator like instance of either MetricAlertResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -316,14 +273,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -339,10 +293,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -353,47 +305,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.MetricAlertResourceCollection]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.MetricAlertResource"]: """Retrieve alert rule definitions in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 MetricAlertResourceCollection or the result of - cls(response) + :return: An iterator like instance of either MetricAlertResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -401,15 +348,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -425,10 +368,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -439,48 +380,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.MetricAlertResource: + def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.MetricAlertResource: """Retrieve an alert rule definition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource, or the result of cls(response) + :return: MetricAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -488,10 +420,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -499,59 +430,124 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MetricAlertResource', pipeline_response) + deserialized = self._deserialize("MetricAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, rule_name: str, parameters: _models.MetricAlertResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.MetricAlertResource: """Create or update an metric alert definition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. + :param parameters: The parameters of the rule to create or update. Required. :type parameters: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: MetricAlertResource, or the result of cls(response) + :return: MetricAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetricAlertResource: + """Create or update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. 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: MetricAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.MetricAlertResource, IO], + **kwargs: Any + ) -> _models.MetricAlertResource: + """Create or update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a model type or a + IO type. Required. + :type parameters: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: MetricAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResource] - _json = self._serialize.body(parameters, 'MetricAlertResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MetricAlertResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -559,10 +555,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -570,59 +565,124 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MetricAlertResource', pipeline_response) + deserialized = self._deserialize("MetricAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, rule_name: str, parameters: _models.MetricAlertResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.MetricAlertResource: """Update an metric alert definition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to update. + :param parameters: The parameters of the rule to update. Required. :type parameters: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: MetricAlertResource, or the result of cls(response) + :return: MetricAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetricAlertResource: + """Update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. 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: MetricAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.MetricAlertResourcePatch, IO], + **kwargs: Any + ) -> _models.MetricAlertResource: + """Update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Is either a model type or a IO type. + Required. + :type parameters: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: MetricAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResource] - _json = self._serialize.body(parameters, 'MetricAlertResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MetricAlertResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -630,10 +690,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -641,52 +700,46 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MetricAlertResource', pipeline_response) + deserialized = self._deserialize("MetricAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, **kwargs: Any ) -> None: """Delete an alert rule definition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -694,10 +747,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -708,5 +760,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py index 23ea26c0b8a0..ecc5c38e616a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,87 +23,80 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, - resource_group_name: str, - rule_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_name_request( - subscription_id: str, - resource_group_name: str, - rule_name: str, - status_name: str, - **kwargs: Any + resource_group_name: str, rule_name: str, status_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "statusName": _SERIALIZER.url("status_name", status_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "statusName": _SERIALIZER.url("status_name", status_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MetricAlertsStatusOperations: """ @@ -120,43 +117,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.MetricAlertStatusCollection: + def list(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.MetricAlertStatusCollection: """Retrieve an alert rule status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertStatusCollection, or the result of cls(response) + :return: MetricAlertStatusCollection or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertStatusCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertStatusCollection] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -164,10 +153,9 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,56 +163,49 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MetricAlertStatusCollection', pipeline_response) + deserialized = self._deserialize("MetricAlertStatusCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status"} # type: ignore @distributed_trace def list_by_name( - self, - resource_group_name: str, - rule_name: str, - status_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, status_name: str, **kwargs: Any ) -> _models.MetricAlertStatusCollection: """Retrieve an alert rule status. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param status_name: The name of the status. + :param status_name: The name of the status. Required. :type status_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertStatusCollection, or the result of cls(response) + :return: MetricAlertStatusCollection or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertStatusCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertStatusCollection] - request = build_list_by_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, status_name=status_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_name.metadata['url'], + template_url=self.list_by_name.metadata["url"], headers=_headers, params=_params, ) @@ -232,10 +213,9 @@ def list_by_name( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -243,12 +223,11 @@ def list_by_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MetricAlertStatusCollection', pipeline_response) + deserialized = self._deserialize("MetricAlertStatusCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}"} # type: ignore - + list_by_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py index 4553ba117c46..a9a360483411 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-04-16". 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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-04-16") # type: str + api_version = kwargs.pop("api_version", "2018-04-16") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json index 1e742490f1c0..2d06e0f25ce0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py index 9846f53b6f80..eac33aa08ac4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ScheduledQueryRulesOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations :vartype scheduled_query_rules: $(python-base-namespace).v2018_04_16.operations.ScheduledQueryRulesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -46,7 +46,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -57,12 +59,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -71,7 +68,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py index a851ec39e387..fa652aba27f3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-04-16". 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-04-16") # type: str + api_version = kwargs.pop("api_version", "2018-04-16") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py index b5bb1503a278..cbe6779ef9c0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ScheduledQueryRulesOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations :vartype scheduled_query_rules: $(python-base-namespace).v2018_04_16.aio.operations.ScheduledQueryRulesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -46,7 +46,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -57,12 +59,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -71,7 +68,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/__init__.py index a33ab10efeb3..40cd07056c01 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ScheduledQueryRulesOperations', + "ScheduledQueryRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py index 9aacec878a06..48df82cc1287 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._scheduled_query_rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._scheduled_query_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ScheduledQueryRulesOperations: """ .. warning:: @@ -43,50 +59,115 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, rule_name: str, parameters: _models.LogSearchRuleResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LogSearchRuleResource: """Creates or updates an log search rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. + :param parameters: The parameters of the rule to create or update. Required. :type parameters: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: LogSearchRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Creates or updates an log search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. 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: LogSearchRuleResource, or the result of cls(response) + :return: LogSearchRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.LogSearchRuleResource, IO], + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Creates or updates an log search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a model type or a + IO type. Required. + :type parameters: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: LogSearchRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResource] - _json = self._serialize.body(parameters, 'LogSearchRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LogSearchRuleResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -94,10 +175,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -106,55 +186,47 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('LogSearchRuleResource', pipeline_response) + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('LogSearchRuleResource', pipeline_response) + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.LogSearchRuleResource: + async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.LogSearchRuleResource: """Gets an Log Search rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource, or the result of cls(response) + :return: LogSearchRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResource] - request = build_get_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -162,10 +234,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,59 +244,124 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LogSearchRuleResource', pipeline_response) + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, rule_name: str, parameters: _models.LogSearchRuleResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LogSearchRuleResource: """Update log search Rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to update. + :param parameters: The parameters of the rule to update. Required. :type parameters: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: LogSearchRuleResource, or the result of cls(response) + :return: LogSearchRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Update log search Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. 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: LogSearchRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.LogSearchRuleResourcePatch, IO], + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Update log search Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Is either a model type or a IO type. + Required. + :type parameters: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: LogSearchRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResource] - _json = self._serialize.body(parameters, 'LogSearchRuleResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LogSearchRuleResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -233,10 +369,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -244,52 +379,46 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LogSearchRuleResource', pipeline_response) + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, **kwargs: Any ) -> None: """Deletes a Log Search rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -297,10 +426,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -311,45 +439,41 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[_models.LogSearchRuleResourceCollection]: + self, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.LogSearchRuleResource"]: """List the Log Search rules within a subscription group. :param filter: The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. 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 LogSearchRuleResourceCollection or the result of + :return: An iterator like instance of either LogSearchRuleResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -357,15 +481,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -381,10 +501,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -395,52 +513,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[_models.LogSearchRuleResourceCollection]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.LogSearchRuleResource"]: """List the Log Search rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. 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 LogSearchRuleResourceCollection or the result of + :return: An iterator like instance of either LogSearchRuleResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -448,16 +561,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -473,10 +581,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -487,8 +593,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py index 7f48070171b5..15975e5d06a0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py @@ -23,43 +23,41 @@ from ._models_py3 import Source from ._models_py3 import TriggerCondition - -from ._monitor_management_client_enums import ( - AlertSeverity, - ConditionalOperator, - Enabled, - MetricTriggerType, - Operator, - ProvisioningState, - QueryType, -) +from ._monitor_management_client_enums import AlertSeverity +from ._monitor_management_client_enums import ConditionalOperator +from ._monitor_management_client_enums import Enabled +from ._monitor_management_client_enums import MetricTriggerType +from ._monitor_management_client_enums import Operator +from ._monitor_management_client_enums import ProvisioningState +from ._monitor_management_client_enums import QueryType from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Action', - 'AlertingAction', - 'AzNsActionGroup', - 'Criteria', - 'Dimension', - 'ErrorContract', - 'ErrorResponse', - 'LogMetricTrigger', - 'LogSearchRuleResource', - 'LogSearchRuleResourceCollection', - 'LogSearchRuleResourcePatch', - 'LogToMetricAction', - 'Resource', - 'Schedule', - 'Source', - 'TriggerCondition', - 'AlertSeverity', - 'ConditionalOperator', - 'Enabled', - 'MetricTriggerType', - 'Operator', - 'ProvisioningState', - 'QueryType', + "Action", + "AlertingAction", + "AzNsActionGroup", + "Criteria", + "Dimension", + "ErrorContract", + "ErrorResponse", + "LogMetricTrigger", + "LogSearchRuleResource", + "LogSearchRuleResourceCollection", + "LogSearchRuleResourcePatch", + "LogToMetricAction", + "Resource", + "Schedule", + "Source", + "TriggerCondition", + "AlertSeverity", + "ConditionalOperator", + "Enabled", + "MetricTriggerType", + "Operator", + "ProvisioningState", + "QueryType", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py index 797409021318..3e1ad7562fce 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/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. @@ -8,46 +9,44 @@ from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Action descriptor. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AlertingAction, LogToMetricAction. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AlertingAction, LogToMetricAction All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. Specifies the action. Supported values - AlertingAction, - LogToMetricAction.Constant filled by server. + :ivar odata_type: Specifies the action. Supported values - AlertingAction, LogToMetricAction. + Required. :vartype odata_type: str """ _validation = { - 'odata_type': {'required': True}, + "odata_type": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, } _subtype_map = { - 'odata_type': {'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction': 'AlertingAction', 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction': 'LogToMetricAction'} + "odata_type": { + "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction": "AlertingAction", + "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction": "LogToMetricAction", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(Action, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -56,31 +55,31 @@ class AlertingAction(Action): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. Specifies the action. Supported values - AlertingAction, - LogToMetricAction.Constant filled by server. + :ivar odata_type: Specifies the action. Supported values - AlertingAction, LogToMetricAction. + Required. :vartype odata_type: str - :ivar severity: Required. Severity of the alert. Known values are: "0", "1", "2", "3", "4". + :ivar severity: Severity of the alert. Required. Known values are: "0", "1", "2", "3", and "4". :vartype severity: str or ~$(python-base-namespace).v2018_04_16.models.AlertSeverity :ivar azns_action: Azure action group reference. :vartype azns_action: ~$(python-base-namespace).v2018_04_16.models.AzNsActionGroup :ivar throttling_in_min: time (in minutes) for which Alerts should be throttled or suppressed. :vartype throttling_in_min: int - :ivar trigger: Required. The trigger condition that results in the alert rule being. + :ivar trigger: The trigger condition that results in the alert rule being. Required. :vartype trigger: ~$(python-base-namespace).v2018_04_16.models.TriggerCondition """ _validation = { - 'odata_type': {'required': True}, - 'severity': {'required': True}, - 'trigger': {'required': True}, + "odata_type": {"required": True}, + "severity": {"required": True}, + "trigger": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'azns_action': {'key': 'aznsAction', 'type': 'AzNsActionGroup'}, - 'throttling_in_min': {'key': 'throttlingInMin', 'type': 'int'}, - 'trigger': {'key': 'trigger', 'type': 'TriggerCondition'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "azns_action": {"key": "aznsAction", "type": "AzNsActionGroup"}, + "throttling_in_min": {"key": "throttlingInMin", "type": "int"}, + "trigger": {"key": "trigger", "type": "TriggerCondition"}, } def __init__( @@ -93,25 +92,26 @@ def __init__( **kwargs ): """ - :keyword severity: Required. Severity of the alert. Known values are: "0", "1", "2", "3", "4". + :keyword severity: Severity of the alert. Required. Known values are: "0", "1", "2", "3", and + "4". :paramtype severity: str or ~$(python-base-namespace).v2018_04_16.models.AlertSeverity :keyword azns_action: Azure action group reference. :paramtype azns_action: ~$(python-base-namespace).v2018_04_16.models.AzNsActionGroup :keyword throttling_in_min: time (in minutes) for which Alerts should be throttled or suppressed. :paramtype throttling_in_min: int - :keyword trigger: Required. The trigger condition that results in the alert rule being. + :keyword trigger: The trigger condition that results in the alert rule being. Required. :paramtype trigger: ~$(python-base-namespace).v2018_04_16.models.TriggerCondition """ - super(AlertingAction, self).__init__(**kwargs) - self.odata_type = 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' # type: str + super().__init__(**kwargs) + self.odata_type = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction" # type: str self.severity = severity self.azns_action = azns_action self.throttling_in_min = throttling_in_min self.trigger = trigger -class AzNsActionGroup(msrest.serialization.Model): +class AzNsActionGroup(_serialization.Model): """Azure action group. :ivar action_group: Azure Action Group reference. @@ -124,9 +124,9 @@ class AzNsActionGroup(msrest.serialization.Model): """ _attribute_map = { - 'action_group': {'key': 'actionGroup', 'type': '[str]'}, - 'email_subject': {'key': 'emailSubject', 'type': 'str'}, - 'custom_webhook_payload': {'key': 'customWebhookPayload', 'type': 'str'}, + "action_group": {"key": "actionGroup", "type": "[str]"}, + "email_subject": {"key": "emailSubject", "type": "str"}, + "custom_webhook_payload": {"key": "customWebhookPayload", "type": "str"}, } def __init__( @@ -146,98 +146,85 @@ def __init__( group. :paramtype custom_webhook_payload: str """ - super(AzNsActionGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.action_group = action_group self.email_subject = email_subject self.custom_webhook_payload = custom_webhook_payload -class Criteria(msrest.serialization.Model): +class Criteria(_serialization.Model): """Specifies the criteria for converting log to metric. All required parameters must be populated in order to send to Azure. - :ivar metric_name: Required. Name of the metric. + :ivar metric_name: Name of the metric. Required. :vartype metric_name: str :ivar dimensions: List of Dimensions for creating metric. :vartype dimensions: list[~$(python-base-namespace).v2018_04_16.models.Dimension] """ _validation = { - 'metric_name': {'required': True}, + "metric_name": {"required": True}, } _attribute_map = { - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, + "metric_name": {"key": "metricName", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, } - def __init__( - self, - *, - metric_name: str, - dimensions: Optional[List["_models.Dimension"]] = None, - **kwargs - ): + def __init__(self, *, metric_name: str, dimensions: Optional[List["_models.Dimension"]] = None, **kwargs): """ - :keyword metric_name: Required. Name of the metric. + :keyword metric_name: Name of the metric. Required. :paramtype metric_name: str :keyword dimensions: List of Dimensions for creating metric. :paramtype dimensions: list[~$(python-base-namespace).v2018_04_16.models.Dimension] """ - super(Criteria, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_name = metric_name self.dimensions = dimensions -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Specifies the criteria for converting log to metric. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the dimension. + :ivar name: Name of the dimension. Required. :vartype name: str - :ivar operator: Required. Operator for dimension values. Known values are: "Include". + :ivar operator: Operator for dimension values. Required. "Include" :vartype operator: str or ~$(python-base-namespace).v2018_04_16.models.Operator - :ivar values: Required. List of dimension values. + :ivar values: List of dimension values. Required. :vartype values: list[str] """ _validation = { - 'name': {'required': True}, - 'operator': {'required': True}, - 'values': {'required': True}, + "name": {"required": True}, + "operator": {"required": True}, + "values": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "operator": {"key": "operator", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, } - def __init__( - self, - *, - name: str, - operator: Union[str, "_models.Operator"], - values: List[str], - **kwargs - ): + def __init__(self, *, name: str, operator: Union[str, "_models.Operator"], values: List[str], **kwargs): """ - :keyword name: Required. Name of the dimension. + :keyword name: Name of the dimension. Required. :paramtype name: str - :keyword operator: Required. Operator for dimension values. Known values are: "Include". + :keyword operator: Operator for dimension values. Required. "Include" :paramtype operator: str or ~$(python-base-namespace).v2018_04_16.models.Operator - :keyword values: Required. List of dimension values. + :keyword values: List of dimension values. Required. :paramtype values: list[str] """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.operator = operator self.values = values -class ErrorContract(msrest.serialization.Model): +class ErrorContract(_serialization.Model): """Describes the format of Error response. :ivar error: The error details. @@ -245,24 +232,19 @@ class ErrorContract(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword error: The error details. :paramtype error: ~$(python-base-namespace).v2018_04_16.models.ErrorResponse """ - super(ErrorContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -272,40 +254,34 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class LogMetricTrigger(msrest.serialization.Model): +class LogMetricTrigger(_serialization.Model): """A log metrics trigger descriptor. :ivar threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", - "Equal". Default value: "GreaterThanOrEqual". + and "Equal". :vartype threshold_operator: str or ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator :ivar threshold: The threshold of the metric trigger. :vartype threshold: float :ivar metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Known values are: - "Consecutive", "Total". Default value: "Consecutive". + "Consecutive" and "Total". :vartype metric_trigger_type: str or ~$(python-base-namespace).v2018_04_16.models.MetricTriggerType :ivar metric_column: Evaluation of metric on a particular column. @@ -313,44 +289,44 @@ class LogMetricTrigger(msrest.serialization.Model): """ _attribute_map = { - 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'metric_trigger_type': {'key': 'metricTriggerType', 'type': 'str'}, - 'metric_column': {'key': 'metricColumn', 'type': 'str'}, + "threshold_operator": {"key": "thresholdOperator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "metric_trigger_type": {"key": "metricTriggerType", "type": "str"}, + "metric_column": {"key": "metricColumn", "type": "str"}, } def __init__( self, *, - threshold_operator: Optional[Union[str, "_models.ConditionalOperator"]] = "GreaterThanOrEqual", + threshold_operator: Union[str, "_models.ConditionalOperator"] = "GreaterThanOrEqual", threshold: Optional[float] = None, - metric_trigger_type: Optional[Union[str, "_models.MetricTriggerType"]] = "Consecutive", + metric_trigger_type: Union[str, "_models.MetricTriggerType"] = "Consecutive", metric_column: Optional[str] = None, **kwargs ): """ :keyword threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", - "Equal". Default value: "GreaterThanOrEqual". + and "Equal". :paramtype threshold_operator: str or ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator :keyword threshold: The threshold of the metric trigger. :paramtype threshold: float :keyword metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Known values are: - "Consecutive", "Total". Default value: "Consecutive". + "Consecutive" and "Total". :paramtype metric_trigger_type: str or ~$(python-base-namespace).v2018_04_16.models.MetricTriggerType :keyword metric_column: Evaluation of metric on a particular column. :paramtype metric_column: str """ - super(LogMetricTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.threshold_operator = threshold_operator self.threshold = threshold self.metric_trigger_type = metric_trigger_type self.metric_column = metric_column -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -363,9 +339,9 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, @@ -380,38 +356,32 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "kind": {"readonly": True}, + "etag": {"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}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "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}"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -421,7 +391,7 @@ def __init__( self.etag = None -class LogSearchRuleResource(Resource): +class LogSearchRuleResource(Resource): # pylint: disable=too-many-instance-attributes """The Log Search Rule resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -434,9 +404,9 @@ class LogSearchRuleResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, @@ -460,57 +430,57 @@ class LogSearchRuleResource(Resource): or not. The default is false. :vartype auto_mitigate: bool :ivar enabled: The flag which indicates whether the Log Search rule is enabled. Value should be - true or false. Known values are: "true", "false". + true or false. Known values are: "true" and "false". :vartype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled :ivar last_updated_time: Last time the rule was updated in IS08601 format. :vartype last_updated_time: ~datetime.datetime :ivar provisioning_state: Provisioning state of the scheduled query rule. Known values are: - "Succeeded", "Deploying", "Canceled", "Failed". + "Succeeded", "Deploying", "Canceled", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2018_04_16.models.ProvisioningState - :ivar source: Required. Data Source against which rule will Query Data. + :ivar source: Data Source against which rule will Query Data. Required. :vartype source: ~$(python-base-namespace).v2018_04_16.models.Source :ivar schedule: Schedule (Frequency, Time Window) for rule. Required for action type - AlertingAction. :vartype schedule: ~$(python-base-namespace).v2018_04_16.models.Schedule - :ivar action: Required. Action needs to be taken on rule execution. + :ivar action: Action needs to be taken on rule execution. Required. :vartype action: ~$(python-base-namespace).v2018_04_16.models.Action """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'etag': {'readonly': True}, - 'created_with_api_version': {'readonly': True}, - 'is_legacy_log_analytics_rule': {'readonly': True}, - 'last_updated_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'source': {'required': True}, - 'action': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "kind": {"readonly": True}, + "etag": {"readonly": True}, + "created_with_api_version": {"readonly": True}, + "is_legacy_log_analytics_rule": {"readonly": True}, + "last_updated_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "source": {"required": True}, + "action": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'created_with_api_version': {'key': 'properties.createdWithApiVersion', 'type': 'str'}, - 'is_legacy_log_analytics_rule': {'key': 'properties.isLegacyLogAnalyticsRule', 'type': 'bool'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'auto_mitigate': {'key': 'properties.autoMitigate', 'type': 'bool'}, - 'enabled': {'key': 'properties.enabled', 'type': 'str'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'Source'}, - 'schedule': {'key': 'properties.schedule', 'type': 'Schedule'}, - 'action': {'key': 'properties.action', 'type': 'Action'}, + "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}"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "created_with_api_version": {"key": "properties.createdWithApiVersion", "type": "str"}, + "is_legacy_log_analytics_rule": {"key": "properties.isLegacyLogAnalyticsRule", "type": "bool"}, + "description": {"key": "properties.description", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "auto_mitigate": {"key": "properties.autoMitigate", "type": "bool"}, + "enabled": {"key": "properties.enabled", "type": "str"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "source": {"key": "properties.source", "type": "Source"}, + "schedule": {"key": "properties.schedule", "type": "Schedule"}, + "action": {"key": "properties.action", "type": "Action"}, } def __init__( @@ -522,15 +492,15 @@ def __init__( tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, display_name: Optional[str] = None, - auto_mitigate: Optional[bool] = False, + auto_mitigate: bool = False, enabled: Optional[Union[str, "_models.Enabled"]] = None, schedule: Optional["_models.Schedule"] = None, **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword description: The description of the Log Search rule. :paramtype description: str @@ -540,17 +510,17 @@ def __init__( resolved or not. The default is false. :paramtype auto_mitigate: bool :keyword enabled: The flag which indicates whether the Log Search rule is enabled. Value should - be true or false. Known values are: "true", "false". + be true or false. Known values are: "true" and "false". :paramtype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled - :keyword source: Required. Data Source against which rule will Query Data. + :keyword source: Data Source against which rule will Query Data. Required. :paramtype source: ~$(python-base-namespace).v2018_04_16.models.Source :keyword schedule: Schedule (Frequency, Time Window) for rule. Required for action type - AlertingAction. :paramtype schedule: ~$(python-base-namespace).v2018_04_16.models.Schedule - :keyword action: Required. Action needs to be taken on rule execution. + :keyword action: Action needs to be taken on rule execution. Required. :paramtype action: ~$(python-base-namespace).v2018_04_16.models.Action """ - super(LogSearchRuleResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.created_with_api_version = None self.is_legacy_log_analytics_rule = None self.description = description @@ -564,7 +534,7 @@ def __init__( self.action = action -class LogSearchRuleResourceCollection(msrest.serialization.Model): +class LogSearchRuleResourceCollection(_serialization.Model): """Represents a collection of Log Search rule resources. :ivar value: The values for the Log Search Rule resources. @@ -572,36 +542,31 @@ class LogSearchRuleResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[LogSearchRuleResource]'}, + "value": {"key": "value", "type": "[LogSearchRuleResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.LogSearchRuleResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.LogSearchRuleResource"]] = None, **kwargs): """ :keyword value: The values for the Log Search Rule resources. :paramtype value: list[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource] """ - super(LogSearchRuleResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class LogSearchRuleResourcePatch(msrest.serialization.Model): +class LogSearchRuleResourcePatch(_serialization.Model): """The log search rule resource for patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar enabled: The flag which indicates whether the Log Search rule is enabled. Value should be - true or false. Known values are: "true", "false". + true or false. Known values are: "true" and "false". :vartype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "str"}, } def __init__( @@ -612,13 +577,13 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword enabled: The flag which indicates whether the Log Search rule is enabled. Value should - be true or false. Known values are: "true", "false". + be true or false. Known values are: "true" and "false". :paramtype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled """ - super(LogSearchRuleResourcePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.enabled = enabled @@ -628,82 +593,71 @@ class LogToMetricAction(Action): All required parameters must be populated in order to send to Azure. - :ivar odata_type: Required. Specifies the action. Supported values - AlertingAction, - LogToMetricAction.Constant filled by server. + :ivar odata_type: Specifies the action. Supported values - AlertingAction, LogToMetricAction. + Required. :vartype odata_type: str - :ivar criteria: Required. Criteria of Metric. + :ivar criteria: Criteria of Metric. Required. :vartype criteria: list[~$(python-base-namespace).v2018_04_16.models.Criteria] """ _validation = { - 'odata_type': {'required': True}, - 'criteria': {'required': True}, + "odata_type": {"required": True}, + "criteria": {"required": True}, } _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'criteria': {'key': 'criteria', 'type': '[Criteria]'}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "criteria": {"key": "criteria", "type": "[Criteria]"}, } - def __init__( - self, - *, - criteria: List["_models.Criteria"], - **kwargs - ): + def __init__(self, *, criteria: List["_models.Criteria"], **kwargs): """ - :keyword criteria: Required. Criteria of Metric. + :keyword criteria: Criteria of Metric. Required. :paramtype criteria: list[~$(python-base-namespace).v2018_04_16.models.Criteria] """ - super(LogToMetricAction, self).__init__(**kwargs) - self.odata_type = 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction' # type: str + super().__init__(**kwargs) + self.odata_type = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction" # type: str self.criteria = criteria -class Schedule(msrest.serialization.Model): +class Schedule(_serialization.Model): """Defines how often to run the search and the time interval. All required parameters must be populated in order to send to Azure. - :ivar frequency_in_minutes: Required. frequency (in minutes) at which rule condition should be - evaluated. + :ivar frequency_in_minutes: frequency (in minutes) at which rule condition should be evaluated. + Required. :vartype frequency_in_minutes: int - :ivar time_window_in_minutes: Required. Time window for which data needs to be fetched for - query (should be greater than or equal to frequencyInMinutes). + :ivar time_window_in_minutes: Time window for which data needs to be fetched for query (should + be greater than or equal to frequencyInMinutes). Required. :vartype time_window_in_minutes: int """ _validation = { - 'frequency_in_minutes': {'required': True}, - 'time_window_in_minutes': {'required': True}, + "frequency_in_minutes": {"required": True}, + "time_window_in_minutes": {"required": True}, } _attribute_map = { - 'frequency_in_minutes': {'key': 'frequencyInMinutes', 'type': 'int'}, - 'time_window_in_minutes': {'key': 'timeWindowInMinutes', 'type': 'int'}, + "frequency_in_minutes": {"key": "frequencyInMinutes", "type": "int"}, + "time_window_in_minutes": {"key": "timeWindowInMinutes", "type": "int"}, } - def __init__( - self, - *, - frequency_in_minutes: int, - time_window_in_minutes: int, - **kwargs - ): + def __init__(self, *, frequency_in_minutes: int, time_window_in_minutes: int, **kwargs): """ - :keyword frequency_in_minutes: Required. frequency (in minutes) at which rule condition should - be evaluated. + :keyword frequency_in_minutes: frequency (in minutes) at which rule condition should be + evaluated. Required. :paramtype frequency_in_minutes: int - :keyword time_window_in_minutes: Required. Time window for which data needs to be fetched for - query (should be greater than or equal to frequencyInMinutes). + :keyword time_window_in_minutes: Time window for which data needs to be fetched for query + (should be greater than or equal to frequencyInMinutes). Required. :paramtype time_window_in_minutes: int """ - super(Schedule, self).__init__(**kwargs) + super().__init__(**kwargs) self.frequency_in_minutes = frequency_in_minutes self.time_window_in_minutes = time_window_in_minutes -class Source(msrest.serialization.Model): +class Source(_serialization.Model): """Specifies the log search query. All required parameters must be populated in order to send to Azure. @@ -712,21 +666,21 @@ class Source(msrest.serialization.Model): :vartype query: str :ivar authorized_resources: List of Resource referred into query. :vartype authorized_resources: list[str] - :ivar data_source_id: Required. The resource uri over which log search query is to be run. + :ivar data_source_id: The resource uri over which log search query is to be run. Required. :vartype data_source_id: str - :ivar query_type: Set value to 'ResultCount' . Known values are: "ResultCount". + :ivar query_type: Set value to 'ResultCount' . "ResultCount" :vartype query_type: str or ~$(python-base-namespace).v2018_04_16.models.QueryType """ _validation = { - 'data_source_id': {'required': True}, + "data_source_id": {"required": True}, } _attribute_map = { - 'query': {'key': 'query', 'type': 'str'}, - 'authorized_resources': {'key': 'authorizedResources', 'type': '[str]'}, - 'data_source_id': {'key': 'dataSourceId', 'type': 'str'}, - 'query_type': {'key': 'queryType', 'type': 'str'}, + "query": {"key": "query", "type": "str"}, + "authorized_resources": {"key": "authorizedResources", "type": "[str]"}, + "data_source_id": {"key": "dataSourceId", "type": "str"}, + "query_type": {"key": "queryType", "type": "str"}, } def __init__( @@ -743,43 +697,42 @@ def __init__( :paramtype query: str :keyword authorized_resources: List of Resource referred into query. :paramtype authorized_resources: list[str] - :keyword data_source_id: Required. The resource uri over which log search query is to be run. + :keyword data_source_id: The resource uri over which log search query is to be run. Required. :paramtype data_source_id: str - :keyword query_type: Set value to 'ResultCount' . Known values are: "ResultCount". + :keyword query_type: Set value to 'ResultCount' . "ResultCount" :paramtype query_type: str or ~$(python-base-namespace).v2018_04_16.models.QueryType """ - super(Source, self).__init__(**kwargs) + super().__init__(**kwargs) self.query = query self.authorized_resources = authorized_resources self.data_source_id = data_source_id self.query_type = query_type -class TriggerCondition(msrest.serialization.Model): +class TriggerCondition(_serialization.Model): """The condition that results in the Log Search rule. All required parameters must be populated in order to send to Azure. - :ivar threshold_operator: Required. Evaluation operation for rule - 'GreaterThan' or 'LessThan. - Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", "Equal". - Default value: "GreaterThanOrEqual". + :ivar threshold_operator: Evaluation operation for rule - 'GreaterThan' or 'LessThan. Known + values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", and "Equal". :vartype threshold_operator: str or ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator - :ivar threshold: Required. Result or count threshold based on which rule should be triggered. + :ivar threshold: Result or count threshold based on which rule should be triggered. Required. :vartype threshold: float :ivar metric_trigger: Trigger condition for metric query rule. :vartype metric_trigger: ~$(python-base-namespace).v2018_04_16.models.LogMetricTrigger """ _validation = { - 'threshold_operator': {'required': True}, - 'threshold': {'required': True}, + "threshold_operator": {"required": True}, + "threshold": {"required": True}, } _attribute_map = { - 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'metric_trigger': {'key': 'metricTrigger', 'type': 'LogMetricTrigger'}, + "threshold_operator": {"key": "thresholdOperator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "metric_trigger": {"key": "metricTrigger", "type": "LogMetricTrigger"}, } def __init__( @@ -791,18 +744,17 @@ def __init__( **kwargs ): """ - :keyword threshold_operator: Required. Evaluation operation for rule - 'GreaterThan' or - 'LessThan. Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", - "LessThan", "Equal". Default value: "GreaterThanOrEqual". + :keyword threshold_operator: Evaluation operation for rule - 'GreaterThan' or 'LessThan. Known + values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", and "Equal". :paramtype threshold_operator: str or ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator - :keyword threshold: Required. Result or count threshold based on which rule should be - triggered. + :keyword threshold: Result or count threshold based on which rule should be triggered. + Required. :paramtype threshold: float :keyword metric_trigger: Trigger condition for metric query rule. :paramtype metric_trigger: ~$(python-base-namespace).v2018_04_16.models.LogMetricTrigger """ - super(TriggerCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.threshold_operator = threshold_operator self.threshold = threshold self.metric_trigger = metric_trigger diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py index 86c63bab3f9c..6462be05d90a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py @@ -11,8 +11,7 @@ class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Severity Level of Alert - """ + """Severity Level of Alert.""" ZERO = "0" ONE = "1" @@ -20,9 +19,9 @@ class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): THREE = "3" FOUR = "4" + class ConditionalOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Result Condition Evaluation criteria. - """ + """Result Condition Evaluation criteria.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" LESS_THAN_OR_EQUAL = "LessThanOrEqual" @@ -30,37 +29,37 @@ class ConditionalOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): LESS_THAN = "LessThan" EQUAL = "Equal" + class Enabled(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The flag which indicates whether the Log Search rule is enabled. Value should be true or false - """ + """The flag which indicates whether the Log Search rule is enabled. Value should be true or false.""" TRUE = "true" FALSE = "false" + class MetricTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Metric Trigger Evaluation Type - """ + """Metric Trigger Evaluation Type.""" CONSECUTIVE = "Consecutive" TOTAL = "Total" + class Operator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operator for dimension values - """ + """Operator for dimension values.""" INCLUDE = "Include" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Provisioning state of the scheduled query rule - """ + """Provisioning state of the scheduled query rule.""" SUCCEEDED = "Succeeded" DEPLOYING = "Deploying" CANCELED = "Canceled" FAILED = "Failed" + class QueryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Set value to 'ResultAccount' - """ + """Set value to 'ResultAccount'.""" RESULT_COUNT = "ResultCount" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/__init__.py index a33ab10efeb3..40cd07056c01 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ScheduledQueryRulesOperations', + "ScheduledQueryRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py index 668fd43bef7b..10d2cfd75db7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,251 +25,211 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - rule_name: str, - *, - json: Optional[_models.LogSearchRuleResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_request( - resource_group_name: str, - rule_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( - subscription_id: str, - resource_group_name: str, - rule_name: str, - *, - json: Optional[_models.LogSearchRuleResourcePatch] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_delete_request( - resource_group_name: str, - rule_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_delete_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_subscription_request( - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _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 - ) + _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, - *, - filter: Optional[str] = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class ScheduledQueryRulesOperations: """ @@ -285,50 +250,115 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, rule_name: str, parameters: _models.LogSearchRuleResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LogSearchRuleResource: """Creates or updates an log search rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. + :param parameters: The parameters of the rule to create or update. Required. :type parameters: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: LogSearchRuleResource, or the result of cls(response) + :return: LogSearchRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Creates or updates an log search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. 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: LogSearchRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.LogSearchRuleResource, IO], + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Creates or updates an log search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a model type or a + IO type. Required. + :type parameters: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: LogSearchRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResource] - _json = self._serialize.body(parameters, 'LogSearchRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LogSearchRuleResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -336,10 +366,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -348,55 +377,47 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('LogSearchRuleResource', pipeline_response) + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('LogSearchRuleResource', pipeline_response) + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.LogSearchRuleResource: + def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.LogSearchRuleResource: """Gets an Log Search rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource, or the result of cls(response) + :return: LogSearchRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResource] - request = build_get_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -404,10 +425,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -415,59 +435,124 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LogSearchRuleResource', pipeline_response) + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, rule_name: str, parameters: _models.LogSearchRuleResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LogSearchRuleResource: """Update log search Rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to update. + :param parameters: The parameters of the rule to update. Required. :type parameters: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: LogSearchRuleResource, or the result of cls(response) + :return: LogSearchRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Update log search Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. 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: LogSearchRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.LogSearchRuleResourcePatch, IO], + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Update log search Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Is either a model type or a IO type. + Required. + :type parameters: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: LogSearchRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResource] - _json = self._serialize.body(parameters, 'LogSearchRuleResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LogSearchRuleResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -475,10 +560,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -486,52 +570,46 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LogSearchRuleResource', pipeline_response) + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, **kwargs: Any ) -> None: """Deletes a Log Search rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -539,10 +617,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -553,45 +630,41 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable[_models.LogSearchRuleResourceCollection]: + self, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.LogSearchRuleResource"]: """List the Log Search rules within a subscription group. :param filter: The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. 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 LogSearchRuleResourceCollection or the result of + :return: An iterator like instance of either LogSearchRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -599,15 +672,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -623,10 +692,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -637,52 +704,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable[_models.LogSearchRuleResourceCollection]: + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.LogSearchRuleResource"]: """List the Log Search rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param filter: The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. 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 LogSearchRuleResourceCollection or the result of + :return: An iterator like instance of either LogSearchRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -690,16 +752,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -715,10 +772,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -729,8 +784,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py index 676df20cf337..0d9de72334c0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-06-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-06-01-preview") # type: str + api_version = kwargs.pop("api_version", "2018-06-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json index 21edf7fba84b..2fc810ba4b99 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py index c158437568fd..65882cf4ce27 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import GuestDiagnosticsSettingsAssociationOperations, GuestDiagnosticsSettingsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar guest_diagnostics_settings_association: GuestDiagnosticsSettingsAssociationOperations @@ -32,9 +32,9 @@ class MonitorManagementClient: :ivar guest_diagnostics_settings: GuestDiagnosticsSettingsOperations operations :vartype guest_diagnostics_settings: $(python-base-namespace).v2018_06_01_preview.operations.GuestDiagnosticsSettingsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,7 +50,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -64,12 +66,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -78,7 +75,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py index 2da71a16292c..ca9cf8a48d4e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-06-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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-06-01-preview") # type: str + api_version = kwargs.pop("api_version", "2018-06-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py index ce6a0ab2f199..32df5781f744 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import GuestDiagnosticsSettingsAssociationOperations, GuestDiagnosticsSettingsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar guest_diagnostics_settings_association: GuestDiagnosticsSettingsAssociationOperations @@ -32,9 +32,9 @@ class MonitorManagementClient: :ivar guest_diagnostics_settings: GuestDiagnosticsSettingsOperations operations :vartype guest_diagnostics_settings: $(python-base-namespace).v2018_06_01_preview.aio.operations.GuestDiagnosticsSettingsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,7 +50,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -64,12 +66,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -78,7 +75,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/__init__.py index 8d3c00241fa2..89e22142c71f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'GuestDiagnosticsSettingsAssociationOperations', - 'GuestDiagnosticsSettingsOperations', + "GuestDiagnosticsSettingsAssociationOperations", + "GuestDiagnosticsSettingsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py index 52f133d1266f..1b25c800b5ea 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._guest_diagnostics_settings_association_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._guest_diagnostics_settings_association_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class GuestDiagnosticsSettingsAssociationOperations: """ .. warning:: @@ -43,45 +59,113 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload + async def create_or_update( + self, + resource_uri: str, + association_name: str, + diagnostic_settings_association: _models.GuestDiagnosticSettingsAssociationResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Creates or updates guest diagnostics settings association. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param diagnostic_settings_association: The diagnostic settings association to create or + update. Required. + :type diagnostic_settings_association: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_uri: str, + association_name: str, + diagnostic_settings_association: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Creates or updates guest diagnostics settings association. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param diagnostic_settings_association: The diagnostic settings association to create or + update. Required. + :type diagnostic_settings_association: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( self, resource_uri: str, association_name: str, - diagnostic_settings_association: _models.GuestDiagnosticSettingsAssociationResource, + diagnostic_settings_association: Union[_models.GuestDiagnosticSettingsAssociationResource, IO], **kwargs: Any ) -> _models.GuestDiagnosticSettingsAssociationResource: """Creates or updates guest diagnostics settings association. :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. + resource type. Required. :type resource_uri: str - :param association_name: The name of the diagnostic settings association. + :param association_name: The name of the diagnostic settings association. Required. :type association_name: str :param diagnostic_settings_association: The diagnostic settings association to create or - update. + update. Is either a model type or a IO type. Required. :type diagnostic_settings_association: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: GuestDiagnosticSettingsAssociationResource, or the result of cls(response) + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] - _json = self._serialize.body(diagnostic_settings_association, 'GuestDiagnosticSettingsAssociationResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_settings_association, (IO, bytes)): + _content = diagnostic_settings_association + else: + _json = self._serialize.body(diagnostic_settings_association, "GuestDiagnosticSettingsAssociationResource") request = build_create_or_update_request( resource_uri=resource_uri, @@ -89,7 +173,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -97,10 +182,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -109,56 +193,49 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GuestDiagnosticSettingsAssociationResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GuestDiagnosticSettingsAssociationResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore - + create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> _models.GuestDiagnosticSettingsAssociationResource: """Gets guest diagnostics association settings. :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. + resource type. Required. :type resource_uri: str - :param association_name: The name of the diagnostic settings association. + :param association_name: The name of the diagnostic settings association. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource, or the result of cls(response) + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] - request = build_get_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -166,10 +243,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,52 +253,45 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GuestDiagnosticSettingsAssociationResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore - + get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> None: """Delete guest diagnostics association settings. :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. + resource type. Required. :type resource_uri: str - :param association_name: The name of the diagnostic settings association. + :param association_name: The name of the diagnostic settings association. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -230,10 +299,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -244,47 +312,116 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore + delete.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore + @overload + async def update( + self, + resource_uri: str, + association_name: str, + parameters: _models.GuestDiagnosticSettingsAssociationResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use + the CreateOrUpdate method. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_uri: str, + association_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use + the CreateOrUpdate method. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param parameters: Parameters supplied to the operation. 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: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_uri: str, association_name: str, - parameters: _models.GuestDiagnosticSettingsAssociationResourcePatch, + parameters: Union[_models.GuestDiagnosticSettingsAssociationResourcePatch, IO], **kwargs: Any ) -> _models.GuestDiagnosticSettingsAssociationResource: """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use the CreateOrUpdate method. :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. + resource type. Required. :type resource_uri: str - :param association_name: The name of the diagnostic settings association. + :param association_name: The name of the diagnostic settings association. Required. :type association_name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. :type parameters: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: GuestDiagnosticSettingsAssociationResource, or the result of cls(response) + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] - _json = self._serialize.body(parameters, 'GuestDiagnosticSettingsAssociationResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GuestDiagnosticSettingsAssociationResourcePatch") request = build_update_request( resource_uri=resource_uri, @@ -292,7 +429,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -300,10 +438,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -311,47 +448,42 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GuestDiagnosticSettingsAssociationResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore - + update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.GuestDiagnosticSettingsAssociationList]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.GuestDiagnosticSettingsAssociationResource"]: """Get a list of all guest diagnostic settings association in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestDiagnosticSettingsAssociationList or the + :return: An iterator like instance of either GuestDiagnosticSettingsAssociationResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -359,14 +491,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -382,10 +511,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -396,47 +523,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.GuestDiagnosticSettingsAssociationList]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GuestDiagnosticSettingsAssociationResource"]: """Get a list of all guest diagnostic settings association in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 GuestDiagnosticSettingsAssociationList or the + :return: An iterator like instance of either GuestDiagnosticSettingsAssociationResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -444,15 +567,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -468,10 +587,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -482,8 +599,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py index d48a25f7ac73..24208b42f67e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._guest_diagnostics_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._guest_diagnostics_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class GuestDiagnosticsSettingsOperations: """ .. warning:: @@ -43,42 +59,107 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, diagnostic_settings_name: str, diagnostic_settings: _models.GuestDiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.GuestDiagnosticSettingsResource: """Creates or updates guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. + :param diagnostic_settings_name: The name of the diagnostic setting. Required. :type diagnostic_settings_name: str - :param diagnostic_settings: The configuration to create or update. + :param diagnostic_settings: The configuration to create or update. Required. :type diagnostic_settings: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + diagnostic_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Creates or updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param diagnostic_settings: The configuration to create or update. Required. + :type diagnostic_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 + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + diagnostic_settings: Union[_models.GuestDiagnosticSettingsResource, IO], + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Creates or updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param diagnostic_settings: The configuration to create or update. Is either a model type or a + IO type. Required. + :type diagnostic_settings: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: GuestDiagnosticSettingsResource, or the result of cls(response) + :return: GuestDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsResource] - _json = self._serialize.body(diagnostic_settings, 'GuestDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_settings, (IO, bytes)): + _content = diagnostic_settings + else: + _json = self._serialize.body(diagnostic_settings, "GuestDiagnosticSettingsResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -87,7 +168,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -95,10 +177,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -107,55 +188,49 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GuestDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GuestDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - diagnostic_settings_name: str, - **kwargs: Any + self, resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any ) -> _models.GuestDiagnosticSettingsResource: """Gets guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. + :param diagnostic_settings_name: The name of the diagnostic setting. Required. :type diagnostic_settings_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource, or the result of cls(response) + :return: GuestDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsResource] - request = build_get_request( resource_group_name=resource_group_name, diagnostic_settings_name=diagnostic_settings_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -163,10 +238,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -174,51 +248,115 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GuestDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, diagnostic_settings_name: str, parameters: _models.GuestDiagnosticSettingsPatchResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.GuestDiagnosticSettingsResource: """Updates guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. + :param diagnostic_settings_name: The name of the diagnostic setting. Required. :type diagnostic_settings_name: str - :param parameters: The configuration to patch. + :param parameters: The configuration to patch. Required. :type parameters: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param parameters: The configuration to patch. 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: GuestDiagnosticSettingsResource, or the result of cls(response) + :return: GuestDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + parameters: Union[_models.GuestDiagnosticSettingsPatchResource, IO], + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param parameters: The configuration to patch. Is either a model type or a IO type. Required. + :type parameters: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'GuestDiagnosticSettingsPatchResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GuestDiagnosticSettingsPatchResource") request = build_update_request( resource_group_name=resource_group_name, @@ -227,7 +365,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -235,10 +374,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -247,55 +385,49 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GuestDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GuestDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - diagnostic_settings_name: str, - **kwargs: Any + self, resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any ) -> None: """Delete guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. + :param diagnostic_settings_name: The name of the diagnostic setting. Required. :type diagnostic_settings_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, diagnostic_settings_name=diagnostic_settings_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -303,10 +435,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,40 +448,35 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.GuestDiagnosticSettingsList]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.GuestDiagnosticSettingsResource"]: """Get a list of all guest diagnostic settings in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestDiagnosticSettingsList or the result of + :return: An iterator like instance of either GuestDiagnosticSettingsResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -358,14 +484,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -381,10 +504,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -395,47 +516,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.GuestDiagnosticSettingsList]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GuestDiagnosticSettingsResource"]: """Get a list of all guest diagnostic settings in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 GuestDiagnosticSettingsList or the result of + :return: An iterator like instance of either GuestDiagnosticSettingsResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -443,15 +560,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -467,10 +580,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -481,8 +592,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py index 961aeba3487d..036aae01a835 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py @@ -22,34 +22,32 @@ from ._models_py3 import Resource from ._models_py3 import SinkConfiguration - -from ._monitor_management_client_enums import ( - DataSourceKind, - GuestDiagnosticSettingsOsType, - SinkConfigurationKind, -) +from ._monitor_management_client_enums import DataSourceKind +from ._monitor_management_client_enums import GuestDiagnosticSettingsOsType +from ._monitor_management_client_enums import SinkConfigurationKind from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DataSource', - 'DataSourceConfiguration', - 'ErrorResponse', - 'EtwEventConfiguration', - 'EtwProviderConfiguration', - 'EventLogConfiguration', - 'GuestDiagnosticSettingsAssociationList', - 'GuestDiagnosticSettingsAssociationResource', - 'GuestDiagnosticSettingsAssociationResourcePatch', - 'GuestDiagnosticSettingsList', - 'GuestDiagnosticSettingsPatchResource', - 'GuestDiagnosticSettingsResource', - 'PerformanceCounterConfiguration', - 'Resource', - 'SinkConfiguration', - 'DataSourceKind', - 'GuestDiagnosticSettingsOsType', - 'SinkConfigurationKind', + "DataSource", + "DataSourceConfiguration", + "ErrorResponse", + "EtwEventConfiguration", + "EtwProviderConfiguration", + "EventLogConfiguration", + "GuestDiagnosticSettingsAssociationList", + "GuestDiagnosticSettingsAssociationResource", + "GuestDiagnosticSettingsAssociationResourcePatch", + "GuestDiagnosticSettingsList", + "GuestDiagnosticSettingsPatchResource", + "GuestDiagnosticSettingsResource", + "PerformanceCounterConfiguration", + "Resource", + "SinkConfiguration", + "DataSourceKind", + "GuestDiagnosticSettingsOsType", + "SinkConfigurationKind", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py index 2c50cb871cdc..7defcd9a1e02 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_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. @@ -8,21 +9,20 @@ from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class DataSource(msrest.serialization.Model): +class DataSource(_serialization.Model): """Data source object contains configuration to collect telemetry and one or more sinks to send that telemetry data to. All required parameters must be populated in order to send to Azure. - :ivar kind: Required. Datasource kind. Known values are: "PerformanceCounter", "ETWProviders", - "WindowsEventLogs". + :ivar kind: Datasource kind. Required. Known values are: "PerformanceCounter", "ETWProviders", + and "WindowsEventLogs". :vartype kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceKind :ivar configuration: Required. :vartype configuration: @@ -32,15 +32,15 @@ class DataSource(msrest.serialization.Model): """ _validation = { - 'kind': {'required': True}, - 'configuration': {'required': True}, - 'sinks': {'required': True}, + "kind": {"required": True}, + "configuration": {"required": True}, + "sinks": {"required": True}, } _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - 'configuration': {'key': 'configuration', 'type': 'DataSourceConfiguration'}, - 'sinks': {'key': 'sinks', 'type': '[SinkConfiguration]'}, + "kind": {"key": "kind", "type": "str"}, + "configuration": {"key": "configuration", "type": "DataSourceConfiguration"}, + "sinks": {"key": "sinks", "type": "[SinkConfiguration]"}, } def __init__( @@ -52,8 +52,8 @@ def __init__( **kwargs ): """ - :keyword kind: Required. Datasource kind. Known values are: "PerformanceCounter", - "ETWProviders", "WindowsEventLogs". + :keyword kind: Datasource kind. Required. Known values are: "PerformanceCounter", + "ETWProviders", and "WindowsEventLogs". :paramtype kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceKind :keyword configuration: Required. :paramtype configuration: @@ -61,13 +61,13 @@ def __init__( :keyword sinks: Required. :paramtype sinks: list[~$(python-base-namespace).v2018_06_01_preview.models.SinkConfiguration] """ - super(DataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.kind = kind self.configuration = configuration self.sinks = sinks -class DataSourceConfiguration(msrest.serialization.Model): +class DataSourceConfiguration(_serialization.Model): """DataSourceConfiguration. :ivar providers: ETW providers configuration. @@ -82,9 +82,9 @@ class DataSourceConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'providers': {'key': 'providers', 'type': '[EtwProviderConfiguration]'}, - 'perf_counters': {'key': 'perfCounters', 'type': '[PerformanceCounterConfiguration]'}, - 'event_logs': {'key': 'eventLogs', 'type': '[EventLogConfiguration]'}, + "providers": {"key": "providers", "type": "[EtwProviderConfiguration]"}, + "perf_counters": {"key": "perfCounters", "type": "[PerformanceCounterConfiguration]"}, + "event_logs": {"key": "eventLogs", "type": "[EventLogConfiguration]"}, } def __init__( @@ -106,13 +106,13 @@ def __init__( :paramtype event_logs: list[~$(python-base-namespace).v2018_06_01_preview.models.EventLogConfiguration] """ - super(DataSourceConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.providers = providers self.perf_counters = perf_counters self.event_logs = event_logs -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -122,29 +122,23 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class EtwEventConfiguration(msrest.serialization.Model): +class EtwEventConfiguration(_serialization.Model): """EtwEventConfiguration. All required parameters must be populated in order to send to Azure. @@ -158,22 +152,22 @@ class EtwEventConfiguration(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'id': {'required': True}, + "name": {"required": True}, + "id": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'int'}, - 'filter': {'key': 'filter', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "int"}, + "filter": {"key": "filter", "type": "str"}, } def __init__( self, *, name: str, - id: int, - filter: Optional[str] = None, + id: int, # pylint: disable=redefined-builtin + filter: Optional[str] = None, # pylint: disable=redefined-builtin **kwargs ): """ @@ -184,13 +178,13 @@ def __init__( :keyword filter: :paramtype filter: str """ - super(EtwEventConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.id = id self.filter = filter -class EtwProviderConfiguration(msrest.serialization.Model): +class EtwProviderConfiguration(_serialization.Model): """EtwProviderConfiguration. All required parameters must be populated in order to send to Azure. @@ -203,21 +197,17 @@ class EtwProviderConfiguration(msrest.serialization.Model): """ _validation = { - 'id': {'required': True}, - 'events': {'required': True}, + "id": {"required": True}, + "events": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'events': {'key': 'events', 'type': '[EtwEventConfiguration]'}, + "id": {"key": "id", "type": "str"}, + "events": {"key": "events", "type": "[EtwEventConfiguration]"}, } def __init__( - self, - *, - id: str, - events: List["_models.EtwEventConfiguration"], - **kwargs + self, *, id: str, events: List["_models.EtwEventConfiguration"], **kwargs # pylint: disable=redefined-builtin ): """ :keyword id: Required. @@ -226,12 +216,12 @@ def __init__( :paramtype events: list[~$(python-base-namespace).v2018_06_01_preview.models.EtwEventConfiguration] """ - super(EtwProviderConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.events = events -class EventLogConfiguration(msrest.serialization.Model): +class EventLogConfiguration(_serialization.Model): """EventLogConfiguration. All required parameters must be populated in order to send to Azure. @@ -243,33 +233,27 @@ class EventLogConfiguration(msrest.serialization.Model): """ _validation = { - 'log_name': {'required': True}, + "log_name": {"required": True}, } _attribute_map = { - 'log_name': {'key': 'logName', 'type': 'str'}, - 'filter': {'key': 'filter', 'type': 'str'}, + "log_name": {"key": "logName", "type": "str"}, + "filter": {"key": "filter", "type": "str"}, } - def __init__( - self, - *, - log_name: str, - filter: Optional[str] = None, - **kwargs - ): + def __init__(self, *, log_name: str, filter: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword log_name: Required. :paramtype log_name: str :keyword filter: :paramtype filter: str """ - super(EventLogConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_name = log_name self.filter = filter -class GuestDiagnosticSettingsAssociationList(msrest.serialization.Model): +class GuestDiagnosticSettingsAssociationList(_serialization.Model): """A list of guest diagnostic settings association. :ivar value: The list of guest diagnostic settings association. @@ -280,8 +264,8 @@ class GuestDiagnosticSettingsAssociationList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GuestDiagnosticSettingsAssociationResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GuestDiagnosticSettingsAssociationResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -298,12 +282,12 @@ def __init__( :keyword next_link: Provides the link to retrieve the next set of elements. :paramtype next_link: str """ - super(GuestDiagnosticSettingsAssociationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -316,41 +300,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -371,84 +349,75 @@ class GuestDiagnosticSettingsAssociationResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar guest_diagnostic_settings_name: Required. The guest diagnostic settings name. + :ivar guest_diagnostic_settings_name: The guest diagnostic settings name. Required. :vartype guest_diagnostic_settings_name: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'guest_diagnostic_settings_name': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "guest_diagnostic_settings_name": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'guest_diagnostic_settings_name': {'key': 'properties.guestDiagnosticSettingsName', 'type': 'str'}, + "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}"}, + "guest_diagnostic_settings_name": {"key": "properties.guestDiagnosticSettingsName", "type": "str"}, } def __init__( - self, - *, - location: str, - guest_diagnostic_settings_name: str, - tags: Optional[Dict[str, str]] = None, - **kwargs + self, *, location: str, guest_diagnostic_settings_name: str, tags: Optional[Dict[str, str]] = None, **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword guest_diagnostic_settings_name: Required. The guest diagnostic settings name. + :keyword guest_diagnostic_settings_name: The guest diagnostic settings name. Required. :paramtype guest_diagnostic_settings_name: str """ - super(GuestDiagnosticSettingsAssociationResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.guest_diagnostic_settings_name = guest_diagnostic_settings_name -class GuestDiagnosticSettingsAssociationResourcePatch(msrest.serialization.Model): +class GuestDiagnosticSettingsAssociationResourcePatch(_serialization.Model): """Guest diagnostic setting resource for patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar guest_diagnostic_settings_name: The guest diagnostic settings name. :vartype guest_diagnostic_settings_name: str """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'guest_diagnostic_settings_name': {'key': 'properties.guestDiagnosticSettingsName', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "guest_diagnostic_settings_name": {"key": "properties.guestDiagnosticSettingsName", "type": "str"}, } def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - guest_diagnostic_settings_name: Optional[str] = None, - **kwargs + self, *, tags: Optional[Dict[str, str]] = None, guest_diagnostic_settings_name: Optional[str] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword guest_diagnostic_settings_name: The guest diagnostic settings name. :paramtype guest_diagnostic_settings_name: str """ - super(GuestDiagnosticSettingsAssociationResourcePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.guest_diagnostic_settings_name = guest_diagnostic_settings_name -class GuestDiagnosticSettingsList(msrest.serialization.Model): +class GuestDiagnosticSettingsList(_serialization.Model): """A list of guest diagnostic settings. :ivar value: The list of guest diagnostic settings. @@ -459,8 +428,8 @@ class GuestDiagnosticSettingsList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GuestDiagnosticSettingsResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GuestDiagnosticSettingsResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -477,17 +446,17 @@ def __init__( :keyword next_link: Provides the link to retrieve the next set of elements. :paramtype next_link: str """ - super(GuestDiagnosticSettingsList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class GuestDiagnosticSettingsPatchResource(msrest.serialization.Model): +class GuestDiagnosticSettingsPatchResource(_serialization.Model): """An diagnostic settings object for the body of patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar os_type: Operating system type for the configuration. Known values are: "Windows", + :ivar os_type: Operating system type for the configuration. Known values are: "Windows" and "Linux". :vartype os_type: str or ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType @@ -499,10 +468,10 @@ class GuestDiagnosticSettingsPatchResource(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'data_sources': {'key': 'properties.dataSources', 'type': '[DataSource]'}, - 'proxy_setting': {'key': 'properties.proxySetting', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "data_sources": {"key": "properties.dataSources", "type": "[DataSource]"}, + "proxy_setting": {"key": "properties.proxySetting", "type": "str"}, } def __init__( @@ -515,9 +484,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword os_type: Operating system type for the configuration. Known values are: "Windows", + :keyword os_type: Operating system type for the configuration. Known values are: "Windows" and "Linux". :paramtype os_type: str or ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType @@ -527,7 +496,7 @@ def __init__( :keyword proxy_setting: :paramtype proxy_setting: str """ - super(GuestDiagnosticSettingsPatchResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.os_type = os_type self.data_sources = data_sources @@ -547,11 +516,11 @@ class GuestDiagnosticSettingsResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar os_type: Operating system type for the configuration. Known values are: "Windows", + :ivar os_type: Operating system type for the configuration. Known values are: "Windows" and "Linux". :vartype os_type: str or ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType @@ -563,21 +532,21 @@ class GuestDiagnosticSettingsResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'data_sources': {'key': 'properties.dataSources', 'type': '[DataSource]'}, - 'proxy_setting': {'key': 'properties.proxySetting', 'type': 'str'}, + "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}"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "data_sources": {"key": "properties.dataSources", "type": "[DataSource]"}, + "proxy_setting": {"key": "properties.proxySetting", "type": "str"}, } def __init__( @@ -591,11 +560,11 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword os_type: Operating system type for the configuration. Known values are: "Windows", + :keyword os_type: Operating system type for the configuration. Known values are: "Windows" and "Linux". :paramtype os_type: str or ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType @@ -605,13 +574,13 @@ def __init__( :keyword proxy_setting: :paramtype proxy_setting: str """ - super(GuestDiagnosticSettingsResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.os_type = os_type self.data_sources = data_sources self.proxy_setting = proxy_setting -class PerformanceCounterConfiguration(msrest.serialization.Model): +class PerformanceCounterConfiguration(_serialization.Model): """PerformanceCounterConfiguration. All required parameters must be populated in order to send to Azure. @@ -625,24 +594,17 @@ class PerformanceCounterConfiguration(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'sampling_period': {'required': True}, + "name": {"required": True}, + "sampling_period": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'sampling_period': {'key': 'samplingPeriod', 'type': 'str'}, - 'instance': {'key': 'instance', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "sampling_period": {"key": "samplingPeriod", "type": "str"}, + "instance": {"key": "instance", "type": "str"}, } - def __init__( - self, - *, - name: str, - sampling_period: str, - instance: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: str, sampling_period: str, instance: Optional[str] = None, **kwargs): """ :keyword name: Required. :paramtype name: str @@ -651,40 +613,36 @@ def __init__( :keyword instance: :paramtype instance: str """ - super(PerformanceCounterConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.sampling_period = sampling_period self.instance = instance -class SinkConfiguration(msrest.serialization.Model): +class SinkConfiguration(_serialization.Model): """SinkConfiguration. All required parameters must be populated in order to send to Azure. - :ivar kind: Required. Known values are: "EventHub", "ApplicationInsights", "LogAnalytics". + :ivar kind: Required. Known values are: "EventHub", "ApplicationInsights", and "LogAnalytics". :vartype kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.SinkConfigurationKind """ _validation = { - 'kind': {'required': True}, + "kind": {"required": True}, } _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, + "kind": {"key": "kind", "type": "str"}, } - def __init__( - self, - *, - kind: Union[str, "_models.SinkConfigurationKind"], - **kwargs - ): + def __init__(self, *, kind: Union[str, "_models.SinkConfigurationKind"], **kwargs): """ - :keyword kind: Required. Known values are: "EventHub", "ApplicationInsights", "LogAnalytics". + :keyword kind: Required. Known values are: "EventHub", "ApplicationInsights", and + "LogAnalytics". :paramtype kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.SinkConfigurationKind """ - super(SinkConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.kind = kind diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py index 45fd9455475b..37e9e206ca1b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py @@ -11,21 +11,22 @@ class DataSourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Datasource kind - """ + """Datasource kind.""" PERFORMANCE_COUNTER = "PerformanceCounter" ETW_PROVIDERS = "ETWProviders" WINDOWS_EVENT_LOGS = "WindowsEventLogs" + class GuestDiagnosticSettingsOsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operating system type for the configuration - """ + """Operating system type for the configuration.""" WINDOWS = "Windows" LINUX = "Linux" + class SinkConfigurationKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SinkConfigurationKind.""" EVENT_HUB = "EventHub" APPLICATION_INSIGHTS = "ApplicationInsights" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/__init__.py index 8d3c00241fa2..89e22142c71f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'GuestDiagnosticsSettingsAssociationOperations', - 'GuestDiagnosticsSettingsOperations', + "GuestDiagnosticsSettingsAssociationOperations", + "GuestDiagnosticsSettingsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py index 54edeb08084d..1b040ec8ef0e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,235 +25,190 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_create_or_update_request( - resource_uri: str, - association_name: str, - *, - json: Optional[_models.GuestDiagnosticSettingsAssociationResource] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_create_or_update_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "associationName": _SERIALIZER.url("association_name", association_name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_get_request( - resource_uri: str, - association_name: str, - **kwargs: Any -) -> HttpRequest: + _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_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "associationName": _SERIALIZER.url("association_name", association_name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_delete_request( - resource_uri: str, - association_name: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "associationName": _SERIALIZER.url("association_name", association_name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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( - resource_uri: str, - association_name: str, - *, - json: Optional[_models.GuestDiagnosticSettingsAssociationResourcePatch] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "associationName": _SERIALIZER.url("association_name", association_name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class GuestDiagnosticsSettingsAssociationOperations: """ @@ -269,45 +229,113 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload + def create_or_update( + self, + resource_uri: str, + association_name: str, + diagnostic_settings_association: _models.GuestDiagnosticSettingsAssociationResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Creates or updates guest diagnostics settings association. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param diagnostic_settings_association: The diagnostic settings association to create or + update. Required. + :type diagnostic_settings_association: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_uri: str, + association_name: str, + diagnostic_settings_association: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Creates or updates guest diagnostics settings association. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param diagnostic_settings_association: The diagnostic settings association to create or + update. Required. + :type diagnostic_settings_association: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( self, resource_uri: str, association_name: str, - diagnostic_settings_association: _models.GuestDiagnosticSettingsAssociationResource, + diagnostic_settings_association: Union[_models.GuestDiagnosticSettingsAssociationResource, IO], **kwargs: Any ) -> _models.GuestDiagnosticSettingsAssociationResource: """Creates or updates guest diagnostics settings association. :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. + resource type. Required. :type resource_uri: str - :param association_name: The name of the diagnostic settings association. + :param association_name: The name of the diagnostic settings association. Required. :type association_name: str :param diagnostic_settings_association: The diagnostic settings association to create or - update. + update. Is either a model type or a IO type. Required. :type diagnostic_settings_association: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: GuestDiagnosticSettingsAssociationResource, or the result of cls(response) + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] - _json = self._serialize.body(diagnostic_settings_association, 'GuestDiagnosticSettingsAssociationResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_settings_association, (IO, bytes)): + _content = diagnostic_settings_association + else: + _json = self._serialize.body(diagnostic_settings_association, "GuestDiagnosticSettingsAssociationResource") request = build_create_or_update_request( resource_uri=resource_uri, @@ -315,7 +343,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -323,10 +352,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -335,56 +363,49 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GuestDiagnosticSettingsAssociationResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GuestDiagnosticSettingsAssociationResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore - + create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore @distributed_trace def get( - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> _models.GuestDiagnosticSettingsAssociationResource: """Gets guest diagnostics association settings. :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. + resource type. Required. :type resource_uri: str - :param association_name: The name of the diagnostic settings association. + :param association_name: The name of the diagnostic settings association. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource, or the result of cls(response) + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] - request = build_get_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -392,10 +413,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -403,52 +423,45 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GuestDiagnosticSettingsAssociationResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore - + get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> None: """Delete guest diagnostics association settings. :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. + resource type. Required. :type resource_uri: str - :param association_name: The name of the diagnostic settings association. + :param association_name: The name of the diagnostic settings association. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -456,10 +469,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -470,47 +482,116 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore + delete.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore + + @overload + def update( + self, + resource_uri: str, + association_name: str, + parameters: _models.GuestDiagnosticSettingsAssociationResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use + the CreateOrUpdate method. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_uri: str, + association_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use + the CreateOrUpdate method. + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param parameters: Parameters supplied to the operation. 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: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_uri: str, association_name: str, - parameters: _models.GuestDiagnosticSettingsAssociationResourcePatch, + parameters: Union[_models.GuestDiagnosticSettingsAssociationResourcePatch, IO], **kwargs: Any ) -> _models.GuestDiagnosticSettingsAssociationResource: """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use the CreateOrUpdate method. :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. + resource type. Required. :type resource_uri: str - :param association_name: The name of the diagnostic settings association. + :param association_name: The name of the diagnostic settings association. Required. :type association_name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. :type parameters: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: GuestDiagnosticSettingsAssociationResource, or the result of cls(response) + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] - _json = self._serialize.body(parameters, 'GuestDiagnosticSettingsAssociationResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GuestDiagnosticSettingsAssociationResourcePatch") request = build_update_request( resource_uri=resource_uri, @@ -518,7 +599,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -526,10 +608,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -537,47 +618,42 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GuestDiagnosticSettingsAssociationResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore - + update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.GuestDiagnosticSettingsAssociationList]: + def list(self, **kwargs: Any) -> Iterable["_models.GuestDiagnosticSettingsAssociationResource"]: """Get a list of all guest diagnostic settings association in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestDiagnosticSettingsAssociationList or the + :return: An iterator like instance of either GuestDiagnosticSettingsAssociationResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -585,14 +661,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -608,10 +681,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -622,47 +693,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.GuestDiagnosticSettingsAssociationList]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.GuestDiagnosticSettingsAssociationResource"]: """Get a list of all guest diagnostic settings association in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 GuestDiagnosticSettingsAssociationList or the + :return: An iterator like instance of either GuestDiagnosticSettingsAssociationResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -670,15 +737,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -694,10 +757,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -708,8 +769,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py index c51c0ce26110..bdd3da0fc274 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +25,209 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - resource_group_name: str, - diagnostic_settings_name: str, - subscription_id: str, - *, - json: Optional[_models.GuestDiagnosticSettingsResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, diagnostic_settings_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_request( - resource_group_name: str, - diagnostic_settings_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, diagnostic_settings_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - diagnostic_settings_name: str, - subscription_id: str, - *, - json: Optional[_models.GuestDiagnosticSettingsPatchResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, diagnostic_settings_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_delete_request( - resource_group_name: str, - diagnostic_settings_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, diagnostic_settings_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class GuestDiagnosticsSettingsOperations: """ @@ -277,42 +248,107 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, diagnostic_settings_name: str, diagnostic_settings: _models.GuestDiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.GuestDiagnosticSettingsResource: """Creates or updates guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. + :param diagnostic_settings_name: The name of the diagnostic setting. Required. :type diagnostic_settings_name: str - :param diagnostic_settings: The configuration to create or update. + :param diagnostic_settings: The configuration to create or update. Required. :type diagnostic_settings: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + diagnostic_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Creates or updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param diagnostic_settings: The configuration to create or update. Required. + :type diagnostic_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 + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + diagnostic_settings: Union[_models.GuestDiagnosticSettingsResource, IO], + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Creates or updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param diagnostic_settings: The configuration to create or update. Is either a model type or a + IO type. Required. + :type diagnostic_settings: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: GuestDiagnosticSettingsResource, or the result of cls(response) + :return: GuestDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsResource] - _json = self._serialize.body(diagnostic_settings, 'GuestDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_settings, (IO, bytes)): + _content = diagnostic_settings + else: + _json = self._serialize.body(diagnostic_settings, "GuestDiagnosticSettingsResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -321,7 +357,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -329,10 +366,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -341,55 +377,49 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GuestDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GuestDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - diagnostic_settings_name: str, - **kwargs: Any + self, resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any ) -> _models.GuestDiagnosticSettingsResource: """Gets guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. + :param diagnostic_settings_name: The name of the diagnostic setting. Required. :type diagnostic_settings_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource, or the result of cls(response) + :return: GuestDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsResource] - request = build_get_request( resource_group_name=resource_group_name, diagnostic_settings_name=diagnostic_settings_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -397,10 +427,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -408,51 +437,115 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GuestDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, diagnostic_settings_name: str, parameters: _models.GuestDiagnosticSettingsPatchResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.GuestDiagnosticSettingsResource: """Updates guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. + :param diagnostic_settings_name: The name of the diagnostic setting. Required. :type diagnostic_settings_name: str - :param parameters: The configuration to patch. + :param parameters: The configuration to patch. Required. :type parameters: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: GuestDiagnosticSettingsResource, or the result of cls(response) + :return: GuestDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param parameters: The configuration to patch. 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: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + parameters: Union[_models.GuestDiagnosticSettingsPatchResource, IO], + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param parameters: The configuration to patch. Is either a model type or a IO type. Required. + :type parameters: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'GuestDiagnosticSettingsPatchResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GuestDiagnosticSettingsPatchResource") request = build_update_request( resource_group_name=resource_group_name, @@ -461,7 +554,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -469,10 +563,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -481,55 +574,49 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GuestDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GuestDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - diagnostic_settings_name: str, - **kwargs: Any + self, resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any ) -> None: """Delete guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. + :param diagnostic_settings_name: The name of the diagnostic setting. Required. :type diagnostic_settings_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, diagnostic_settings_name=diagnostic_settings_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -537,10 +624,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -551,40 +637,35 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.GuestDiagnosticSettingsList]: + def list(self, **kwargs: Any) -> Iterable["_models.GuestDiagnosticSettingsResource"]: """Get a list of all guest diagnostic settings in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestDiagnosticSettingsList or the result of + :return: An iterator like instance of either GuestDiagnosticSettingsResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -592,14 +673,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -615,10 +693,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -629,47 +705,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.GuestDiagnosticSettingsList]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.GuestDiagnosticSettingsResource"]: """Get a list of all guest diagnostic settings in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 GuestDiagnosticSettingsList or the result of + :return: An iterator like instance of either GuestDiagnosticSettingsResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -677,15 +749,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -701,10 +769,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -715,8 +781,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py index a8eb4584c7e8..12c7e4de2931 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + api_version = kwargs.pop("api_version", "2018-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json index 869dd906e72b..df2c86ea8327 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py index 7acb95edb87a..c8ef90ca4885 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, BaselinesOperations @@ -22,16 +21,17 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2018_09_01.operations.ActionGroupsOperations :ivar baselines: BaselinesOperations operations :vartype baselines: $(python-base-namespace).v2018_09_01.operations.BaselinesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -47,26 +47,19 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.baselines = BaselinesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -75,7 +68,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py index 6eba1f68a2b8..d03c5ef67ce5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-09-01") # type: str + api_version = kwargs.pop("api_version", "2018-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py index b9350b2a8f74..54c778e0f4ff 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, BaselinesOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations @@ -30,9 +30,9 @@ class MonitorManagementClient: $(python-base-namespace).v2018_09_01.aio.operations.ActionGroupsOperations :ivar baselines: BaselinesOperations operations :vartype baselines: $(python-base-namespace).v2018_09_01.aio.operations.BaselinesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -48,26 +48,19 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.baselines = BaselinesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -76,7 +69,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/__init__.py index 62e8fdde212b..15bdf6da240f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', - 'BaselinesOperations', + "ActionGroupsOperations", + "BaselinesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py index 5d4ec502c39a..11aa15a29f5a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._action_groups_operations import build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_request -T = TypeVar('T') +from ...operations._action_groups_operations import ( + build_create_or_update_request, + build_delete_request, + build_enable_receiver_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ActionGroupsOperations: """ .. warning:: @@ -43,41 +60,105 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -86,7 +167,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -94,10 +176,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -106,55 +187,47 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -162,10 +235,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,52 +245,46 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -226,10 +292,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -240,52 +305,118 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2018_09_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2018_09_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -293,10 +424,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -304,46 +434,41 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -351,14 +476,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -374,10 +496,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -388,46 +508,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -435,15 +551,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -459,10 +571,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -473,47 +583,112 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore - @distributed_trace_async + @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2018_09_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2018_09_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -522,7 +697,8 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +706,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -544,5 +719,4 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baselines_operations.py index 37b2f16ffe03..861441d5dd98 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baselines_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baselines_operations.py @@ -8,9 +8,16 @@ # -------------------------------------------------------------------------- import datetime from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +28,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._baselines_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BaselinesOperations: """ .. warning:: @@ -43,7 +52,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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, @@ -57,10 +65,10 @@ def list( filter: Optional[str] = None, result_type: Optional[Union[str, "_models.ResultType"]] = None, **kwargs: Any - ) -> AsyncIterable[_models.MetricBaselinesResponse]: + ) -> AsyncIterable["_models.SingleMetricBaseline"]: """**Lists the metric baseline values for a resource**. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param metricnames: The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be @@ -94,31 +102,29 @@ def list( %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. Default value is None. :type filter: str :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. Default value is None. + information is retrieved. Known values are: "Data" and "Metadata". Default value is None. :type result_type: str or ~$(python-base-namespace).v2018_09_01.models.ResultType :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricBaselinesResponse or the result of + :return: An iterator like instance of either SingleMetricBaseline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_09_01.models.MetricBaselinesResponse] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_09_01.models.SingleMetricBaseline] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricBaselinesResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricBaselinesResponse] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, metricnames=metricnames, metricnamespace=metricnamespace, timespan=timespan, @@ -127,7 +133,8 @@ def prepare_request(next_link=None): sensitivities=sensitivities, filter=filter, result_type=result_type, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -135,22 +142,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - metricnames=metricnames, - metricnamespace=metricnamespace, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - filter=filter, - result_type=result_type, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -166,10 +162,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -180,8 +174,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py index 7ba604184e3f..fc2c3eb12f98 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py @@ -29,41 +29,39 @@ from ._models_py3 import VoiceReceiver from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import ( - BaselineSensitivity, - ReceiverStatus, - ResultType, -) +from ._monitor_management_client_enums import BaselineSensitivity +from ._monitor_management_client_enums import ReceiverStatus +from ._monitor_management_client_enums import ResultType from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupList', - 'ActionGroupPatchBody', - 'ActionGroupResource', - 'ArmRoleReceiver', - 'AutomationRunbookReceiver', - 'AzureAppPushReceiver', - 'AzureFunctionReceiver', - 'BaselineMetadata', - 'EmailReceiver', - 'EnableRequest', - 'ErrorResponse', - 'ItsmReceiver', - 'LogicAppReceiver', - 'MetricBaselinesResponse', - 'MetricSingleDimension', - 'Resource', - 'SingleBaseline', - 'SingleMetricBaseline', - 'SmsReceiver', - 'TimeSeriesBaseline', - 'VoiceReceiver', - 'WebhookReceiver', - 'BaselineSensitivity', - 'ReceiverStatus', - 'ResultType', + "ActionGroupList", + "ActionGroupPatchBody", + "ActionGroupResource", + "ArmRoleReceiver", + "AutomationRunbookReceiver", + "AzureAppPushReceiver", + "AzureFunctionReceiver", + "BaselineMetadata", + "EmailReceiver", + "EnableRequest", + "ErrorResponse", + "ItsmReceiver", + "LogicAppReceiver", + "MetricBaselinesResponse", + "MetricSingleDimension", + "Resource", + "SingleBaseline", + "SingleMetricBaseline", + "SmsReceiver", + "TimeSeriesBaseline", + "VoiceReceiver", + "WebhookReceiver", + "BaselineSensitivity", + "ReceiverStatus", + "ResultType", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py index d65938ee66f1..511771a35d97 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_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. @@ -9,15 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class ActionGroupList(msrest.serialization.Model): +class ActionGroupList(_serialization.Model): """A list of action groups. :ivar value: The list of action groups. @@ -27,16 +27,12 @@ class ActionGroupList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ActionGroupResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of action groups. @@ -44,15 +40,15 @@ def __init__( :keyword next_link: Provides the link to retrieve the next set of elements. :paramtype next_link: str """ - super(ActionGroupList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ActionGroupPatchBody(msrest.serialization.Model): +class ActionGroupPatchBody(_serialization.Model): """An action group object for the body of patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. @@ -60,30 +56,24 @@ class ActionGroupPatchBody(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - enabled: Optional[bool] = True, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. :paramtype enabled: bool """ - super(ActionGroupPatchBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.enabled = enabled -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -96,41 +86,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -138,7 +122,7 @@ def __init__( self.tags = tags -class ActionGroupResource(Resource): +class ActionGroupResource(Resource): # pylint: disable=too-many-instance-attributes """An action group resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -151,9 +135,9 @@ class ActionGroupResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar group_short_name: The short name of the action group. This will be used in SMS messages. :vartype group_short_name: str @@ -191,31 +175,34 @@ class ActionGroupResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "group_short_name": {"max_length": 12}, } _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}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'properties.armRoleReceivers', 'type': '[ArmRoleReceiver]'}, + "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}"}, + "group_short_name": {"key": "properties.groupShortName", "type": "str"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, + "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, + "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, + "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, + "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, + "automation_runbook_receivers": { + "key": "properties.automationRunbookReceivers", + "type": "[AutomationRunbookReceiver]", + }, + "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, + "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, + "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, + "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, } def __init__( @@ -224,7 +211,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, - enabled: Optional[bool] = True, + enabled: bool = True, email_receivers: Optional[List["_models.EmailReceiver"]] = None, sms_receivers: Optional[List["_models.SmsReceiver"]] = None, webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, @@ -238,9 +225,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword group_short_name: The short name of the action group. This will be used in SMS messages. @@ -280,7 +267,7 @@ def __init__( :paramtype arm_role_receivers: list[~$(python-base-namespace).v2018_09_01.models.ArmRoleReceiver] """ - super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled self.email_receivers = email_receivers @@ -295,60 +282,54 @@ def __init__( self.arm_role_receivers = arm_role_receivers -class ArmRoleReceiver(msrest.serialization.Model): +class ArmRoleReceiver(_serialization.Model): """An arm role receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the arm role receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the arm role receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar role_id: Required. The arm role id. + :ivar role_id: The arm role id. Required. :vartype role_id: str """ _validation = { - 'name': {'required': True}, - 'role_id': {'required': True}, + "name": {"required": True}, + "role_id": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, } - def __init__( - self, - *, - name: str, - role_id: str, - **kwargs - ): + def __init__(self, *, name: str, role_id: str, **kwargs): """ - :keyword name: Required. The name of the arm role receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the arm role receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword role_id: Required. The arm role id. + :keyword role_id: The arm role id. Required. :paramtype role_id: str """ - super(ArmRoleReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.role_id = role_id -class AutomationRunbookReceiver(msrest.serialization.Model): +class AutomationRunbookReceiver(_serialization.Model): """The Azure Automation Runbook notification receiver. All required parameters must be populated in order to send to Azure. - :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook - and authenticate to Azure resource. + :ivar automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :vartype automation_account_id: str - :ivar runbook_name: Required. The name for this runbook. + :ivar runbook_name: The name for this runbook. Required. :vartype runbook_name: str - :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. :vartype webhook_resource_id: str - :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. :vartype is_global_runbook: bool :ivar name: Indicates name of the webhook. :vartype name: str @@ -357,19 +338,19 @@ class AutomationRunbookReceiver(msrest.serialization.Model): """ _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, + "automation_account_id": {"required": True}, + "runbook_name": {"required": True}, + "webhook_resource_id": {"required": True}, + "is_global_runbook": {"required": True}, } _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, + "automation_account_id": {"key": "automationAccountId", "type": "str"}, + "runbook_name": {"key": "runbookName", "type": "str"}, + "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, + "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, } def __init__( @@ -384,21 +365,21 @@ def __init__( **kwargs ): """ - :keyword automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. + :keyword automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :paramtype automation_account_id: str - :keyword runbook_name: Required. The name for this runbook. + :keyword runbook_name: The name for this runbook. Required. :paramtype runbook_name: str - :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. :paramtype webhook_resource_id: str - :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. :paramtype is_global_runbook: bool :keyword name: Indicates name of the webhook. :paramtype name: str :keyword service_uri: The URI where webhooks should be sent. :paramtype service_uri: str """ - super(AutomationRunbookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name self.webhook_resource_id = webhook_resource_id @@ -407,224 +388,195 @@ def __init__( self.service_uri = service_uri -class AzureAppPushReceiver(msrest.serialization.Model): +class AzureAppPushReceiver(_serialization.Model): """The Azure mobile App push notification receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :vartype name: str - :ivar email_address: Required. The email address registered for the Azure mobile app. + :ivar email_address: The email address registered for the Azure mobile app. Required. :vartype email_address: str """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, + "name": {"required": True}, + "email_address": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, **kwargs): """ - :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address registered for the Azure mobile app. + :keyword email_address: The email address registered for the Azure mobile app. Required. :paramtype email_address: str """ - super(AzureAppPushReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address -class AzureFunctionReceiver(msrest.serialization.Model): +class AzureFunctionReceiver(_serialization.Model): """An azure function receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the azure function receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the azure function receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar function_app_resource_id: Required. The azure resource id of the function app. + :ivar function_app_resource_id: The azure resource id of the function app. Required. :vartype function_app_resource_id: str - :ivar function_name: Required. The function name in the function app. + :ivar function_name: The function name in the function app. Required. :vartype function_name: str - :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :ivar http_trigger_url: The http trigger url where http request sent to. Required. :vartype http_trigger_url: str """ _validation = { - 'name': {'required': True}, - 'function_app_resource_id': {'required': True}, - 'function_name': {'required': True}, - 'http_trigger_url': {'required': True}, + "name": {"required": True}, + "function_app_resource_id": {"required": True}, + "function_name": {"required": True}, + "http_trigger_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, - 'function_name': {'key': 'functionName', 'type': 'str'}, - 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, + "function_name": {"key": "functionName", "type": "str"}, + "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, } def __init__( - self, - *, - name: str, - function_app_resource_id: str, - function_name: str, - http_trigger_url: str, - **kwargs + self, *, name: str, function_app_resource_id: str, function_name: str, http_trigger_url: str, **kwargs ): """ - :keyword name: Required. The name of the azure function receiver. Names must be unique across - all receivers within an action group. + :keyword name: The name of the azure function receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword function_app_resource_id: Required. The azure resource id of the function app. + :keyword function_app_resource_id: The azure resource id of the function app. Required. :paramtype function_app_resource_id: str - :keyword function_name: Required. The function name in the function app. + :keyword function_name: The function name in the function app. Required. :paramtype function_name: str - :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :keyword http_trigger_url: The http trigger url where http request sent to. Required. :paramtype http_trigger_url: str """ - super(AzureFunctionReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.function_app_resource_id = function_app_resource_id self.function_name = function_name self.http_trigger_url = http_trigger_url -class BaselineMetadata(msrest.serialization.Model): +class BaselineMetadata(_serialization.Model): """Represents a baseline metadata value. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the baseline metadata. + :ivar name: Name of the baseline metadata. Required. :vartype name: str - :ivar value: Required. Value of the baseline metadata. + :ivar value: Value of the baseline metadata. Required. :vartype value: str """ _validation = { - 'name': {'required': True}, - 'value': {'required': True}, + "name": {"required": True}, + "value": {"required": 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, - *, - name: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, value: str, **kwargs): """ - :keyword name: Required. Name of the baseline metadata. + :keyword name: Name of the baseline metadata. Required. :paramtype name: str - :keyword value: Required. Value of the baseline metadata. + :keyword value: Value of the baseline metadata. Required. :paramtype value: str """ - super(BaselineMetadata, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class EmailReceiver(msrest.serialization.Model): +class EmailReceiver(_serialization.Model): """An email receiver. Variables are only 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 name: Required. The name of the email receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the email receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar email_address: Required. The email address of this receiver. + :ivar email_address: The email address of this receiver. Required. :vartype email_address: str :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - "Disabled". + and "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_09_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "email_address": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, **kwargs): """ - :keyword name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the email receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address of this receiver. + :keyword email_address: The email address of this receiver. Required. :paramtype email_address: str """ - super(EmailReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address self.status = None -class EnableRequest(msrest.serialization.Model): +class EnableRequest(_serialization.Model): """Describes a receiver that should be resubscribed. All required parameters must be populated in order to send to Azure. - :ivar receiver_name: Required. The name of the receiver to resubscribe. + :ivar receiver_name: The name of the receiver to resubscribe. Required. :vartype receiver_name: str """ _validation = { - 'receiver_name': {'required': True}, + "receiver_name": {"required": True}, } _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, + "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__( - self, - *, - receiver_name: str, - **kwargs - ): + def __init__(self, *, receiver_name: str, **kwargs): """ - :keyword receiver_name: Required. The name of the receiver to resubscribe. + :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str """ - super(EnableRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.receiver_name = receiver_name -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -634,92 +586,81 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ItsmReceiver(msrest.serialization.Model): +class ItsmReceiver(_serialization.Model): """An Itsm receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar workspace_id: Required. OMS LA instance identifier. + :ivar workspace_id: OMS LA instance identifier. Required. :vartype workspace_id: str - :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined - in above workspace. + :ivar connection_id: Unique identification of ITSM connection among multiple defined in above + workspace. Required. :vartype connection_id: str - :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :vartype ticket_configuration: str - :ivar region: Required. Region in which workspace resides. Supported + :ivar region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :vartype region: str """ _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, + "name": {"required": True}, + "workspace_id": {"required": True}, + "connection_id": {"required": True}, + "ticket_configuration": {"required": True}, + "region": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "connection_id": {"key": "connectionId", "type": "str"}, + "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, + "region": {"key": "region", "type": "str"}, } def __init__( - self, - *, - name: str, - workspace_id: str, - connection_id: str, - ticket_configuration: str, - region: str, - **kwargs + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs ): """ - :keyword name: Required. The name of the Itsm receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword workspace_id: Required. OMS LA instance identifier. + :keyword workspace_id: OMS LA instance identifier. Required. :paramtype workspace_id: str - :keyword connection_id: Required. Unique identification of ITSM connection among multiple - defined in above workspace. + :keyword connection_id: Unique identification of ITSM connection among multiple defined in + above workspace. Required. :paramtype connection_id: str - :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :paramtype ticket_configuration: str - :keyword region: Required. Region in which workspace resides. Supported + :keyword region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :paramtype region: str """ - super(ItsmReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.workspace_id = workspace_id self.connection_id = connection_id @@ -727,67 +668,60 @@ def __init__( self.region = region -class LogicAppReceiver(msrest.serialization.Model): +class LogicAppReceiver(_serialization.Model): """A logic app receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar resource_id: Required. The azure resource id of the logic app receiver. + :ivar resource_id: The azure resource id of the logic app receiver. Required. :vartype resource_id: str - :ivar callback_url: Required. The callback url where http request sent to. + :ivar callback_url: The callback url where http request sent to. Required. :vartype callback_url: str """ _validation = { - 'name': {'required': True}, - 'resource_id': {'required': True}, - 'callback_url': {'required': True}, + "name": {"required": True}, + "resource_id": {"required": True}, + "callback_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "callback_url": {"key": "callbackUrl", "type": "str"}, } - def __init__( - self, - *, - name: str, - resource_id: str, - callback_url: str, - **kwargs - ): + def __init__(self, *, name: str, resource_id: str, callback_url: str, **kwargs): """ - :keyword name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword resource_id: Required. The azure resource id of the logic app receiver. + :keyword resource_id: The azure resource id of the logic app receiver. Required. :paramtype resource_id: str - :keyword callback_url: Required. The callback url where http request sent to. + :keyword callback_url: The callback url where http request sent to. Required. :paramtype callback_url: str """ - super(LogicAppReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.resource_id = resource_id self.callback_url = callback_url -class MetricBaselinesResponse(msrest.serialization.Model): +class MetricBaselinesResponse(_serialization.Model): """A list of metric baselines. All required parameters must be populated in order to send to Azure. - :ivar timespan: Required. The timespan for which the data was retrieved. Its value consists of - two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned - back from what was originally requested. + :ivar timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. Required. :vartype timespan: str - :ivar interval: Required. The interval (window size) for which the metric data was returned in. - This may be adjusted in the future and returned back from what was originally requested. This - is not present if a metadata request was made. + :ivar interval: The interval (window size) for which the metric data was returned in. This may + be adjusted in the future and returned back from what was originally requested. This is not + present if a metadata request was made. Required. :vartype interval: ~datetime.timedelta :ivar namespace: The namespace of the metrics been queried. :vartype namespace: str @@ -796,15 +730,15 @@ class MetricBaselinesResponse(msrest.serialization.Model): """ _validation = { - 'timespan': {'required': True}, - 'interval': {'required': True}, + "timespan": {"required": True}, + "interval": {"required": True}, } _attribute_map = { - 'timespan': {'key': 'timespan', 'type': 'str'}, - 'interval': {'key': 'interval', 'type': 'duration'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[SingleMetricBaseline]'}, + "timespan": {"key": "timespan", "type": "str"}, + "interval": {"key": "interval", "type": "duration"}, + "namespace": {"key": "namespace", "type": "str"}, + "value": {"key": "value", "type": "[SingleMetricBaseline]"}, } def __init__( @@ -817,89 +751,83 @@ def __init__( **kwargs ): """ - :keyword timespan: Required. The timespan for which the data was retrieved. Its value consists - of two datetimes concatenated, separated by '/'. This may be adjusted in the future and - returned back from what was originally requested. + :keyword timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. Required. :paramtype timespan: str - :keyword interval: Required. The interval (window size) for which the metric data was returned - in. This may be adjusted in the future and returned back from what was originally requested. - This is not present if a metadata request was made. + :keyword interval: The interval (window size) for which the metric data was returned in. This + may be adjusted in the future and returned back from what was originally requested. This is + not present if a metadata request was made. Required. :paramtype interval: ~datetime.timedelta :keyword namespace: The namespace of the metrics been queried. :paramtype namespace: str :keyword value: The baseline for each time series that was queried. :paramtype value: list[~$(python-base-namespace).v2018_09_01.models.SingleMetricBaseline] """ - super(MetricBaselinesResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.timespan = timespan self.interval = interval self.namespace = namespace self.value = value -class MetricSingleDimension(msrest.serialization.Model): +class MetricSingleDimension(_serialization.Model): """The metric dimension name and value. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the dimension. + :ivar name: Name of the dimension. Required. :vartype name: str - :ivar value: Required. Value of the dimension. + :ivar value: Value of the dimension. Required. :vartype value: str """ _validation = { - 'name': {'required': True}, - 'value': {'required': True}, + "name": {"required": True}, + "value": {"required": 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, - *, - name: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, value: str, **kwargs): """ - :keyword name: Required. Name of the dimension. + :keyword name: Name of the dimension. Required. :paramtype name: str - :keyword value: Required. Value of the dimension. + :keyword value: Value of the dimension. Required. :paramtype value: str """ - super(MetricSingleDimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class SingleBaseline(msrest.serialization.Model): +class SingleBaseline(_serialization.Model): """The baseline values for a single sensitivity value. All required parameters must be populated in order to send to Azure. - :ivar sensitivity: Required. the sensitivity of the baseline. Known values are: "Low", - "Medium", "High". + :ivar sensitivity: the sensitivity of the baseline. Required. Known values are: "Low", + "Medium", and "High". :vartype sensitivity: str or ~$(python-base-namespace).v2018_09_01.models.BaselineSensitivity - :ivar low_thresholds: Required. The low thresholds of the baseline. + :ivar low_thresholds: The low thresholds of the baseline. Required. :vartype low_thresholds: list[float] - :ivar high_thresholds: Required. The high thresholds of the baseline. + :ivar high_thresholds: The high thresholds of the baseline. Required. :vartype high_thresholds: list[float] """ _validation = { - 'sensitivity': {'required': True}, - 'low_thresholds': {'required': True}, - 'high_thresholds': {'required': True}, + "sensitivity": {"required": True}, + "low_thresholds": {"required": True}, + "high_thresholds": {"required": True}, } _attribute_map = { - 'sensitivity': {'key': 'sensitivity', 'type': 'str'}, - 'low_thresholds': {'key': 'lowThresholds', 'type': '[float]'}, - 'high_thresholds': {'key': 'highThresholds', 'type': '[float]'}, + "sensitivity": {"key": "sensitivity", "type": "str"}, + "low_thresholds": {"key": "lowThresholds", "type": "[float]"}, + "high_thresholds": {"key": "highThresholds", "type": "[float]"}, } def __init__( @@ -911,161 +839,154 @@ def __init__( **kwargs ): """ - :keyword sensitivity: Required. the sensitivity of the baseline. Known values are: "Low", - "Medium", "High". + :keyword sensitivity: the sensitivity of the baseline. Required. Known values are: "Low", + "Medium", and "High". :paramtype sensitivity: str or ~$(python-base-namespace).v2018_09_01.models.BaselineSensitivity - :keyword low_thresholds: Required. The low thresholds of the baseline. + :keyword low_thresholds: The low thresholds of the baseline. Required. :paramtype low_thresholds: list[float] - :keyword high_thresholds: Required. The high thresholds of the baseline. + :keyword high_thresholds: The high thresholds of the baseline. Required. :paramtype high_thresholds: list[float] """ - super(SingleBaseline, self).__init__(**kwargs) + super().__init__(**kwargs) self.sensitivity = sensitivity self.low_thresholds = low_thresholds self.high_thresholds = high_thresholds -class SingleMetricBaseline(msrest.serialization.Model): +class SingleMetricBaseline(_serialization.Model): """The baseline results of a single metric. All required parameters must be populated in order to send to Azure. - :ivar id: Required. The metric baseline Id. + :ivar id: The metric baseline Id. Required. :vartype id: str - :ivar type: Required. The resource type of the metric baseline resource. + :ivar type: The resource type of the metric baseline resource. Required. :vartype type: str - :ivar metric_name: Required. The name of the metric for which the baselines were retrieved. + :ivar metric_name: The name of the metric for which the baselines were retrieved. Required. :vartype metric_name: str - :ivar baselines: Required. The baseline for each time series that was queried. + :ivar baselines: The baseline for each time series that was queried. Required. :vartype baselines: list[~$(python-base-namespace).v2018_09_01.models.TimeSeriesBaseline] """ _validation = { - 'id': {'required': True}, - 'type': {'required': True}, - 'metric_name': {'required': True}, - 'baselines': {'required': True}, + "id": {"required": True}, + "type": {"required": True}, + "metric_name": {"required": True}, + "baselines": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'baselines': {'key': 'baselines', 'type': '[TimeSeriesBaseline]'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metric_name": {"key": "metricName", "type": "str"}, + "baselines": {"key": "baselines", "type": "[TimeSeriesBaseline]"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin type: str, metric_name: str, baselines: List["_models.TimeSeriesBaseline"], **kwargs ): """ - :keyword id: Required. The metric baseline Id. + :keyword id: The metric baseline Id. Required. :paramtype id: str - :keyword type: Required. The resource type of the metric baseline resource. + :keyword type: The resource type of the metric baseline resource. Required. :paramtype type: str - :keyword metric_name: Required. The name of the metric for which the baselines were retrieved. + :keyword metric_name: The name of the metric for which the baselines were retrieved. Required. :paramtype metric_name: str - :keyword baselines: Required. The baseline for each time series that was queried. + :keyword baselines: The baseline for each time series that was queried. Required. :paramtype baselines: list[~$(python-base-namespace).v2018_09_01.models.TimeSeriesBaseline] """ - super(SingleMetricBaseline, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.metric_name = metric_name self.baselines = baselines -class SmsReceiver(msrest.serialization.Model): +class SmsReceiver(_serialization.Model): """An SMS receiver. Variables are only 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 name: Required. The name of the SMS receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the SMS receiver. + :ivar country_code: The country code of the SMS receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the SMS receiver. + :ivar phone_number: The phone number of the SMS receiver. Required. :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_09_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the SMS receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the SMS receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the SMS receiver. + :keyword country_code: The country code of the SMS receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the SMS receiver. + :keyword phone_number: The phone number of the SMS receiver. Required. :paramtype phone_number: str """ - super(SmsReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number self.status = None -class TimeSeriesBaseline(msrest.serialization.Model): +class TimeSeriesBaseline(_serialization.Model): """The baseline values for a single time series. All required parameters must be populated in order to send to Azure. - :ivar aggregation: Required. The aggregation type of the metric. + :ivar aggregation: The aggregation type of the metric. Required. :vartype aggregation: str :ivar dimensions: The dimensions of this time series. :vartype dimensions: list[~$(python-base-namespace).v2018_09_01.models.MetricSingleDimension] - :ivar timestamps: Required. The list of timestamps of the baselines. + :ivar timestamps: The list of timestamps of the baselines. Required. :vartype timestamps: list[~datetime.datetime] - :ivar data: Required. The baseline values for each sensitivity. + :ivar data: The baseline values for each sensitivity. Required. :vartype data: list[~$(python-base-namespace).v2018_09_01.models.SingleBaseline] :ivar metadata_values: The baseline metadata values. :vartype metadata_values: list[~$(python-base-namespace).v2018_09_01.models.BaselineMetadata] """ _validation = { - 'aggregation': {'required': True}, - 'timestamps': {'required': True}, - 'data': {'required': True}, + "aggregation": {"required": True}, + "timestamps": {"required": True}, + "data": {"required": True}, } _attribute_map = { - 'aggregation': {'key': 'aggregation', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricSingleDimension]'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - 'data': {'key': 'data', 'type': '[SingleBaseline]'}, - 'metadata_values': {'key': 'metadataValues', 'type': '[BaselineMetadata]'}, + "aggregation": {"key": "aggregation", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricSingleDimension]"}, + "timestamps": {"key": "timestamps", "type": "[iso-8601]"}, + "data": {"key": "data", "type": "[SingleBaseline]"}, + "metadata_values": {"key": "metadataValues", "type": "[BaselineMetadata]"}, } def __init__( @@ -1079,18 +1000,18 @@ def __init__( **kwargs ): """ - :keyword aggregation: Required. The aggregation type of the metric. + :keyword aggregation: The aggregation type of the metric. Required. :paramtype aggregation: str :keyword dimensions: The dimensions of this time series. :paramtype dimensions: list[~$(python-base-namespace).v2018_09_01.models.MetricSingleDimension] - :keyword timestamps: Required. The list of timestamps of the baselines. + :keyword timestamps: The list of timestamps of the baselines. Required. :paramtype timestamps: list[~datetime.datetime] - :keyword data: Required. The baseline values for each sensitivity. + :keyword data: The baseline values for each sensitivity. Required. :paramtype data: list[~$(python-base-namespace).v2018_09_01.models.SingleBaseline] :keyword metadata_values: The baseline metadata values. :paramtype metadata_values: list[~$(python-base-namespace).v2018_09_01.models.BaselineMetadata] """ - super(TimeSeriesBaseline, self).__init__(**kwargs) + super().__init__(**kwargs) self.aggregation = aggregation self.dimensions = dimensions self.timestamps = timestamps @@ -1098,91 +1019,78 @@ def __init__( self.metadata_values = metadata_values -class VoiceReceiver(msrest.serialization.Model): +class VoiceReceiver(_serialization.Model): """A voice receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the voice receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the voice receiver. + :ivar country_code: The country code of the voice receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the voice receiver. + :ivar phone_number: The phone number of the voice receiver. Required. :vartype phone_number: str """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the voice receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the voice receiver. + :keyword country_code: The country code of the voice receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the voice receiver. + :keyword phone_number: The phone number of the voice receiver. Required. :paramtype phone_number: str """ - super(VoiceReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number -class WebhookReceiver(msrest.serialization.Model): +class WebhookReceiver(_serialization.Model): """A webhook receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the webhook receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar service_uri: Required. The URI where webhooks should be sent. + :ivar service_uri: The URI where webhooks should be sent. Required. :vartype service_uri: str """ _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, + "name": {"required": True}, + "service_uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, } - def __init__( - self, - *, - name: str, - service_uri: str, - **kwargs - ): + def __init__(self, *, name: str, service_uri: str, **kwargs): """ - :keyword name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the webhook receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword service_uri: Required. The URI where webhooks should be sent. + :keyword service_uri: The URI where webhooks should be sent. Required. :paramtype service_uri: str """ - super(WebhookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.service_uri = service_uri diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py index c68a974106d7..bf08d44864b2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py @@ -11,13 +11,13 @@ class BaselineSensitivity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the sensitivity of the baseline. - """ + """the sensitivity of the baseline.""" LOW = "Low" MEDIUM = "Medium" HIGH = "High" + class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. @@ -27,7 +27,9 @@ class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): ENABLED = "Enabled" DISABLED = "Disabled" + class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ResultType.""" DATA = "Data" METADATA = "Metadata" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/__init__.py index 62e8fdde212b..15bdf6da240f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', - 'BaselinesOperations', + "ActionGroupsOperations", + "BaselinesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py index 4ff55d45bc51..0e48ff1b6aa2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,288 +25,243 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.ActionGroupResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - action_group_name: str, - *, - json: Optional[_models.ActionGroupPatchBody] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_id_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_enable_receiver_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.EnableRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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 ActionGroupsOperations: """ @@ -322,41 +282,105 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -365,7 +389,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -373,10 +398,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -385,55 +409,47 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -441,10 +457,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,52 +467,46 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -505,10 +514,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -519,52 +527,118 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2018_09_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2018_09_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -572,10 +646,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -583,46 +656,41 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -630,14 +698,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -653,10 +718,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -667,46 +730,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -714,15 +773,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -738,10 +793,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -752,47 +805,112 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore - @distributed_trace + @overload def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2018_09_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2018_09_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -801,7 +919,8 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -809,10 +928,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -823,5 +941,4 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baselines_operations.py index d9b20e2acce4..fc0482c39430 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baselines_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baselines_operations.py @@ -8,10 +8,15 @@ # -------------------------------------------------------------------------- import datetime from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -21,13 +26,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( resource_uri: str, *, @@ -44,46 +52,41 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricBaselines") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters if metricnames is not None: - _params['metricnames'] = _SERIALIZER.query("metricnames", metricnames, 'str') + _params["metricnames"] = _SERIALIZER.query("metricnames", metricnames, "str") if metricnamespace is not None: - _params['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') + _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") if timespan is not None: - _params['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") if interval is not None: - _params['interval'] = _SERIALIZER.query("interval", interval, 'duration') + _params["interval"] = _SERIALIZER.query("interval", interval, "duration") if aggregation is not None: - _params['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") if sensitivities is not None: - _params['sensitivities'] = _SERIALIZER.query("sensitivities", sensitivities, 'str') + _params["sensitivities"] = _SERIALIZER.query("sensitivities", sensitivities, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if result_type is not None: - _params['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["resultType"] = _SERIALIZER.query("result_type", result_type, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BaselinesOperations: """ @@ -104,7 +107,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, @@ -118,10 +120,10 @@ def list( filter: Optional[str] = None, result_type: Optional[Union[str, "_models.ResultType"]] = None, **kwargs: Any - ) -> Iterable[_models.MetricBaselinesResponse]: + ) -> Iterable["_models.SingleMetricBaseline"]: """**Lists the metric baseline values for a resource**. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param metricnames: The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be @@ -155,31 +157,29 @@ def list( %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. Default value is None. :type filter: str :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. Default value is None. + information is retrieved. Known values are: "Data" and "Metadata". Default value is None. :type result_type: str or ~$(python-base-namespace).v2018_09_01.models.ResultType :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricBaselinesResponse or the result of + :return: An iterator like instance of either SingleMetricBaseline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_09_01.models.MetricBaselinesResponse] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_09_01.models.SingleMetricBaseline] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricBaselinesResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricBaselinesResponse] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, metricnames=metricnames, metricnamespace=metricnamespace, timespan=timespan, @@ -188,7 +188,8 @@ def prepare_request(next_link=None): sensitivities=sensitivities, filter=filter, result_type=result_type, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -196,22 +197,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - metricnames=metricnames, - metricnamespace=metricnamespace, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - filter=filter, - result_type=result_type, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -227,10 +217,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -241,8 +229,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py index 3ae4f05c4eb6..acbc54026c7d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py @@ -25,43 +25,40 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 :keyword api_version: Api Version. Default value is "2018-11-27-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-11-27-preview") # type: str + api_version = kwargs.pop("api_version", "2018-11-27-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json index 4eda122cd5ec..0bbb96d82593 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json @@ -10,14 +10,14 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 } @@ -25,7 +25,7 @@ "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 } @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py index cfcad63da399..83cbac7247fa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import VMInsightsOperations @@ -22,13 +21,14 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar vm_insights: VMInsightsOperations operations :vartype vm_insights: $(python-base-namespace).v2018_11_27_preview.operations.VMInsightsOperations - :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 base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -38,10 +38,7 @@ class MonitorManagementClient: """ def __init__( - self, - credential: "TokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -50,16 +47,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.vm_insights = VMInsightsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.vm_insights = VMInsightsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -68,7 +58,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py index bb21c5db7403..14c0bea3671f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py @@ -25,42 +25,37 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 :keyword api_version: Api Version. Default value is "2018-11-27-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-11-27-preview") # type: str + api_version = kwargs.pop("api_version", "2018-11-27-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py index b6d69e9d5b2c..19eea0780dee 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import VMInsightsOperations @@ -22,13 +21,14 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar vm_insights: VMInsightsOperations operations :vartype vm_insights: $(python-base-namespace).v2018_11_27_preview.aio.operations.VMInsightsOperations - :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 base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -38,10 +38,7 @@ class MonitorManagementClient: """ def __init__( - self, - credential: "AsyncTokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -50,16 +47,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.vm_insights = VMInsightsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.vm_insights = VMInsightsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -68,7 +58,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/__init__.py index 5e4c85044f19..c49e28cd308f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'VMInsightsOperations', + "VMInsightsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py index 8c05069a0516..240e24b164db 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._vm_insights_operations import build_get_onboarding_status_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class VMInsightsOperations: """ .. warning:: @@ -41,39 +49,31 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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_onboarding_status( - self, - resource_uri: str, - **kwargs: Any - ) -> _models.VMInsightsOnboardingStatus: + async def get_onboarding_status(self, resource_uri: str, **kwargs: Any) -> _models.VMInsightsOnboardingStatus: """Retrieves the VM Insights onboarding status for the specified resource or resource scope. :param resource_uri: The fully qualified Azure Resource manager identifier of the resource, or - scope, whose status to retrieve. + scope, whose status to retrieve. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VMInsightsOnboardingStatus, or the result of cls(response) + :return: VMInsightsOnboardingStatus or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_11_27_preview.models.VMInsightsOnboardingStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-27-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VMInsightsOnboardingStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-27-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VMInsightsOnboardingStatus] - request = build_get_onboarding_status_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.get_onboarding_status.metadata['url'], + template_url=self.get_onboarding_status.metadata["url"], headers=_headers, params=_params, ) @@ -81,10 +81,9 @@ async def get_onboarding_status( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,12 +91,11 @@ async def get_onboarding_status( error = self._deserialize.failsafe_deserialize(_models.ResponseWithError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('VMInsightsOnboardingStatus', pipeline_response) + deserialized = self._deserialize("VMInsightsOnboardingStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_onboarding_status.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default"} # type: ignore - + get_onboarding_status.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py index bee6c414166c..c43be904632c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py @@ -13,23 +13,21 @@ from ._models_py3 import VMInsightsOnboardingStatus from ._models_py3 import WorkspaceInfo - -from ._monitor_management_client_enums import ( - DataStatus, - OnboardingStatus, -) +from ._monitor_management_client_enums import DataStatus +from ._monitor_management_client_enums import OnboardingStatus from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DataContainer', - 'Error', - 'ProxyResource', - 'ResponseWithError', - 'VMInsightsOnboardingStatus', - 'WorkspaceInfo', - 'DataStatus', - 'OnboardingStatus', + "DataContainer", + "Error", + "ProxyResource", + "ResponseWithError", + "VMInsightsOnboardingStatus", + "WorkspaceInfo", + "DataStatus", + "OnboardingStatus", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py index a3cc7d54ec74..bf881bf182e5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_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. @@ -8,84 +9,72 @@ from typing import List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class DataContainer(msrest.serialization.Model): +class DataContainer(_serialization.Model): """Information about a container with data for a given resource. All required parameters must be populated in order to send to Azure. - :ivar workspace: Required. Log Analytics workspace information. + :ivar workspace: Log Analytics workspace information. Required. :vartype workspace: ~$(python-base-namespace).v2018_11_27_preview.models.WorkspaceInfo """ _validation = { - 'workspace': {'required': True}, + "workspace": {"required": True}, } _attribute_map = { - 'workspace': {'key': 'workspace', 'type': 'WorkspaceInfo'}, + "workspace": {"key": "workspace", "type": "WorkspaceInfo"}, } - def __init__( - self, - *, - workspace: "_models.WorkspaceInfo", - **kwargs - ): + def __init__(self, *, workspace: "_models.WorkspaceInfo", **kwargs): """ - :keyword workspace: Required. Log Analytics workspace information. + :keyword workspace: Log Analytics workspace information. Required. :paramtype workspace: ~$(python-base-namespace).v2018_11_27_preview.models.WorkspaceInfo """ - super(DataContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.workspace = workspace -class Error(msrest.serialization.Model): +class Error(_serialization.Model): """Error details. All required parameters must be populated in order to send to Azure. - :ivar code: Required. Error code identifying the specific error. + :ivar code: Error code identifying the specific error. Required. :vartype code: str :ivar message: Error message in the caller's locale. :vartype message: str """ _validation = { - 'code': {'required': True}, + "code": {"required": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: str, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: str, message: Optional[str] = None, **kwargs): """ - :keyword code: Required. Error code identifying the specific error. + :keyword code: Error code identifying the specific error. Required. :paramtype code: str :keyword message: Error message in the caller's locale. :paramtype message: str """ - super(Error, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -99,57 +88,48 @@ class ProxyResource(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(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None -class ResponseWithError(msrest.serialization.Model): +class ResponseWithError(_serialization.Model): """An error response from the API. All required parameters must be populated in order to send to Azure. - :ivar error: Required. Error information. + :ivar error: Error information. Required. :vartype error: ~$(python-base-namespace).v2018_11_27_preview.models.Error """ _validation = { - 'error': {'required': True}, + "error": {"required": True}, } _attribute_map = { - 'error': {'key': 'error', 'type': 'Error'}, + "error": {"key": "error", "type": "Error"}, } - def __init__( - self, - *, - error: "_models.Error", - **kwargs - ): + def __init__(self, *, error: "_models.Error", **kwargs): """ - :keyword error: Required. Error information. + :keyword error: Error information. Required. :paramtype error: ~$(python-base-namespace).v2018_11_27_preview.models.Error """ - super(ResponseWithError, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error @@ -169,31 +149,31 @@ class VMInsightsOnboardingStatus(ProxyResource): :vartype resource_id: str :ivar onboarding_status: The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource - under it is onboarded. Known values are: "onboarded", "notOnboarded", "unknown". + under it is onboarded. Known values are: "onboarded", "notOnboarded", and "unknown". :vartype onboarding_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.OnboardingStatus :ivar data_status: The status of VM Insights data from the resource. When reported as ``present`` the data array will contain information about the data containers to which data for - the specified resource is being routed. Known values are: "present", "notPresent". + the specified resource is being routed. Known values are: "present" and "notPresent". :vartype data_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.DataStatus :ivar data: Containers that currently store VM Insights data for the specified resource. :vartype data: list[~$(python-base-namespace).v2018_11_27_preview.models.DataContainer] """ _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'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - 'onboarding_status': {'key': 'properties.onboardingStatus', 'type': 'str'}, - 'data_status': {'key': 'properties.dataStatus', 'type': 'str'}, - 'data': {'key': 'properties.data', 'type': '[DataContainer]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "resource_id": {"key": "properties.resourceId", "type": "str"}, + "onboarding_status": {"key": "properties.onboardingStatus", "type": "str"}, + "data_status": {"key": "properties.dataStatus", "type": "str"}, + "data": {"key": "properties.data", "type": "[DataContainer]"}, } def __init__( @@ -211,65 +191,58 @@ def __init__( :paramtype resource_id: str :keyword onboarding_status: The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource - under it is onboarded. Known values are: "onboarded", "notOnboarded", "unknown". + under it is onboarded. Known values are: "onboarded", "notOnboarded", and "unknown". :paramtype onboarding_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.OnboardingStatus :keyword data_status: The status of VM Insights data from the resource. When reported as ``present`` the data array will contain information about the data containers to which data for - the specified resource is being routed. Known values are: "present", "notPresent". + the specified resource is being routed. Known values are: "present" and "notPresent". :paramtype data_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.DataStatus :keyword data: Containers that currently store VM Insights data for the specified resource. :paramtype data: list[~$(python-base-namespace).v2018_11_27_preview.models.DataContainer] """ - super(VMInsightsOnboardingStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_id = resource_id self.onboarding_status = onboarding_status self.data_status = data_status self.data = data -class WorkspaceInfo(msrest.serialization.Model): +class WorkspaceInfo(_serialization.Model): """Information about a Log Analytics Workspace. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Azure Resource Manager identifier of the Log Analytics Workspace. + :ivar id: Azure Resource Manager identifier of the Log Analytics Workspace. Required. :vartype id: str - :ivar location: Required. Location of the Log Analytics workspace. + :ivar location: Location of the Log Analytics workspace. Required. :vartype location: str - :ivar customer_id: Required. Log Analytics workspace identifier. + :ivar customer_id: Log Analytics workspace identifier. Required. :vartype customer_id: str """ _validation = { - 'id': {'required': True}, - 'location': {'required': True}, - 'customer_id': {'required': True}, + "id": {"required": True}, + "location": {"required": True}, + "customer_id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'customer_id': {'key': 'properties.customerId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "customer_id": {"key": "properties.customerId", "type": "str"}, } - def __init__( - self, - *, - id: str, - location: str, - customer_id: str, - **kwargs - ): + def __init__(self, *, id: str, location: str, customer_id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Azure Resource Manager identifier of the Log Analytics Workspace. + :keyword id: Azure Resource Manager identifier of the Log Analytics Workspace. Required. :paramtype id: str - :keyword location: Required. Location of the Log Analytics workspace. + :keyword location: Location of the Log Analytics workspace. Required. :paramtype location: str - :keyword customer_id: Required. Log Analytics workspace identifier. + :keyword customer_id: Log Analytics workspace identifier. Required. :paramtype customer_id: str """ - super(WorkspaceInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.location = location self.customer_id = customer_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py index 0dc94d4b599e..b1ee153b301c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py @@ -19,6 +19,7 @@ class DataStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): PRESENT = "present" NOT_PRESENT = "notPresent" + class OnboardingStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource under it is onboarded. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/__init__.py index 5e4c85044f19..c49e28cd308f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'VMInsightsOperations', + "VMInsightsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py index 273157392acd..d889eba706e2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,44 +23,41 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_onboarding_status_request( - resource_uri: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_onboarding_status_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-27-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-27-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default") + _url = kwargs.pop( + "template_url", "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default" + ) path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class VMInsightsOperations: """ @@ -77,39 +78,31 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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_onboarding_status( - self, - resource_uri: str, - **kwargs: Any - ) -> _models.VMInsightsOnboardingStatus: + def get_onboarding_status(self, resource_uri: str, **kwargs: Any) -> _models.VMInsightsOnboardingStatus: """Retrieves the VM Insights onboarding status for the specified resource or resource scope. :param resource_uri: The fully qualified Azure Resource manager identifier of the resource, or - scope, whose status to retrieve. + scope, whose status to retrieve. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VMInsightsOnboardingStatus, or the result of cls(response) + :return: VMInsightsOnboardingStatus or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_11_27_preview.models.VMInsightsOnboardingStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-27-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VMInsightsOnboardingStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-27-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VMInsightsOnboardingStatus] - request = build_get_onboarding_status_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.get_onboarding_status.metadata['url'], + template_url=self.get_onboarding_status.metadata["url"], headers=_headers, params=_params, ) @@ -117,10 +110,9 @@ def get_onboarding_status( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,12 +120,11 @@ def get_onboarding_status( error = self._deserialize.failsafe_deserialize(_models.ResponseWithError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('VMInsightsOnboardingStatus', pipeline_response) + deserialized = self._deserialize("VMInsightsOnboardingStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_onboarding_status.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default"} # type: ignore - + get_onboarding_status.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py index 3911a9297d3d..8d2286410a6a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. 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: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", "2019-03-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json index 26b88ebb750e..38479b2f6c2b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py index 5a0b47ac2e83..f6196670f808 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, BaselinesOperations @@ -22,16 +21,17 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2019_03_01.operations.ActionGroupsOperations :ivar baselines: BaselinesOperations operations :vartype baselines: $(python-base-namespace).v2019_03_01.operations.BaselinesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -47,26 +47,19 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.baselines = BaselinesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -75,7 +68,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py index e20c8250f686..d02e2a974c4d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop("api_version", "2019-03-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py index 4596f73b543e..10552ea91e3b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, BaselinesOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations @@ -30,9 +30,9 @@ class MonitorManagementClient: $(python-base-namespace).v2019_03_01.aio.operations.ActionGroupsOperations :ivar baselines: BaselinesOperations operations :vartype baselines: $(python-base-namespace).v2019_03_01.aio.operations.BaselinesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -48,26 +48,19 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.baselines = BaselinesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -76,7 +69,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/__init__.py index 62e8fdde212b..15bdf6da240f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', - 'BaselinesOperations', + "ActionGroupsOperations", + "BaselinesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py index b0e110f90588..d98d3eea5ec7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._action_groups_operations import build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_request -T = TypeVar('T') +from ...operations._action_groups_operations import ( + build_create_or_update_request, + build_delete_request, + build_enable_receiver_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ActionGroupsOperations: """ .. warning:: @@ -43,41 +60,105 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -86,7 +167,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -94,10 +176,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -106,55 +187,47 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -162,10 +235,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,52 +245,46 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -226,10 +292,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -240,52 +305,118 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2019_03_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2019_03_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -293,10 +424,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -304,46 +434,41 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -351,14 +476,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -374,10 +496,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -388,46 +508,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -435,15 +551,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -459,10 +571,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -473,47 +583,112 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore - @distributed_trace_async + @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2019_03_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2019_03_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -522,7 +697,8 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +706,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -544,5 +719,4 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py index 6e677f3f862b..6db5746075a5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py @@ -8,9 +8,16 @@ # -------------------------------------------------------------------------- import datetime from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +28,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._baselines_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BaselinesOperations: """ .. warning:: @@ -43,7 +52,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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, @@ -57,10 +65,10 @@ def list( filter: Optional[str] = None, result_type: Optional[Union[str, "_models.ResultType"]] = None, **kwargs: Any - ) -> AsyncIterable[_models.MetricBaselinesResponse]: + ) -> AsyncIterable["_models.SingleMetricBaseline"]: """**Lists the metric baseline values for a resource**. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param metricnames: The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be @@ -94,31 +102,29 @@ def list( %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. Default value is None. :type filter: str :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. Default value is None. + information is retrieved. Known values are: "Data" and "Metadata". Default value is None. :type result_type: str or ~$(python-base-namespace).v2019_03_01.models.ResultType :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricBaselinesResponse or the result of + :return: An iterator like instance of either SingleMetricBaseline or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.MetricBaselinesResponse] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.SingleMetricBaseline] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricBaselinesResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricBaselinesResponse] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, metricnames=metricnames, metricnamespace=metricnamespace, timespan=timespan, @@ -127,7 +133,8 @@ def prepare_request(next_link=None): sensitivities=sensitivities, filter=filter, result_type=result_type, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -135,22 +142,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - metricnames=metricnames, - metricnamespace=metricnamespace, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - filter=filter, - result_type=result_type, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -166,10 +162,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -180,8 +174,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py index c66b69ce31cd..6020f789616f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py @@ -29,41 +29,39 @@ from ._models_py3 import VoiceReceiver from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import ( - BaselineSensitivity, - ReceiverStatus, - ResultType, -) +from ._monitor_management_client_enums import BaselineSensitivity +from ._monitor_management_client_enums import ReceiverStatus +from ._monitor_management_client_enums import ResultType from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupList', - 'ActionGroupPatchBody', - 'ActionGroupResource', - 'ArmRoleReceiver', - 'AutomationRunbookReceiver', - 'AzureAppPushReceiver', - 'AzureFunctionReceiver', - 'AzureResource', - 'BaselineMetadata', - 'EmailReceiver', - 'EnableRequest', - 'ErrorResponse', - 'ItsmReceiver', - 'LogicAppReceiver', - 'MetricBaselinesResponse', - 'MetricSingleDimension', - 'SingleBaseline', - 'SingleMetricBaseline', - 'SmsReceiver', - 'TimeSeriesBaseline', - 'VoiceReceiver', - 'WebhookReceiver', - 'BaselineSensitivity', - 'ReceiverStatus', - 'ResultType', + "ActionGroupList", + "ActionGroupPatchBody", + "ActionGroupResource", + "ArmRoleReceiver", + "AutomationRunbookReceiver", + "AzureAppPushReceiver", + "AzureFunctionReceiver", + "AzureResource", + "BaselineMetadata", + "EmailReceiver", + "EnableRequest", + "ErrorResponse", + "ItsmReceiver", + "LogicAppReceiver", + "MetricBaselinesResponse", + "MetricSingleDimension", + "SingleBaseline", + "SingleMetricBaseline", + "SmsReceiver", + "TimeSeriesBaseline", + "VoiceReceiver", + "WebhookReceiver", + "BaselineSensitivity", + "ReceiverStatus", + "ResultType", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py index f7ca10c5a949..051dbc824eae 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/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. @@ -9,15 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class ActionGroupList(msrest.serialization.Model): +class ActionGroupList(_serialization.Model): """A list of action groups. :ivar value: The list of action groups. @@ -27,16 +27,12 @@ class ActionGroupList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ActionGroupResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of action groups. @@ -44,15 +40,15 @@ def __init__( :keyword next_link: Provides the link to retrieve the next set of elements. :paramtype next_link: str """ - super(ActionGroupList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ActionGroupPatchBody(msrest.serialization.Model): +class ActionGroupPatchBody(_serialization.Model): """An action group object for the body of patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. @@ -60,30 +56,24 @@ class ActionGroupPatchBody(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - enabled: Optional[bool] = True, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. :paramtype enabled: bool """ - super(ActionGroupPatchBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.enabled = enabled -class AzureResource(msrest.serialization.Model): +class AzureResource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -96,41 +86,35 @@ class AzureResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(AzureResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -138,7 +122,7 @@ def __init__( self.tags = tags -class ActionGroupResource(AzureResource): +class ActionGroupResource(AzureResource): # pylint: disable=too-many-instance-attributes """An action group resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -151,9 +135,9 @@ class ActionGroupResource(AzureResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar group_short_name: The short name of the action group. This will be used in SMS messages. :vartype group_short_name: str @@ -191,31 +175,34 @@ class ActionGroupResource(AzureResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "group_short_name": {"max_length": 12}, } _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}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'properties.armRoleReceivers', 'type': '[ArmRoleReceiver]'}, + "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}"}, + "group_short_name": {"key": "properties.groupShortName", "type": "str"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, + "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, + "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, + "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, + "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, + "automation_runbook_receivers": { + "key": "properties.automationRunbookReceivers", + "type": "[AutomationRunbookReceiver]", + }, + "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, + "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, + "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, + "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, } def __init__( @@ -224,7 +211,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, - enabled: Optional[bool] = True, + enabled: bool = True, email_receivers: Optional[List["_models.EmailReceiver"]] = None, sms_receivers: Optional[List["_models.SmsReceiver"]] = None, webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, @@ -238,9 +225,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword group_short_name: The short name of the action group. This will be used in SMS messages. @@ -280,7 +267,7 @@ def __init__( :paramtype arm_role_receivers: list[~$(python-base-namespace).v2019_03_01.models.ArmRoleReceiver] """ - super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled self.email_receivers = email_receivers @@ -295,67 +282,60 @@ def __init__( self.arm_role_receivers = arm_role_receivers -class ArmRoleReceiver(msrest.serialization.Model): +class ArmRoleReceiver(_serialization.Model): """An arm role receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the arm role receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the arm role receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar role_id: Required. The arm role id. + :ivar role_id: The arm role id. Required. :vartype role_id: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'role_id': {'required': True}, + "name": {"required": True}, + "role_id": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } - def __init__( - self, - *, - name: str, - role_id: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs): """ - :keyword name: Required. The name of the arm role receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the arm role receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword role_id: Required. The arm role id. + :keyword role_id: The arm role id. Required. :paramtype role_id: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(ArmRoleReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.role_id = role_id self.use_common_alert_schema = use_common_alert_schema -class AutomationRunbookReceiver(msrest.serialization.Model): +class AutomationRunbookReceiver(_serialization.Model): """The Azure Automation Runbook notification receiver. All required parameters must be populated in order to send to Azure. - :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook - and authenticate to Azure resource. + :ivar automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :vartype automation_account_id: str - :ivar runbook_name: Required. The name for this runbook. + :ivar runbook_name: The name for this runbook. Required. :vartype runbook_name: str - :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. :vartype webhook_resource_id: str - :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. :vartype is_global_runbook: bool :ivar name: Indicates name of the webhook. :vartype name: str @@ -366,20 +346,20 @@ class AutomationRunbookReceiver(msrest.serialization.Model): """ _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, + "automation_account_id": {"required": True}, + "runbook_name": {"required": True}, + "webhook_resource_id": {"required": True}, + "is_global_runbook": {"required": True}, } _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "automation_account_id": {"key": "automationAccountId", "type": "str"}, + "runbook_name": {"key": "runbookName", "type": "str"}, + "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, + "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( @@ -391,18 +371,18 @@ def __init__( is_global_runbook: bool, name: Optional[str] = None, service_uri: Optional[str] = None, - use_common_alert_schema: Optional[bool] = False, + use_common_alert_schema: bool = False, **kwargs ): """ - :keyword automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. + :keyword automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :paramtype automation_account_id: str - :keyword runbook_name: Required. The name for this runbook. + :keyword runbook_name: The name for this runbook. Required. :paramtype runbook_name: str - :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. :paramtype webhook_resource_id: str - :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. :paramtype is_global_runbook: bool :keyword name: Indicates name of the webhook. :paramtype name: str @@ -411,7 +391,7 @@ def __init__( :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(AutomationRunbookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name self.webhook_resource_id = webhook_resource_id @@ -421,78 +401,72 @@ def __init__( self.use_common_alert_schema = use_common_alert_schema -class AzureAppPushReceiver(msrest.serialization.Model): +class AzureAppPushReceiver(_serialization.Model): """The Azure mobile App push notification receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :vartype name: str - :ivar email_address: Required. The email address registered for the Azure mobile app. + :ivar email_address: The email address registered for the Azure mobile app. Required. :vartype email_address: str """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, + "name": {"required": True}, + "email_address": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, **kwargs): """ - :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address registered for the Azure mobile app. + :keyword email_address: The email address registered for the Azure mobile app. Required. :paramtype email_address: str """ - super(AzureAppPushReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address -class AzureFunctionReceiver(msrest.serialization.Model): +class AzureFunctionReceiver(_serialization.Model): """An azure function receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the azure function receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the azure function receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar function_app_resource_id: Required. The azure resource id of the function app. + :ivar function_app_resource_id: The azure resource id of the function app. Required. :vartype function_app_resource_id: str - :ivar function_name: Required. The function name in the function app. + :ivar function_name: The function name in the function app. Required. :vartype function_name: str - :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :ivar http_trigger_url: The http trigger url where http request sent to. Required. :vartype http_trigger_url: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'function_app_resource_id': {'required': True}, - 'function_name': {'required': True}, - 'http_trigger_url': {'required': True}, + "name": {"required": True}, + "function_app_resource_id": {"required": True}, + "function_name": {"required": True}, + "http_trigger_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, - 'function_name': {'key': 'functionName', 'type': 'str'}, - 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, + "function_name": {"key": "functionName", "type": "str"}, + "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( @@ -502,23 +476,23 @@ def __init__( function_app_resource_id: str, function_name: str, http_trigger_url: str, - use_common_alert_schema: Optional[bool] = False, + use_common_alert_schema: bool = False, **kwargs ): """ - :keyword name: Required. The name of the azure function receiver. Names must be unique across - all receivers within an action group. + :keyword name: The name of the azure function receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword function_app_resource_id: Required. The azure resource id of the function app. + :keyword function_app_resource_id: The azure resource id of the function app. Required. :paramtype function_app_resource_id: str - :keyword function_name: Required. The function name in the function app. + :keyword function_name: The function name in the function app. Required. :paramtype function_name: str - :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :keyword http_trigger_url: The http trigger url where http request sent to. Required. :paramtype http_trigger_url: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(AzureFunctionReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.function_app_resource_id = function_app_resource_id self.function_name = function_name @@ -526,133 +500,115 @@ def __init__( self.use_common_alert_schema = use_common_alert_schema -class BaselineMetadata(msrest.serialization.Model): +class BaselineMetadata(_serialization.Model): """Represents a baseline metadata value. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the baseline metadata. + :ivar name: Name of the baseline metadata. Required. :vartype name: str - :ivar value: Required. Value of the baseline metadata. + :ivar value: Value of the baseline metadata. Required. :vartype value: str """ _validation = { - 'name': {'required': True}, - 'value': {'required': True}, + "name": {"required": True}, + "value": {"required": 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, - *, - name: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, value: str, **kwargs): """ - :keyword name: Required. Name of the baseline metadata. + :keyword name: Name of the baseline metadata. Required. :paramtype name: str - :keyword value: Required. Value of the baseline metadata. + :keyword value: Value of the baseline metadata. Required. :paramtype value: str """ - super(BaselineMetadata, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class EmailReceiver(msrest.serialization.Model): +class EmailReceiver(_serialization.Model): """An email receiver. Variables are only 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 name: Required. The name of the email receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the email receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar email_address: Required. The email address of this receiver. + :ivar email_address: The email address of this receiver. Required. :vartype email_address: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - "Disabled". + and "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_03_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "email_address": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs): """ - :keyword name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the email receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address of this receiver. + :keyword email_address: The email address of this receiver. Required. :paramtype email_address: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(EmailReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address self.use_common_alert_schema = use_common_alert_schema self.status = None -class EnableRequest(msrest.serialization.Model): +class EnableRequest(_serialization.Model): """Describes a receiver that should be resubscribed. All required parameters must be populated in order to send to Azure. - :ivar receiver_name: Required. The name of the receiver to resubscribe. + :ivar receiver_name: The name of the receiver to resubscribe. Required. :vartype receiver_name: str """ _validation = { - 'receiver_name': {'required': True}, + "receiver_name": {"required": True}, } _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, + "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__( - self, - *, - receiver_name: str, - **kwargs - ): + def __init__(self, *, receiver_name: str, **kwargs): """ - :keyword receiver_name: Required. The name of the receiver to resubscribe. + :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str """ - super(EnableRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.receiver_name = receiver_name -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -662,92 +618,81 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ItsmReceiver(msrest.serialization.Model): +class ItsmReceiver(_serialization.Model): """An Itsm receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar workspace_id: Required. OMS LA instance identifier. + :ivar workspace_id: OMS LA instance identifier. Required. :vartype workspace_id: str - :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined - in above workspace. + :ivar connection_id: Unique identification of ITSM connection among multiple defined in above + workspace. Required. :vartype connection_id: str - :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :vartype ticket_configuration: str - :ivar region: Required. Region in which workspace resides. Supported + :ivar region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :vartype region: str """ _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, + "name": {"required": True}, + "workspace_id": {"required": True}, + "connection_id": {"required": True}, + "ticket_configuration": {"required": True}, + "region": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "connection_id": {"key": "connectionId", "type": "str"}, + "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, + "region": {"key": "region", "type": "str"}, } def __init__( - self, - *, - name: str, - workspace_id: str, - connection_id: str, - ticket_configuration: str, - region: str, - **kwargs + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs ): """ - :keyword name: Required. The name of the Itsm receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword workspace_id: Required. OMS LA instance identifier. + :keyword workspace_id: OMS LA instance identifier. Required. :paramtype workspace_id: str - :keyword connection_id: Required. Unique identification of ITSM connection among multiple - defined in above workspace. + :keyword connection_id: Unique identification of ITSM connection among multiple defined in + above workspace. Required. :paramtype connection_id: str - :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :paramtype ticket_configuration: str - :keyword region: Required. Region in which workspace resides. Supported + :keyword region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :paramtype region: str """ - super(ItsmReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.workspace_id = workspace_id self.connection_id = connection_id @@ -755,63 +700,57 @@ def __init__( self.region = region -class LogicAppReceiver(msrest.serialization.Model): +class LogicAppReceiver(_serialization.Model): """A logic app receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar resource_id: Required. The azure resource id of the logic app receiver. + :ivar resource_id: The azure resource id of the logic app receiver. Required. :vartype resource_id: str - :ivar callback_url: Required. The callback url where http request sent to. + :ivar callback_url: The callback url where http request sent to. Required. :vartype callback_url: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'resource_id': {'required': True}, - 'callback_url': {'required': True}, + "name": {"required": True}, + "resource_id": {"required": True}, + "callback_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "callback_url": {"key": "callbackUrl", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( - self, - *, - name: str, - resource_id: str, - callback_url: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs + self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs ): """ - :keyword name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword resource_id: Required. The azure resource id of the logic app receiver. + :keyword resource_id: The azure resource id of the logic app receiver. Required. :paramtype resource_id: str - :keyword callback_url: Required. The callback url where http request sent to. + :keyword callback_url: The callback url where http request sent to. Required. :paramtype callback_url: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(LogicAppReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.resource_id = resource_id self.callback_url = callback_url self.use_common_alert_schema = use_common_alert_schema -class MetricBaselinesResponse(msrest.serialization.Model): +class MetricBaselinesResponse(_serialization.Model): """A list of metric baselines. :ivar value: The list of metric baselines. @@ -819,86 +758,75 @@ class MetricBaselinesResponse(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SingleMetricBaseline]'}, + "value": {"key": "value", "type": "[SingleMetricBaseline]"}, } - def __init__( - self, - *, - value: Optional[List["_models.SingleMetricBaseline"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SingleMetricBaseline"]] = None, **kwargs): """ :keyword value: The list of metric baselines. :paramtype value: list[~$(python-base-namespace).v2019_03_01.models.SingleMetricBaseline] """ - super(MetricBaselinesResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class MetricSingleDimension(msrest.serialization.Model): +class MetricSingleDimension(_serialization.Model): """The metric dimension name and value. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the dimension. + :ivar name: Name of the dimension. Required. :vartype name: str - :ivar value: Required. Value of the dimension. + :ivar value: Value of the dimension. Required. :vartype value: str """ _validation = { - 'name': {'required': True}, - 'value': {'required': True}, + "name": {"required": True}, + "value": {"required": 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, - *, - name: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, value: str, **kwargs): """ - :keyword name: Required. Name of the dimension. + :keyword name: Name of the dimension. Required. :paramtype name: str - :keyword value: Required. Value of the dimension. + :keyword value: Value of the dimension. Required. :paramtype value: str """ - super(MetricSingleDimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class SingleBaseline(msrest.serialization.Model): +class SingleBaseline(_serialization.Model): """The baseline values for a single sensitivity value. All required parameters must be populated in order to send to Azure. - :ivar sensitivity: Required. the sensitivity of the baseline. Known values are: "Low", - "Medium", "High". + :ivar sensitivity: the sensitivity of the baseline. Required. Known values are: "Low", + "Medium", and "High". :vartype sensitivity: str or ~$(python-base-namespace).v2019_03_01.models.BaselineSensitivity - :ivar low_thresholds: Required. The low thresholds of the baseline. + :ivar low_thresholds: The low thresholds of the baseline. Required. :vartype low_thresholds: list[float] - :ivar high_thresholds: Required. The high thresholds of the baseline. + :ivar high_thresholds: The high thresholds of the baseline. Required. :vartype high_thresholds: list[float] """ _validation = { - 'sensitivity': {'required': True}, - 'low_thresholds': {'required': True}, - 'high_thresholds': {'required': True}, + "sensitivity": {"required": True}, + "low_thresholds": {"required": True}, + "high_thresholds": {"required": True}, } _attribute_map = { - 'sensitivity': {'key': 'sensitivity', 'type': 'str'}, - 'low_thresholds': {'key': 'lowThresholds', 'type': '[float]'}, - 'high_thresholds': {'key': 'highThresholds', 'type': '[float]'}, + "sensitivity": {"key": "sensitivity", "type": "str"}, + "low_thresholds": {"key": "lowThresholds", "type": "[float]"}, + "high_thresholds": {"key": "highThresholds", "type": "[float]"}, } def __init__( @@ -910,68 +838,68 @@ def __init__( **kwargs ): """ - :keyword sensitivity: Required. the sensitivity of the baseline. Known values are: "Low", - "Medium", "High". + :keyword sensitivity: the sensitivity of the baseline. Required. Known values are: "Low", + "Medium", and "High". :paramtype sensitivity: str or ~$(python-base-namespace).v2019_03_01.models.BaselineSensitivity - :keyword low_thresholds: Required. The low thresholds of the baseline. + :keyword low_thresholds: The low thresholds of the baseline. Required. :paramtype low_thresholds: list[float] - :keyword high_thresholds: Required. The high thresholds of the baseline. + :keyword high_thresholds: The high thresholds of the baseline. Required. :paramtype high_thresholds: list[float] """ - super(SingleBaseline, self).__init__(**kwargs) + super().__init__(**kwargs) self.sensitivity = sensitivity self.low_thresholds = low_thresholds self.high_thresholds = high_thresholds -class SingleMetricBaseline(msrest.serialization.Model): +class SingleMetricBaseline(_serialization.Model): """The baseline results of a single metric. All required parameters must be populated in order to send to Azure. - :ivar id: Required. The metric baseline Id. + :ivar id: The metric baseline Id. Required. :vartype id: str - :ivar type: Required. The resource type of the metric baseline resource. + :ivar type: The resource type of the metric baseline resource. Required. :vartype type: str - :ivar name: Required. The name of the metric for which the baselines were retrieved. + :ivar name: The name of the metric for which the baselines were retrieved. Required. :vartype name: str - :ivar timespan: Required. The timespan for which the data was retrieved. Its value consists of - two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned - back from what was originally requested. + :ivar timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. Required. :vartype timespan: str - :ivar interval: Required. The interval (window size) for which the metric data was returned in. - This may be adjusted in the future and returned back from what was originally requested. This - is not present if a metadata request was made. + :ivar interval: The interval (window size) for which the metric data was returned in. This may + be adjusted in the future and returned back from what was originally requested. This is not + present if a metadata request was made. Required. :vartype interval: ~datetime.timedelta :ivar namespace: The namespace of the metrics been queried. :vartype namespace: str - :ivar baselines: Required. The baseline for each time series that was queried. + :ivar baselines: The baseline for each time series that was queried. Required. :vartype baselines: list[~$(python-base-namespace).v2019_03_01.models.TimeSeriesBaseline] """ _validation = { - 'id': {'required': True}, - 'type': {'required': True}, - 'name': {'required': True}, - 'timespan': {'required': True}, - 'interval': {'required': True}, - 'baselines': {'required': True}, + "id": {"required": True}, + "type": {"required": True}, + "name": {"required": True}, + "timespan": {"required": True}, + "interval": {"required": True}, + "baselines": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'timespan': {'key': 'properties.timespan', 'type': 'str'}, - 'interval': {'key': 'properties.interval', 'type': 'duration'}, - 'namespace': {'key': 'properties.namespace', 'type': 'str'}, - 'baselines': {'key': 'properties.baselines', 'type': '[TimeSeriesBaseline]'}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "timespan": {"key": "properties.timespan", "type": "str"}, + "interval": {"key": "properties.interval", "type": "duration"}, + "namespace": {"key": "properties.namespace", "type": "str"}, + "baselines": {"key": "properties.baselines", "type": "[TimeSeriesBaseline]"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin type: str, name: str, timespan: str, @@ -981,26 +909,26 @@ def __init__( **kwargs ): """ - :keyword id: Required. The metric baseline Id. + :keyword id: The metric baseline Id. Required. :paramtype id: str - :keyword type: Required. The resource type of the metric baseline resource. + :keyword type: The resource type of the metric baseline resource. Required. :paramtype type: str - :keyword name: Required. The name of the metric for which the baselines were retrieved. + :keyword name: The name of the metric for which the baselines were retrieved. Required. :paramtype name: str - :keyword timespan: Required. The timespan for which the data was retrieved. Its value consists - of two datetimes concatenated, separated by '/'. This may be adjusted in the future and - returned back from what was originally requested. + :keyword timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. Required. :paramtype timespan: str - :keyword interval: Required. The interval (window size) for which the metric data was returned - in. This may be adjusted in the future and returned back from what was originally requested. - This is not present if a metadata request was made. + :keyword interval: The interval (window size) for which the metric data was returned in. This + may be adjusted in the future and returned back from what was originally requested. This is + not present if a metadata request was made. Required. :paramtype interval: ~datetime.timedelta :keyword namespace: The namespace of the metrics been queried. :paramtype namespace: str - :keyword baselines: Required. The baseline for each time series that was queried. + :keyword baselines: The baseline for each time series that was queried. Required. :paramtype baselines: list[~$(python-base-namespace).v2019_03_01.models.TimeSeriesBaseline] """ - super(SingleMetricBaseline, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.type = type self.name = name @@ -1010,92 +938,85 @@ def __init__( self.baselines = baselines -class SmsReceiver(msrest.serialization.Model): +class SmsReceiver(_serialization.Model): """An SMS receiver. Variables are only 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 name: Required. The name of the SMS receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the SMS receiver. + :ivar country_code: The country code of the SMS receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the SMS receiver. + :ivar phone_number: The phone number of the SMS receiver. Required. :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_03_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the SMS receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the SMS receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the SMS receiver. + :keyword country_code: The country code of the SMS receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the SMS receiver. + :keyword phone_number: The phone number of the SMS receiver. Required. :paramtype phone_number: str """ - super(SmsReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number self.status = None -class TimeSeriesBaseline(msrest.serialization.Model): +class TimeSeriesBaseline(_serialization.Model): """The baseline values for a single time series. All required parameters must be populated in order to send to Azure. - :ivar aggregation: Required. The aggregation type of the metric. + :ivar aggregation: The aggregation type of the metric. Required. :vartype aggregation: str :ivar dimensions: The dimensions of this time series. :vartype dimensions: list[~$(python-base-namespace).v2019_03_01.models.MetricSingleDimension] - :ivar timestamps: Required. The list of timestamps of the baselines. + :ivar timestamps: The list of timestamps of the baselines. Required. :vartype timestamps: list[~datetime.datetime] - :ivar data: Required. The baseline values for each sensitivity. + :ivar data: The baseline values for each sensitivity. Required. :vartype data: list[~$(python-base-namespace).v2019_03_01.models.SingleBaseline] :ivar metadata_values: The baseline metadata values. :vartype metadata_values: list[~$(python-base-namespace).v2019_03_01.models.BaselineMetadata] """ _validation = { - 'aggregation': {'required': True}, - 'timestamps': {'required': True}, - 'data': {'required': True}, + "aggregation": {"required": True}, + "timestamps": {"required": True}, + "data": {"required": True}, } _attribute_map = { - 'aggregation': {'key': 'aggregation', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricSingleDimension]'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - 'data': {'key': 'data', 'type': '[SingleBaseline]'}, - 'metadata_values': {'key': 'metadataValues', 'type': '[BaselineMetadata]'}, + "aggregation": {"key": "aggregation", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricSingleDimension]"}, + "timestamps": {"key": "timestamps", "type": "[iso-8601]"}, + "data": {"key": "data", "type": "[SingleBaseline]"}, + "metadata_values": {"key": "metadataValues", "type": "[BaselineMetadata]"}, } def __init__( @@ -1109,18 +1030,18 @@ def __init__( **kwargs ): """ - :keyword aggregation: Required. The aggregation type of the metric. + :keyword aggregation: The aggregation type of the metric. Required. :paramtype aggregation: str :keyword dimensions: The dimensions of this time series. :paramtype dimensions: list[~$(python-base-namespace).v2019_03_01.models.MetricSingleDimension] - :keyword timestamps: Required. The list of timestamps of the baselines. + :keyword timestamps: The list of timestamps of the baselines. Required. :paramtype timestamps: list[~datetime.datetime] - :keyword data: Required. The baseline values for each sensitivity. + :keyword data: The baseline values for each sensitivity. Required. :paramtype data: list[~$(python-base-namespace).v2019_03_01.models.SingleBaseline] :keyword metadata_values: The baseline metadata values. :paramtype metadata_values: list[~$(python-base-namespace).v2019_03_01.models.BaselineMetadata] """ - super(TimeSeriesBaseline, self).__init__(**kwargs) + super().__init__(**kwargs) self.aggregation = aggregation self.dimensions = dimensions self.timestamps = timestamps @@ -1128,98 +1049,84 @@ def __init__( self.metadata_values = metadata_values -class VoiceReceiver(msrest.serialization.Model): +class VoiceReceiver(_serialization.Model): """A voice receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the voice receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the voice receiver. + :ivar country_code: The country code of the voice receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the voice receiver. + :ivar phone_number: The phone number of the voice receiver. Required. :vartype phone_number: str """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the voice receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the voice receiver. + :keyword country_code: The country code of the voice receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the voice receiver. + :keyword phone_number: The phone number of the voice receiver. Required. :paramtype phone_number: str """ - super(VoiceReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number -class WebhookReceiver(msrest.serialization.Model): +class WebhookReceiver(_serialization.Model): """A webhook receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the webhook receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar service_uri: Required. The URI where webhooks should be sent. + :ivar service_uri: The URI where webhooks should be sent. Required. :vartype service_uri: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, + "name": {"required": True}, + "service_uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } - def __init__( - self, - *, - name: str, - service_uri: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, service_uri: str, use_common_alert_schema: bool = False, **kwargs): """ - :keyword name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the webhook receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword service_uri: Required. The URI where webhooks should be sent. + :keyword service_uri: The URI where webhooks should be sent. Required. :paramtype service_uri: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(WebhookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.service_uri = service_uri self.use_common_alert_schema = use_common_alert_schema diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py index c68a974106d7..bf08d44864b2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py @@ -11,13 +11,13 @@ class BaselineSensitivity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the sensitivity of the baseline. - """ + """the sensitivity of the baseline.""" LOW = "Low" MEDIUM = "Medium" HIGH = "High" + class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. @@ -27,7 +27,9 @@ class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): ENABLED = "Enabled" DISABLED = "Disabled" + class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ResultType.""" DATA = "Data" METADATA = "Metadata" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/__init__.py index 62e8fdde212b..15bdf6da240f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', - 'BaselinesOperations', + "ActionGroupsOperations", + "BaselinesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py index 38736cc5f94f..f76fb0980cbb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,288 +25,243 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.ActionGroupResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - action_group_name: str, - *, - json: Optional[_models.ActionGroupPatchBody] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_id_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_enable_receiver_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.EnableRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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 ActionGroupsOperations: """ @@ -322,41 +282,105 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -365,7 +389,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -373,10 +398,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -385,55 +409,47 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -441,10 +457,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,52 +467,46 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -505,10 +514,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -519,52 +527,118 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2019_03_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2019_03_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -572,10 +646,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -583,46 +656,41 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -630,14 +698,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -653,10 +718,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -667,46 +730,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -714,15 +773,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -738,10 +793,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -752,47 +805,112 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore - @distributed_trace + @overload def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2019_03_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2019_03_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -801,7 +919,8 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -809,10 +928,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -823,5 +941,4 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py index c0a20ce41777..7762844d61f2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py @@ -8,10 +8,15 @@ # -------------------------------------------------------------------------- import datetime from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -21,13 +26,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( resource_uri: str, *, @@ -44,46 +52,41 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricBaselines") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters if metricnames is not None: - _params['metricnames'] = _SERIALIZER.query("metricnames", metricnames, 'str') + _params["metricnames"] = _SERIALIZER.query("metricnames", metricnames, "str") if metricnamespace is not None: - _params['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') + _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") if timespan is not None: - _params['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") if interval is not None: - _params['interval'] = _SERIALIZER.query("interval", interval, 'duration') + _params["interval"] = _SERIALIZER.query("interval", interval, "duration") if aggregation is not None: - _params['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") if sensitivities is not None: - _params['sensitivities'] = _SERIALIZER.query("sensitivities", sensitivities, 'str') + _params["sensitivities"] = _SERIALIZER.query("sensitivities", sensitivities, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if result_type is not None: - _params['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["resultType"] = _SERIALIZER.query("result_type", result_type, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BaselinesOperations: """ @@ -104,7 +107,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, @@ -118,10 +120,10 @@ def list( filter: Optional[str] = None, result_type: Optional[Union[str, "_models.ResultType"]] = None, **kwargs: Any - ) -> Iterable[_models.MetricBaselinesResponse]: + ) -> Iterable["_models.SingleMetricBaseline"]: """**Lists the metric baseline values for a resource**. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param metricnames: The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be @@ -155,31 +157,29 @@ def list( %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. Default value is None. :type filter: str :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. Default value is None. + information is retrieved. Known values are: "Data" and "Metadata". Default value is None. :type result_type: str or ~$(python-base-namespace).v2019_03_01.models.ResultType :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricBaselinesResponse or the result of + :return: An iterator like instance of either SingleMetricBaseline or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.MetricBaselinesResponse] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.SingleMetricBaseline] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricBaselinesResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricBaselinesResponse] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, - api_version=api_version, metricnames=metricnames, metricnamespace=metricnamespace, timespan=timespan, @@ -188,7 +188,8 @@ def prepare_request(next_link=None): sensitivities=sensitivities, filter=filter, result_type=result_type, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -196,22 +197,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - metricnames=metricnames, - metricnamespace=metricnamespace, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - filter=filter, - result_type=result_type, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -227,10 +217,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -241,8 +229,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py index a6860e42c01c..f2b5ee16ad38 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", "2019-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json index 775abfe44986..e7dc2ce80858 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py index 0abbc303fec8..166d1376bae4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -22,14 +21,15 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2019_06_01.operations.ActionGroupsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -45,23 +45,18 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -70,7 +65,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py index 10763f771226..93b0e6be8e61 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", "2019-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py index 20b4c2ce65c2..a6e3a27ecf96 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2019_06_01.aio.operations.ActionGroupsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -46,23 +46,18 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -71,7 +66,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/__init__.py index 60f9d62f0ead..0e396f5d7fb0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', + "ActionGroupsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py index ba945ecce720..17699d366adf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._action_groups_operations import build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_request -T = TypeVar('T') +from ...operations._action_groups_operations import ( + build_create_or_update_request, + build_delete_request, + build_enable_receiver_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ActionGroupsOperations: """ .. warning:: @@ -43,41 +60,105 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -86,7 +167,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -94,10 +176,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -106,55 +187,47 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -162,10 +235,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,52 +245,46 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -226,10 +292,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -240,52 +305,118 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2019_06_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2019_06_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -293,10 +424,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -304,46 +434,41 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -351,14 +476,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -374,10 +496,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -388,46 +508,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -435,15 +551,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -459,10 +571,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -473,47 +583,112 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore - @distributed_trace_async + @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2019_06_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2019_06_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -522,7 +697,8 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +706,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -544,5 +719,4 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py index cb5205fe1cc8..df5fd096a3c5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py @@ -23,31 +23,29 @@ from ._models_py3 import VoiceReceiver from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import ( - ReceiverStatus, -) +from ._monitor_management_client_enums import ReceiverStatus from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupList', - 'ActionGroupPatchBody', - 'ActionGroupResource', - 'ArmRoleReceiver', - 'AutomationRunbookReceiver', - 'AzureAppPushReceiver', - 'AzureFunctionReceiver', - 'AzureResource', - 'EmailReceiver', - 'EnableRequest', - 'ErrorResponse', - 'ItsmReceiver', - 'LogicAppReceiver', - 'SmsReceiver', - 'VoiceReceiver', - 'WebhookReceiver', - 'ReceiverStatus', + "ActionGroupList", + "ActionGroupPatchBody", + "ActionGroupResource", + "ArmRoleReceiver", + "AutomationRunbookReceiver", + "AzureAppPushReceiver", + "AzureFunctionReceiver", + "AzureResource", + "EmailReceiver", + "EnableRequest", + "ErrorResponse", + "ItsmReceiver", + "LogicAppReceiver", + "SmsReceiver", + "VoiceReceiver", + "WebhookReceiver", + "ReceiverStatus", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py index f76679d09e44..9324ebe7603d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_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. @@ -6,17 +7,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, TYPE_CHECKING +from typing import Dict, List, Optional -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models - -class ActionGroupList(msrest.serialization.Model): +class ActionGroupList(_serialization.Model): """A list of action groups. :ivar value: The list of action groups. @@ -26,16 +22,12 @@ class ActionGroupList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ActionGroupResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of action groups. @@ -43,15 +35,15 @@ def __init__( :keyword next_link: Provides the link to retrieve the next set of elements. :paramtype next_link: str """ - super(ActionGroupList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ActionGroupPatchBody(msrest.serialization.Model): +class ActionGroupPatchBody(_serialization.Model): """An action group object for the body of patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. @@ -59,30 +51,24 @@ class ActionGroupPatchBody(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - enabled: Optional[bool] = True, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. :paramtype enabled: bool """ - super(ActionGroupPatchBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.enabled = enabled -class AzureResource(msrest.serialization.Model): +class AzureResource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -95,41 +81,35 @@ class AzureResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(AzureResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -137,7 +117,7 @@ def __init__( self.tags = tags -class ActionGroupResource(AzureResource): +class ActionGroupResource(AzureResource): # pylint: disable=too-many-instance-attributes """An action group resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -150,9 +130,9 @@ class ActionGroupResource(AzureResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar group_short_name: The short name of the action group. This will be used in SMS messages. :vartype group_short_name: str @@ -190,31 +170,34 @@ class ActionGroupResource(AzureResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "group_short_name": {"max_length": 12}, } _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}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'properties.armRoleReceivers', 'type': '[ArmRoleReceiver]'}, + "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}"}, + "group_short_name": {"key": "properties.groupShortName", "type": "str"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, + "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, + "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, + "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, + "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, + "automation_runbook_receivers": { + "key": "properties.automationRunbookReceivers", + "type": "[AutomationRunbookReceiver]", + }, + "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, + "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, + "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, + "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, } def __init__( @@ -223,7 +206,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, - enabled: Optional[bool] = True, + enabled: bool = True, email_receivers: Optional[List["_models.EmailReceiver"]] = None, sms_receivers: Optional[List["_models.SmsReceiver"]] = None, webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, @@ -237,9 +220,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword group_short_name: The short name of the action group. This will be used in SMS messages. @@ -279,7 +262,7 @@ def __init__( :paramtype arm_role_receivers: list[~$(python-base-namespace).v2019_06_01.models.ArmRoleReceiver] """ - super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled self.email_receivers = email_receivers @@ -294,67 +277,60 @@ def __init__( self.arm_role_receivers = arm_role_receivers -class ArmRoleReceiver(msrest.serialization.Model): +class ArmRoleReceiver(_serialization.Model): """An arm role receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the arm role receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the arm role receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar role_id: Required. The arm role id. + :ivar role_id: The arm role id. Required. :vartype role_id: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'role_id': {'required': True}, + "name": {"required": True}, + "role_id": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } - def __init__( - self, - *, - name: str, - role_id: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs): """ - :keyword name: Required. The name of the arm role receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the arm role receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword role_id: Required. The arm role id. + :keyword role_id: The arm role id. Required. :paramtype role_id: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(ArmRoleReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.role_id = role_id self.use_common_alert_schema = use_common_alert_schema -class AutomationRunbookReceiver(msrest.serialization.Model): +class AutomationRunbookReceiver(_serialization.Model): """The Azure Automation Runbook notification receiver. All required parameters must be populated in order to send to Azure. - :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook - and authenticate to Azure resource. + :ivar automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :vartype automation_account_id: str - :ivar runbook_name: Required. The name for this runbook. + :ivar runbook_name: The name for this runbook. Required. :vartype runbook_name: str - :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. :vartype webhook_resource_id: str - :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. :vartype is_global_runbook: bool :ivar name: Indicates name of the webhook. :vartype name: str @@ -365,20 +341,20 @@ class AutomationRunbookReceiver(msrest.serialization.Model): """ _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, + "automation_account_id": {"required": True}, + "runbook_name": {"required": True}, + "webhook_resource_id": {"required": True}, + "is_global_runbook": {"required": True}, } _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "automation_account_id": {"key": "automationAccountId", "type": "str"}, + "runbook_name": {"key": "runbookName", "type": "str"}, + "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, + "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( @@ -390,18 +366,18 @@ def __init__( is_global_runbook: bool, name: Optional[str] = None, service_uri: Optional[str] = None, - use_common_alert_schema: Optional[bool] = False, + use_common_alert_schema: bool = False, **kwargs ): """ - :keyword automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. + :keyword automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :paramtype automation_account_id: str - :keyword runbook_name: Required. The name for this runbook. + :keyword runbook_name: The name for this runbook. Required. :paramtype runbook_name: str - :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. :paramtype webhook_resource_id: str - :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. :paramtype is_global_runbook: bool :keyword name: Indicates name of the webhook. :paramtype name: str @@ -410,7 +386,7 @@ def __init__( :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(AutomationRunbookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name self.webhook_resource_id = webhook_resource_id @@ -420,78 +396,72 @@ def __init__( self.use_common_alert_schema = use_common_alert_schema -class AzureAppPushReceiver(msrest.serialization.Model): +class AzureAppPushReceiver(_serialization.Model): """The Azure mobile App push notification receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :vartype name: str - :ivar email_address: Required. The email address registered for the Azure mobile app. + :ivar email_address: The email address registered for the Azure mobile app. Required. :vartype email_address: str """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, + "name": {"required": True}, + "email_address": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, **kwargs): """ - :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address registered for the Azure mobile app. + :keyword email_address: The email address registered for the Azure mobile app. Required. :paramtype email_address: str """ - super(AzureAppPushReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address -class AzureFunctionReceiver(msrest.serialization.Model): +class AzureFunctionReceiver(_serialization.Model): """An azure function receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the azure function receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the azure function receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar function_app_resource_id: Required. The azure resource id of the function app. + :ivar function_app_resource_id: The azure resource id of the function app. Required. :vartype function_app_resource_id: str - :ivar function_name: Required. The function name in the function app. + :ivar function_name: The function name in the function app. Required. :vartype function_name: str - :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :ivar http_trigger_url: The http trigger url where http request sent to. Required. :vartype http_trigger_url: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'function_app_resource_id': {'required': True}, - 'function_name': {'required': True}, - 'http_trigger_url': {'required': True}, + "name": {"required": True}, + "function_app_resource_id": {"required": True}, + "function_name": {"required": True}, + "http_trigger_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, - 'function_name': {'key': 'functionName', 'type': 'str'}, - 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, + "function_name": {"key": "functionName", "type": "str"}, + "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( @@ -501,23 +471,23 @@ def __init__( function_app_resource_id: str, function_name: str, http_trigger_url: str, - use_common_alert_schema: Optional[bool] = False, + use_common_alert_schema: bool = False, **kwargs ): """ - :keyword name: Required. The name of the azure function receiver. Names must be unique across - all receivers within an action group. + :keyword name: The name of the azure function receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword function_app_resource_id: Required. The azure resource id of the function app. + :keyword function_app_resource_id: The azure resource id of the function app. Required. :paramtype function_app_resource_id: str - :keyword function_name: Required. The function name in the function app. + :keyword function_name: The function name in the function app. Required. :paramtype function_name: str - :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :keyword http_trigger_url: The http trigger url where http request sent to. Required. :paramtype http_trigger_url: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(AzureFunctionReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.function_app_resource_id = function_app_resource_id self.function_name = function_name @@ -525,94 +495,82 @@ def __init__( self.use_common_alert_schema = use_common_alert_schema -class EmailReceiver(msrest.serialization.Model): +class EmailReceiver(_serialization.Model): """An email receiver. Variables are only 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 name: Required. The name of the email receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the email receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar email_address: Required. The email address of this receiver. + :ivar email_address: The email address of this receiver. Required. :vartype email_address: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - "Disabled". + and "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_06_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "email_address": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs): """ - :keyword name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the email receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address of this receiver. + :keyword email_address: The email address of this receiver. Required. :paramtype email_address: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(EmailReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address self.use_common_alert_schema = use_common_alert_schema self.status = None -class EnableRequest(msrest.serialization.Model): +class EnableRequest(_serialization.Model): """Describes a receiver that should be resubscribed. All required parameters must be populated in order to send to Azure. - :ivar receiver_name: Required. The name of the receiver to resubscribe. + :ivar receiver_name: The name of the receiver to resubscribe. Required. :vartype receiver_name: str """ _validation = { - 'receiver_name': {'required': True}, + "receiver_name": {"required": True}, } _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, + "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__( - self, - *, - receiver_name: str, - **kwargs - ): + def __init__(self, *, receiver_name: str, **kwargs): """ - :keyword receiver_name: Required. The name of the receiver to resubscribe. + :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str """ - super(EnableRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.receiver_name = receiver_name -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -622,92 +580,81 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ItsmReceiver(msrest.serialization.Model): +class ItsmReceiver(_serialization.Model): """An Itsm receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar workspace_id: Required. OMS LA instance identifier. + :ivar workspace_id: OMS LA instance identifier. Required. :vartype workspace_id: str - :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined - in above workspace. + :ivar connection_id: Unique identification of ITSM connection among multiple defined in above + workspace. Required. :vartype connection_id: str - :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :vartype ticket_configuration: str - :ivar region: Required. Region in which workspace resides. Supported + :ivar region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :vartype region: str """ _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, + "name": {"required": True}, + "workspace_id": {"required": True}, + "connection_id": {"required": True}, + "ticket_configuration": {"required": True}, + "region": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "connection_id": {"key": "connectionId", "type": "str"}, + "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, + "region": {"key": "region", "type": "str"}, } def __init__( - self, - *, - name: str, - workspace_id: str, - connection_id: str, - ticket_configuration: str, - region: str, - **kwargs + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs ): """ - :keyword name: Required. The name of the Itsm receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword workspace_id: Required. OMS LA instance identifier. + :keyword workspace_id: OMS LA instance identifier. Required. :paramtype workspace_id: str - :keyword connection_id: Required. Unique identification of ITSM connection among multiple - defined in above workspace. + :keyword connection_id: Unique identification of ITSM connection among multiple defined in + above workspace. Required. :paramtype connection_id: str - :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :paramtype ticket_configuration: str - :keyword region: Required. Region in which workspace resides. Supported + :keyword region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :paramtype region: str """ - super(ItsmReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.workspace_id = workspace_id self.connection_id = connection_id @@ -715,177 +662,157 @@ def __init__( self.region = region -class LogicAppReceiver(msrest.serialization.Model): +class LogicAppReceiver(_serialization.Model): """A logic app receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar resource_id: Required. The azure resource id of the logic app receiver. + :ivar resource_id: The azure resource id of the logic app receiver. Required. :vartype resource_id: str - :ivar callback_url: Required. The callback url where http request sent to. + :ivar callback_url: The callback url where http request sent to. Required. :vartype callback_url: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'resource_id': {'required': True}, - 'callback_url': {'required': True}, + "name": {"required": True}, + "resource_id": {"required": True}, + "callback_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "callback_url": {"key": "callbackUrl", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( - self, - *, - name: str, - resource_id: str, - callback_url: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs + self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs ): """ - :keyword name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword resource_id: Required. The azure resource id of the logic app receiver. + :keyword resource_id: The azure resource id of the logic app receiver. Required. :paramtype resource_id: str - :keyword callback_url: Required. The callback url where http request sent to. + :keyword callback_url: The callback url where http request sent to. Required. :paramtype callback_url: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(LogicAppReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.resource_id = resource_id self.callback_url = callback_url self.use_common_alert_schema = use_common_alert_schema -class SmsReceiver(msrest.serialization.Model): +class SmsReceiver(_serialization.Model): """An SMS receiver. Variables are only 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 name: Required. The name of the SMS receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the SMS receiver. + :ivar country_code: The country code of the SMS receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the SMS receiver. + :ivar phone_number: The phone number of the SMS receiver. Required. :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_06_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the SMS receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the SMS receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the SMS receiver. + :keyword country_code: The country code of the SMS receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the SMS receiver. + :keyword phone_number: The phone number of the SMS receiver. Required. :paramtype phone_number: str """ - super(SmsReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number self.status = None -class VoiceReceiver(msrest.serialization.Model): +class VoiceReceiver(_serialization.Model): """A voice receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the voice receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the voice receiver. + :ivar country_code: The country code of the voice receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the voice receiver. + :ivar phone_number: The phone number of the voice receiver. Required. :vartype phone_number: str """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the voice receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the voice receiver. + :keyword country_code: The country code of the voice receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the voice receiver. + :keyword phone_number: The phone number of the voice receiver. Required. :paramtype phone_number: str """ - super(VoiceReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number -class WebhookReceiver(msrest.serialization.Model): +class WebhookReceiver(_serialization.Model): """A webhook receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the webhook receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar service_uri: Required. The URI where webhooks should be sent. + :ivar service_uri: The URI where webhooks should be sent. Required. :vartype service_uri: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool @@ -900,18 +827,18 @@ class WebhookReceiver(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, + "name": {"required": True}, + "service_uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'use_aad_auth': {'key': 'useAadAuth', 'type': 'bool'}, - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'identifier_uri': {'key': 'identifierUri', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "use_aad_auth": {"key": "useAadAuth", "type": "bool"}, + "object_id": {"key": "objectId", "type": "str"}, + "identifier_uri": {"key": "identifierUri", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } def __init__( @@ -919,18 +846,18 @@ def __init__( *, name: str, service_uri: str, - use_common_alert_schema: Optional[bool] = False, - use_aad_auth: Optional[bool] = False, + use_common_alert_schema: bool = False, + use_aad_auth: bool = False, object_id: Optional[str] = None, identifier_uri: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the webhook receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword service_uri: Required. The URI where webhooks should be sent. + :keyword service_uri: The URI where webhooks should be sent. Required. :paramtype service_uri: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool @@ -943,7 +870,7 @@ def __init__( :keyword tenant_id: Indicates the tenant id for aad auth. :paramtype tenant_id: str """ - super(WebhookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.service_uri = service_uri self.use_common_alert_schema = use_common_alert_schema diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/__init__.py index 60f9d62f0ead..0e396f5d7fb0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', + "ActionGroupsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py index dfe57fbbf0e3..d61f7d5322e7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,288 +25,243 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.ActionGroupResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - action_group_name: str, - *, - json: Optional[_models.ActionGroupPatchBody] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_id_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_enable_receiver_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.EnableRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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 ActionGroupsOperations: """ @@ -322,41 +282,105 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -365,7 +389,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -373,10 +398,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -385,55 +409,47 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -441,10 +457,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,52 +467,46 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -505,10 +514,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -519,52 +527,118 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2019_06_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2019_06_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -572,10 +646,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -583,46 +656,41 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -630,14 +698,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -653,10 +718,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -667,46 +730,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -714,15 +773,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -738,10 +793,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -752,47 +805,112 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore - @distributed_trace + @overload def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2019_06_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2019_06_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -801,7 +919,8 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -809,10 +928,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -823,5 +941,4 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py index 2df221ca96ff..1b892f93ef1e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-10-17-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-10-17-preview") # type: str + api_version = kwargs.pop("api_version", "2019-10-17-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json index a393daf1dc40..77cfc19d416c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py index 1246473842cd..efb720dba23a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py @@ -9,20 +9,26 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, PrivateLinkScopeOperationStatusOperations, PrivateLinkScopedResourcesOperations, PrivateLinkScopesOperations +from .operations import ( + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + PrivateLinkScopeOperationStatusOperations, + PrivateLinkScopedResourcesOperations, + PrivateLinkScopesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar private_link_scopes: PrivateLinkScopesOperations operations @@ -40,9 +46,9 @@ class MonitorManagementClient: :ivar private_link_scoped_resources: PrivateLinkScopedResourcesOperations operations :vartype private_link_scoped_resources: $(python-base-namespace).v2019_10_17.operations.PrivateLinkScopedResourcesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,7 +66,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -83,12 +91,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -97,7 +100,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py index c41ed063f867..8c24d0c65cac 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-10-17-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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-10-17-preview") # type: str + api_version = kwargs.pop("api_version", "2019-10-17-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py index 860be3f92221..b1b03a095e9e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py @@ -9,20 +9,26 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, PrivateLinkScopeOperationStatusOperations, PrivateLinkScopedResourcesOperations, PrivateLinkScopesOperations +from .operations import ( + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + PrivateLinkScopeOperationStatusOperations, + PrivateLinkScopedResourcesOperations, + PrivateLinkScopesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar private_link_scopes: PrivateLinkScopesOperations operations @@ -40,9 +46,9 @@ class MonitorManagementClient: :ivar private_link_scoped_resources: PrivateLinkScopedResourcesOperations operations :vartype private_link_scoped_resources: $(python-base-namespace).v2019_10_17.aio.operations.PrivateLinkScopedResourcesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,7 +66,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -83,12 +91,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -97,7 +100,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/__init__.py index 0a36c7d8c015..6737f122eff7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/__init__.py @@ -15,12 +15,13 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PrivateLinkScopesOperations', - 'PrivateLinkScopeOperationStatusOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkScopedResourcesOperations', + "PrivateLinkScopesOperations", + "PrivateLinkScopeOperationStatusOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkScopedResourcesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py index 17aac92d991d..598891676454 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,17 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_private_link_scope_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_private_link_scope_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -45,47 +59,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets a private endpoint connection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -93,57 +100,60 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, + parameters: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -151,10 +161,9 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -163,35 +172,80 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param parameters: + :param parameters: Required. :type parameters: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param 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 :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -204,20 +258,55 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -226,66 +315,55 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -293,10 +371,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -306,24 +383,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -335,96 +408,86 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def list_by_private_link_scope( - self, - resource_group_name: str, - scope_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Gets all private endpoint connections on a private link scope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_private_link_scope_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_private_link_scope.metadata['url'], + template_url=self.list_by_private_link_scope.metadata["url"], headers=_headers, params=_params, ) @@ -432,16 +495,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_private_link_scope_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - scope_name=scope_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -457,10 +515,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -470,8 +526,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_private_link_scope.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections"} # type: ignore + list_by_private_link_scope.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py index b97aa058300e..eab00cda70b5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +28,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_by_private_link_scope_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -43,46 +52,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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_private_link_scope( - self, - resource_group_name: str, - scope_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateLinkResourceListResult]: + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_private_link_scope_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_private_link_scope.metadata['url'], + template_url=self.list_by_private_link_scope.metadata["url"], headers=_headers, params=_params, ) @@ -90,16 +94,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_private_link_scope_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - scope_name=scope_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -115,10 +114,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -128,52 +125,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_private_link_scope.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources"} # type: ignore + list_by_private_link_scope.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - scope_name: str, - group_name: str, - **kwargs: Any + self, resource_group_name: str, scope_name: str, group_name: str, **kwargs: Any ) -> _models.PrivateLinkResource: """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param group_name: The name of the private link resource. + :param group_name: The name of the private link resource. Required. :type group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, group_name=group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -181,22 +170,20 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py index 3fb9a2df6a9c..451ba9f201b6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_scope_operation_status_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkScopeOperationStatusOperations: """ .. warning:: @@ -41,44 +49,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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, - async_operation_id: str, - resource_group_name: str, - **kwargs: Any - ) -> _models.OperationStatus: + async def get(self, async_operation_id: str, resource_group_name: str, **kwargs: Any) -> _models.OperationStatus: """Get the status of an azure asynchronous operation associated with a private link scope operation. - :param async_operation_id: The operation Id. + :param async_operation_id: The operation Id. Required. :type async_operation_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus, or the result of cls(response) + :return: OperationStatus or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.OperationStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatus] - request = build_get_request( async_operation_id=async_operation_id, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -86,22 +86,20 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatus', pipeline_response) + deserialized = self._deserialize("OperationStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py index f221cf86894c..7fb7ff99e6e7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,17 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_link_scoped_resources_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_private_link_scope_request -T = TypeVar('T') +from ...operations._private_link_scoped_resources_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_private_link_scope_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkScopedResourcesOperations: """ .. warning:: @@ -45,47 +59,38 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get( - self, - resource_group_name: str, - scope_name: str, - name: str, - **kwargs: Any - ) -> _models.ScopedResource: + async def get(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> _models.ScopedResource: """Gets a scoped resource in a private link scope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param name: The name of the scoped resource object. + :param name: The name of the scoped resource object. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopedResource, or the result of cls(response) + :return: ScopedResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.ScopedResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScopedResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScopedResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -93,57 +98,60 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopedResource', pipeline_response) + deserialized = self._deserialize("ScopedResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, scope_name: str, name: str, - parameters: _models.ScopedResource, + parameters: Union[_models.ScopedResource, IO], **kwargs: Any ) -> Optional[_models.ScopedResource]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ScopedResource]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ScopedResource]] - _json = self._serialize.body(parameters, 'ScopedResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedResource") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, scope_name=scope_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -151,10 +159,9 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -163,38 +170,121 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ScopedResource', pipeline_response) + deserialized = self._deserialize("ScopedResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopedResource', pipeline_response) + deserialized = self._deserialize("ScopedResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, scope_name: str, name: str, parameters: _models.ScopedResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ScopedResource]: """Approve or reject a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param name: The name of the scoped resource object. + :param name: The name of the scoped resource object. Required. :type name: str - :param parameters: + :param parameters: Required. :type parameters: ~$(python-base-namespace).v2019_10_17.models.ScopedResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ScopedResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2019_10_17.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopedResource]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :param 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ScopedResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2019_10_17.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + name: str, + parameters: Union[_models.ScopedResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopedResource]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~$(python-base-namespace).v2019_10_17.models.ScopedResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 @@ -207,20 +297,17 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2019_10_17.models.ScopedResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScopedResource] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScopedResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -229,66 +316,55 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ScopedResource', pipeline_response) + deserialized = self._deserialize("ScopedResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - scope_name: str, - name: str, - **kwargs: Any + self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, scope_name=scope_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -296,10 +372,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -309,24 +384,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - scope_name: str, - name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param name: The name of the scoped resource object. + :param name: The name of the scoped resource object. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -338,96 +409,85 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, name=name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore @distributed_trace def list_by_private_link_scope( - self, - resource_group_name: str, - scope_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ScopedResourceListResult]: + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ScopedResource"]: """Gets all private endpoint connections on a private link scope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopedResourceListResult or the result of - cls(response) + :return: An iterator like instance of either ScopedResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.ScopedResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScopedResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScopedResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_private_link_scope_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_private_link_scope.metadata['url'], + template_url=self.list_by_private_link_scope.metadata["url"], headers=_headers, params=_params, ) @@ -435,16 +495,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_private_link_scope_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - scope_name=scope_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -460,10 +515,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -473,8 +526,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_private_link_scope.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources"} # type: ignore + list_by_private_link_scope.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py index 81cbd406ca19..5b852898069f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_link_scopes_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_tags_request -T = TypeVar('T') +from ...operations._private_link_scopes_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_tags_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkScopesOperations: """ .. warning:: @@ -45,38 +61,33 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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.AzureMonitorPrivateLinkScopeListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.AzureMonitorPrivateLinkScope"]: """Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorPrivateLinkScopeListResult or the - result of cls(response) + :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -84,14 +95,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -107,10 +115,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -120,47 +126,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.AzureMonitorPrivateLinkScopeListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AzureMonitorPrivateLinkScope"]: """Gets a list of Azure Monitor PrivateLinkScopes within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 AzureMonitorPrivateLinkScopeListResult or the - result of cls(response) + :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -168,15 +170,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -192,10 +190,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -205,36 +201,28 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - scope_name: str, - **kwargs: Any + self, resource_group_name: str, scope_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -242,10 +230,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -255,21 +242,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - scope_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -281,92 +263,80 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - scope_name: str, - **kwargs: Any + self, resource_group_name: str, scope_name: str, **kwargs: Any ) -> _models.AzureMonitorPrivateLinkScope: """Returns a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope, or the result of cls(response) + :return: AzureMonitorPrivateLinkScope or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] - request = build_get_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -374,72 +344,140 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AzureMonitorPrivateLinkScope', pipeline_response) + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, scope_name: str, azure_monitor_private_link_scope_payload: _models.AzureMonitorPrivateLinkScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AzureMonitorPrivateLinkScope: """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different value for InstrumentationKey nor AppId in the Put operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. + or update a Azure Monitor PrivateLinkScope. Required. :type azure_monitor_private_link_scope_payload: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + scope_name: str, + azure_monitor_private_link_scope_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different + value for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create + or update a Azure Monitor PrivateLinkScope. Required. + :type azure_monitor_private_link_scope_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AzureMonitorPrivateLinkScope, or the result of cls(response) + :return: AzureMonitorPrivateLinkScope or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + scope_name: str, + azure_monitor_private_link_scope_payload: Union[_models.AzureMonitorPrivateLinkScope, IO], + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different + value for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create + or update a Azure Monitor PrivateLinkScope. Is either a model type or a IO type. Required. + :type azure_monitor_private_link_scope_payload: + ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] - _json = self._serialize.body(azure_monitor_private_link_scope_payload, 'AzureMonitorPrivateLinkScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_monitor_private_link_scope_payload, (IO, bytes)): + _content = azure_monitor_private_link_scope_payload + else: + _json = self._serialize.body(azure_monitor_private_link_scope_payload, "AzureMonitorPrivateLinkScope") request = build_create_or_update_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -447,10 +485,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -458,64 +495,132 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AzureMonitorPrivateLinkScope', pipeline_response) + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AzureMonitorPrivateLinkScope', pipeline_response) + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore - - @distributed_trace_async + @overload async def update_tags( self, resource_group_name: str, scope_name: str, private_link_scope_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AzureMonitorPrivateLinkScope: """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. + instance. Required. :type private_link_scope_tags: ~$(python-base-namespace).v2019_10_17.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Required. + :type private_link_scope_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AzureMonitorPrivateLinkScope, or the result of cls(response) + :return: AzureMonitorPrivateLinkScope or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: Union[_models.TagsResource, IO], + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Is either a model type or a IO type. Required. + :type private_link_scope_tags: ~$(python-base-namespace).v2019_10_17.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] - _json = self._serialize.body(private_link_scope_tags, 'TagsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link_scope_tags, (IO, bytes)): + _content = private_link_scope_tags + else: + _json = self._serialize.body(private_link_scope_tags, "TagsResource") request = build_update_tags_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) @@ -523,22 +628,20 @@ async def update_tags( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AzureMonitorPrivateLinkScope', pipeline_response) + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore - + update_tags.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py index dfe6a71d3fa4..53f978c6d85f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py @@ -23,28 +23,28 @@ from ._models_py3 import ScopedResource from ._models_py3 import ScopedResourceListResult from ._models_py3 import TagsResource - from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AzureMonitorPrivateLinkScope', - 'AzureMonitorPrivateLinkScopeListResult', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ErrorResponseCommon', - 'OperationStatus', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateEndpointProperty', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkScopesResource', - 'PrivateLinkServiceConnectionStateProperty', - 'ProxyResource', - 'ScopedResource', - 'ScopedResourceListResult', - 'TagsResource', + "AzureMonitorPrivateLinkScope", + "AzureMonitorPrivateLinkScopeListResult", + "ErrorAdditionalInfo", + "ErrorResponse", + "ErrorResponseCommon", + "OperationStatus", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateEndpointProperty", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkScopesResource", + "PrivateLinkServiceConnectionStateProperty", + "ProxyResource", + "ScopedResource", + "ScopedResourceListResult", + "TagsResource", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py index bb315d2873d0..991e73282eb6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/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. @@ -9,14 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class PrivateLinkScopesResource(msrest.serialization.Model): +class PrivateLinkScopesResource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -29,41 +30,35 @@ class PrivateLinkScopesResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(PrivateLinkScopesResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -84,9 +79,9 @@ class AzureMonitorPrivateLinkScope(PrivateLinkScopesResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar provisioning_state: Current state of this PrivateLinkScope: whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are @@ -98,48 +93,45 @@ class AzureMonitorPrivateLinkScope(PrivateLinkScopesResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "private_endpoint_connections": {"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}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, + "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}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(AzureMonitorPrivateLinkScope, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.private_endpoint_connections = None -class AzureMonitorPrivateLinkScopeListResult(msrest.serialization.Model): +class AzureMonitorPrivateLinkScopeListResult(_serialization.Model): """Describes the list of Azure Monitor PrivateLinkScope resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. List of Azure Monitor PrivateLinkScope definitions. + :ivar value: List of Azure Monitor PrivateLinkScope definitions. Required. :vartype value: list[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope] :ivar next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions if too many PrivateLinkScopes where returned in the result set. @@ -147,35 +139,31 @@ class AzureMonitorPrivateLinkScopeListResult(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[AzureMonitorPrivateLinkScope]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AzureMonitorPrivateLinkScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: List["_models.AzureMonitorPrivateLinkScope"], - next_link: Optional[str] = None, - **kwargs + self, *, value: List["_models.AzureMonitorPrivateLinkScope"], next_link: Optional[str] = None, **kwargs ): """ - :keyword value: Required. List of Azure Monitor PrivateLinkScope definitions. + :keyword value: List of Azure Monitor PrivateLinkScope definitions. Required. :paramtype value: list[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope] :keyword next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions if too many PrivateLinkScopes where returned in the result set. :paramtype next_link: str """ - super(AzureMonitorPrivateLinkScopeListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -183,31 +171,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -217,24 +201,18 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message @@ -256,36 +234,30 @@ class ErrorResponseCommon(ErrorResponse): """ _validation = { - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponseCommon]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponseCommon]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponseCommon, self).__init__(code=code, message=message, **kwargs) + super().__init__(code=code, message=message, **kwargs) self.details = None self.additional_info = None -class OperationStatus(msrest.serialization.Model): +class OperationStatus(_serialization.Model): """The status of operation. :ivar id: The operation Id. @@ -303,18 +275,18 @@ class OperationStatus(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponseCommon'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponseCommon"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, @@ -336,7 +308,7 @@ def __init__( :keyword error: The error detail of the operation if any. :paramtype error: ~$(python-base-namespace).v2019_10_17.models.ErrorResponseCommon """ - super(OperationStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.start_time = start_time @@ -345,7 +317,7 @@ def __init__( self.error = error -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -359,24 +331,20 @@ class ProxyResource(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(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -404,19 +372,22 @@ class PrivateEndpointConnection(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpointProperty'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionStateProperty'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpointProperty"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionStateProperty", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -435,13 +406,13 @@ def __init__( :paramtype private_link_service_connection_state: ~$(python-base-namespace).v2019_10_17.models.PrivateLinkServiceConnectionStateProperty """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """A list of private endpoint connections. Variables are only populated by the server, and will be ignored when sending a request. @@ -453,27 +424,23 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateEndpointProperty(msrest.serialization.Model): +class PrivateEndpointProperty(_serialization.Model): """Private endpoint which the connection belongs to. :ivar id: Resource id of the private endpoint. @@ -481,20 +448,15 @@ class PrivateEndpointProperty(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource id of the private endpoint. :paramtype id: str """ - super(PrivateEndpointProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -516,33 +478,29 @@ class PrivateLinkResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateLinkResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.group_id = None self.required_members = None -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -554,67 +512,57 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateLinkServiceConnectionStateProperty(msrest.serialization.Model): +class PrivateLinkServiceConnectionStateProperty(_serialization.Model): """State of the private endpoint connection. Variables are only 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: Required. The private link service connection status. + :ivar status: The private link service connection status. Required. :vartype status: str - :ivar description: Required. The private link service connection description. + :ivar description: The private link service connection description. Required. :vartype description: str :ivar actions_required: The actions required for private link service connection. :vartype actions_required: str """ _validation = { - 'status': {'required': True}, - 'description': {'required': True}, - 'actions_required': {'readonly': True}, + "status": {"required": True}, + "description": {"required": True}, + "actions_required": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } - def __init__( - self, - *, - status: str, - description: str, - **kwargs - ): + def __init__(self, *, status: str, description: str, **kwargs): """ - :keyword status: Required. The private link service connection status. + :keyword status: The private link service connection status. Required. :paramtype status: str - :keyword description: Required. The private link service connection description. + :keyword description: The private link service connection description. Required. :paramtype description: str """ - super(PrivateLinkServiceConnectionStateProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = None @@ -638,36 +586,31 @@ class ScopedResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'linked_resource_id': {'key': 'properties.linkedResourceId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "linked_resource_id": {"key": "properties.linkedResourceId", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } - def __init__( - self, - *, - linked_resource_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, linked_resource_id: Optional[str] = None, **kwargs): """ :keyword linked_resource_id: The resource id of the scoped Azure monitor resource. :paramtype linked_resource_id: str """ - super(ScopedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.linked_resource_id = linked_resource_id self.provisioning_state = None -class ScopedResourceListResult(msrest.serialization.Model): +class ScopedResourceListResult(_serialization.Model): """A list of scoped resources in a private link scope. Variables are only populated by the server, and will be ignored when sending a request. @@ -679,46 +622,37 @@ class ScopedResourceListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ScopedResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ScopedResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ScopedResourceListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on a PrivateLinkScope instance. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :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 - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/__init__.py index 0a36c7d8c015..6737f122eff7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/__init__.py @@ -15,12 +15,13 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'PrivateLinkScopesOperations', - 'PrivateLinkScopeOperationStatusOperations', - 'PrivateLinkResourcesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkScopedResourcesOperations', + "PrivateLinkScopesOperations", + "PrivateLinkScopeOperationStatusOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkScopedResourcesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py index 812ba1173e5f..5e673474778c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,166 +27,165 @@ 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 -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_by_private_link_scope_request( - subscription_id: str, - resource_group_name: str, - scope_name: str, - **kwargs: Any + resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -202,47 +206,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets a private endpoint connection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -250,57 +247,60 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, + parameters: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -308,10 +308,9 @@ def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -320,35 +319,118 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param parameters: + :param parameters: Required. :type parameters: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 @@ -361,20 +443,17 @@ def begin_create_or_update( of cls(response) :rtype: ~azure.core.polling.LROPoller[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -383,66 +462,55 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -450,10 +518,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -463,24 +530,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -492,96 +555,86 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def list_by_private_link_scope( - self, - resource_group_name: str, - scope_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """Gets all private endpoint connections on a private link scope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_private_link_scope_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_private_link_scope.metadata['url'], + template_url=self.list_by_private_link_scope.metadata["url"], headers=_headers, params=_params, ) @@ -589,16 +642,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_private_link_scope_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - scope_name=scope_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -614,10 +662,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -627,8 +673,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_private_link_scope.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections"} # type: ignore + list_by_private_link_scope.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py index 70ad22a21db2..e4a2712e5b58 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,87 +25,82 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_private_link_scope_request( - subscription_id: str, - resource_group_name: str, - scope_name: str, - **kwargs: Any + resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - scope_name: str, - group_name: str, - **kwargs: Any + resource_group_name: str, scope_name: str, group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), - "groupName": _SERIALIZER.url("group_name", group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "groupName": _SERIALIZER.url("group_name", group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -121,46 +121,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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_private_link_scope( - self, - resource_group_name: str, - scope_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateLinkResourceListResult]: + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_private_link_scope_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_private_link_scope.metadata['url'], + template_url=self.list_by_private_link_scope.metadata["url"], headers=_headers, params=_params, ) @@ -168,16 +163,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_private_link_scope_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - scope_name=scope_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -193,10 +183,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -206,52 +194,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_private_link_scope.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources"} # type: ignore + list_by_private_link_scope.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - scope_name: str, - group_name: str, - **kwargs: Any + self, resource_group_name: str, scope_name: str, group_name: str, **kwargs: Any ) -> _models.PrivateLinkResource: """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param group_name: The name of the private link resource. + :param group_name: The name of the private link resource. Required. :type group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, group_name=group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -259,22 +239,20 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py index b9fbfa8996eb..da12c96bbe27 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +23,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - async_operation_id: str, - resource_group_name: str, - subscription_id: str, - **kwargs: Any + async_operation_id: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "asyncOperationId": _SERIALIZER.url("async_operation_id", async_operation_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "asyncOperationId": _SERIALIZER.url("async_operation_id", async_operation_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkScopeOperationStatusOperations: """ @@ -81,44 +85,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - async_operation_id: str, - resource_group_name: str, - **kwargs: Any - ) -> _models.OperationStatus: + def get(self, async_operation_id: str, resource_group_name: str, **kwargs: Any) -> _models.OperationStatus: """Get the status of an azure asynchronous operation associated with a private link scope operation. - :param async_operation_id: The operation Id. + :param async_operation_id: The operation Id. Required. :type async_operation_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus, or the result of cls(response) + :return: OperationStatus or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.OperationStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatus] - request = build_get_request( async_operation_id=async_operation_id, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -126,22 +122,20 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationStatus', pipeline_response) + deserialized = self._deserialize("OperationStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py index 7fd92fdaa46f..f3dc3783f66a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,166 +27,147 @@ 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 -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - scope_name: str, - name: str, - **kwargs: Any + resource_group_name: str, scope_name: str, name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - scope_name: str, - name: str, - *, - json: Optional[_models.ScopedResource] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, scope_name: str, name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - scope_name: str, - name: str, - **kwargs: Any + _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( + resource_group_name: str, scope_name: str, name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_by_private_link_scope_request( - subscription_id: str, - resource_group_name: str, - scope_name: str, - **kwargs: Any + resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkScopedResourcesOperations: """ @@ -202,47 +188,38 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get( - self, - resource_group_name: str, - scope_name: str, - name: str, - **kwargs: Any - ) -> _models.ScopedResource: + def get(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> _models.ScopedResource: """Gets a scoped resource in a private link scope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param name: The name of the scoped resource object. + :param name: The name of the scoped resource object. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopedResource, or the result of cls(response) + :return: ScopedResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.ScopedResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScopedResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScopedResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -250,57 +227,60 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScopedResource', pipeline_response) + deserialized = self._deserialize("ScopedResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, scope_name: str, name: str, - parameters: _models.ScopedResource, + parameters: Union[_models.ScopedResource, IO], **kwargs: Any ) -> Optional[_models.ScopedResource]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ScopedResource]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ScopedResource]] - _json = self._serialize.body(parameters, 'ScopedResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedResource") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, scope_name=scope_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -308,10 +288,9 @@ def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -320,38 +299,121 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ScopedResource', pipeline_response) + deserialized = self._deserialize("ScopedResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScopedResource', pipeline_response) + deserialized = self._deserialize("ScopedResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, scope_name: str, name: str, parameters: _models.ScopedResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ScopedResource]: """Approve or reject a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param name: The name of the scoped resource object. + :param name: The name of the scoped resource object. Required. :type name: str - :param parameters: + :param parameters: Required. :type parameters: ~$(python-base-namespace).v2019_10_17.models.ScopedResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ScopedResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2019_10_17.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopedResource]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :param 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ScopedResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2019_10_17.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + name: str, + parameters: Union[_models.ScopedResource, IO], + **kwargs: Any + ) -> LROPoller[_models.ScopedResource]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~$(python-base-namespace).v2019_10_17.models.ScopedResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 @@ -364,20 +426,17 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~$(python-base-namespace).v2019_10_17.models.ScopedResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScopedResource] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScopedResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -386,66 +445,55 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ScopedResource', pipeline_response) + deserialized = self._deserialize("ScopedResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - scope_name: str, - name: str, - **kwargs: Any + self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, scope_name=scope_name, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -453,10 +501,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -466,24 +513,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - scope_name: str, - name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str - :param name: The name of the scoped resource object. + :param name: The name of the scoped resource object. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -495,96 +536,85 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, name=name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore @distributed_trace def list_by_private_link_scope( - self, - resource_group_name: str, - scope_name: str, - **kwargs: Any - ) -> Iterable[_models.ScopedResourceListResult]: + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> Iterable["_models.ScopedResource"]: """Gets all private endpoint connections on a private link scope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopedResourceListResult or the result of - cls(response) + :return: An iterator like instance of either ScopedResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.ScopedResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScopedResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScopedResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_private_link_scope_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_private_link_scope.metadata['url'], + template_url=self.list_by_private_link_scope.metadata["url"], headers=_headers, params=_params, ) @@ -592,16 +622,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_private_link_scope_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - scope_name=scope_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -617,10 +642,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -630,8 +653,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_private_link_scope.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources"} # type: ignore + list_by_private_link_scope.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py index 2dc4b7af814e..d30f559c4957 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,236 +27,197 @@ 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 -T = TypeVar('T') + +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: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_delete_request_initial( - resource_group_name: str, - subscription_id: str, - scope_name: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_get_request( - resource_group_name: str, - subscription_id: str, - scope_name: str, - **kwargs: Any -) -> HttpRequest: +def build_get_request(resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - subscription_id: str, - scope_name: str, - *, - json: Optional[_models.AzureMonitorPrivateLinkScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_tags_request( - resource_group_name: str, - subscription_id: str, - scope_name: str, - *, - json: Optional[_models.TagsResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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) + class PrivateLinkScopesOperations: """ @@ -272,38 +238,33 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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.AzureMonitorPrivateLinkScopeListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.AzureMonitorPrivateLinkScope"]: """Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorPrivateLinkScopeListResult or the - result of cls(response) + :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -311,14 +272,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -334,10 +292,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -347,47 +303,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.AzureMonitorPrivateLinkScopeListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.AzureMonitorPrivateLinkScope"]: """Gets a list of Azure Monitor PrivateLinkScopes within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 AzureMonitorPrivateLinkScopeListResult or the - result of cls(response) + :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -395,15 +347,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -419,10 +367,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -432,36 +378,28 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - scope_name: str, - **kwargs: Any + self, resource_group_name: str, scope_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -469,10 +407,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -482,21 +419,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - scope_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -508,92 +440,78 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + 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 = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - scope_name: str, - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: + def get(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> _models.AzureMonitorPrivateLinkScope: """Returns a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope, or the result of cls(response) + :return: AzureMonitorPrivateLinkScope or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] - request = build_get_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -601,72 +519,140 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AzureMonitorPrivateLinkScope', pipeline_response) + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, scope_name: str, azure_monitor_private_link_scope_payload: _models.AzureMonitorPrivateLinkScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AzureMonitorPrivateLinkScope: """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different value for InstrumentationKey nor AppId in the Put operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. + or update a Azure Monitor PrivateLinkScope. Required. :type azure_monitor_private_link_scope_payload: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AzureMonitorPrivateLinkScope, or the result of cls(response) + :return: AzureMonitorPrivateLinkScope or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + scope_name: str, + azure_monitor_private_link_scope_payload: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different + value for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create + or update a Azure Monitor PrivateLinkScope. Required. + :type azure_monitor_private_link_scope_payload: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + scope_name: str, + azure_monitor_private_link_scope_payload: Union[_models.AzureMonitorPrivateLinkScope, IO], + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different + value for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create + or update a Azure Monitor PrivateLinkScope. Is either a model type or a IO type. Required. + :type azure_monitor_private_link_scope_payload: + ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] - _json = self._serialize.body(azure_monitor_private_link_scope_payload, 'AzureMonitorPrivateLinkScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_monitor_private_link_scope_payload, (IO, bytes)): + _content = azure_monitor_private_link_scope_payload + else: + _json = self._serialize.body(azure_monitor_private_link_scope_payload, "AzureMonitorPrivateLinkScope") request = build_create_or_update_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -674,10 +660,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -685,64 +670,132 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AzureMonitorPrivateLinkScope', pipeline_response) + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AzureMonitorPrivateLinkScope', pipeline_response) + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore - @distributed_trace + @overload def update_tags( self, resource_group_name: str, scope_name: str, private_link_scope_tags: _models.TagsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AzureMonitorPrivateLinkScope: """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. + instance. Required. :type private_link_scope_tags: ~$(python-base-namespace).v2019_10_17.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Required. + :type private_link_scope_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: Union[_models.TagsResource, IO], + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Is either a model type or a IO type. Required. + :type private_link_scope_tags: ~$(python-base-namespace).v2019_10_17.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AzureMonitorPrivateLinkScope, or the result of cls(response) + :return: AzureMonitorPrivateLinkScope or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] - _json = self._serialize.body(private_link_scope_tags, 'TagsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link_scope_tags, (IO, bytes)): + _content = private_link_scope_tags + else: + _json = self._serialize.body(private_link_scope_tags, "TagsResource") request = build_update_tags_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, scope_name=scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update_tags.metadata['url'], + content=_content, + template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) @@ -750,22 +803,20 @@ def update_tags( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AzureMonitorPrivateLinkScope', pipeline_response) + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore - + update_tags.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py index df9da9ebbfee..501ddf562dc4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-11-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-11-01-preview") # type: str + api_version = kwargs.pop("api_version", "2019-11-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json index c230b21e7154..6918f403b326 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py index 87749cef2aca..14008c78ec23 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations @@ -31,9 +31,9 @@ class MonitorManagementClient: :ivar data_collection_rules: DataCollectionRulesOperations operations :vartype data_collection_rules: $(python-base-namespace).v2019_11_01_preview.operations.DataCollectionRulesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -49,7 +49,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -63,12 +65,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -77,7 +74,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py index 8e0896e554e0..b23b37b819ef 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-11-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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-11-01-preview") # type: str + api_version = kwargs.pop("api_version", "2019-11-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py index a573acb57637..13b75397dc48 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations @@ -31,9 +31,9 @@ class MonitorManagementClient: :ivar data_collection_rules: DataCollectionRulesOperations operations :vartype data_collection_rules: $(python-base-namespace).v2019_11_01_preview.aio.operations.DataCollectionRulesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -49,7 +49,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -63,12 +65,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -77,7 +74,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/__init__.py index 09d431fd767d..8bc953b60497 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DataCollectionRuleAssociationsOperations', - 'DataCollectionRulesOperations', + "DataCollectionRuleAssociationsOperations", + "DataCollectionRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py index 011a286dca00..57482873f504 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,18 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._data_collection_rule_associations_operations import build_create_request, build_delete_request, build_get_request, build_list_by_resource_request, build_list_by_rule_request -T = TypeVar('T') +from ...operations._data_collection_rule_associations_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_request, + build_list_by_rule_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DataCollectionRuleAssociationsOperations: """ .. warning:: @@ -43,43 +58,39 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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_resource( - self, - resource_uri: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_uri: str, **kwargs: Any + ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified resource. Lists associations for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list_by_resource.metadata['url'], + template_url=self.list_by_resource.metadata["url"], headers=_headers, params=_params, ) @@ -87,21 +98,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,10 +120,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,54 +132,49 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore + list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore @distributed_trace def list_by_rule( - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_rule_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_rule.metadata['url'], + template_url=self.list_by_rule.metadata["url"], headers=_headers, params=_params, ) @@ -179,23 +182,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_rule_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -204,10 +204,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -218,50 +216,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore + list_by_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore @distributed_trace_async async def get( - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Returns the specified association. Returns the specified association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) + :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] - request = build_get_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -269,10 +259,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,57 +269,125 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - - @distributed_trace_async + @overload async def create( self, resource_uri: str, association_name: str, body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Creates or updates an association. Creates or updates an association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) + :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create( + self, + resource_uri: str, + association_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: + """Creates or updates an association. + + Creates or updates an association. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param association_name: The name of the association. The name is case insensitive. Required. + :type association_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_uri: str, + association_name: str, + body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: + """Creates or updates an association. + + Creates or updates an association. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param association_name: The name of the association. The name is case insensitive. Required. + :type association_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") + else: + _json = None request = build_create_request( resource_uri=resource_uri, @@ -338,7 +395,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -346,10 +404,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -358,56 +415,49 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + create.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> None: """Deletes an association. Deletes an association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -415,10 +465,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -429,5 +478,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py index 0967200b2d1c..9eed82858a43 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._data_collection_rules_operations import build_create_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._data_collection_rules_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DataCollectionRulesOperations: """ .. warning:: @@ -43,44 +59,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionRuleResourceListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataCollectionRuleResource"]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 DataCollectionRuleResourceListResult or the result - of cls(response) + :return: An iterator like instance of either DataCollectionRuleResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -88,15 +101,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -112,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -126,45 +133,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionRuleResourceListResult]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionRuleResource"]: """Lists all data collection rules in the specified subscription. Lists all data collection rules in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result - of cls(response) + :return: An iterator like instance of either DataCollectionRuleResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -172,14 +173,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -195,10 +193,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -209,51 +205,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any ) -> _models.DataCollectionRuleResource: """Returns the specified data collection rule. Returns the specified data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -261,10 +250,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -272,22 +260,23 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, data_collection_rule_name: str, body: Optional[_models.DataCollectionRuleResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleResource: """Creates or updates a data collection rule. @@ -295,42 +284,112 @@ async def create( Creates or updates a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Creates or updates a data collection rule. + + Creates or updates a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Creates or updates a data collection rule. + + Creates or updates a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionRuleResource") + else: + _json = None request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -338,10 +397,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -350,25 +408,26 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, data_collection_rule_name: str, body: Optional[_models.ResourceForUpdate] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleResource: """Updates part of a data collection rule. @@ -376,42 +435,111 @@ async def update( Updates part of a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.ResourceForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Updates part of a data collection rule. + + Updates part of a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[Union[_models.ResourceForUpdate, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Updates part of a data collection rule. + + Updates part of a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2019_11_01_preview.models.ResourceForUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - if body is not None: - _json = self._serialize.body(body, 'ResourceForUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "ResourceForUpdate") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -419,10 +547,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -430,55 +557,49 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any ) -> None: """Deletes a data collection rule. Deletes a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -486,10 +607,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -500,5 +620,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py index 39e2ff5c6e8f..2fd922c667dc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py @@ -31,57 +31,55 @@ from ._models_py3 import SyslogDataSource from ._models_py3 import WindowsEventLogDataSource - -from ._monitor_management_client_enums import ( - KnownDataCollectionRuleAssociationProvisioningState, - KnownDataCollectionRuleProvisioningState, - KnownDataCollectionRuleResourceKind, - KnownDataFlowStreams, - KnownExtensionDataSourceStreams, - KnownPerfCounterDataSourceStreams, - KnownSyslogDataSourceFacilityNames, - KnownSyslogDataSourceLogLevels, - KnownSyslogDataSourceStreams, - KnownWindowsEventLogDataSourceStreams, -) +from ._monitor_management_client_enums import KnownDataCollectionRuleAssociationProvisioningState +from ._monitor_management_client_enums import KnownDataCollectionRuleProvisioningState +from ._monitor_management_client_enums import KnownDataCollectionRuleResourceKind +from ._monitor_management_client_enums import KnownDataFlowStreams +from ._monitor_management_client_enums import KnownExtensionDataSourceStreams +from ._monitor_management_client_enums import KnownPerfCounterDataSourceStreams +from ._monitor_management_client_enums import KnownSyslogDataSourceFacilityNames +from ._monitor_management_client_enums import KnownSyslogDataSourceLogLevels +from ._monitor_management_client_enums import KnownSyslogDataSourceStreams +from ._monitor_management_client_enums import KnownWindowsEventLogDataSourceStreams from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AzureMonitorMetricsDestination', - 'DataCollectionRule', - 'DataCollectionRuleAssociation', - 'DataCollectionRuleAssociationProxyOnlyResource', - 'DataCollectionRuleAssociationProxyOnlyResourceListResult', - 'DataCollectionRuleAssociationProxyOnlyResourceProperties', - 'DataCollectionRuleDataSources', - 'DataCollectionRuleDestinations', - 'DataCollectionRuleResource', - 'DataCollectionRuleResourceListResult', - 'DataCollectionRuleResourceProperties', - 'DataFlow', - 'DataSourcesSpec', - 'DestinationsSpec', - 'DestinationsSpecAzureMonitorMetrics', - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponse', - 'ExtensionDataSource', - 'LogAnalyticsDestination', - 'PerfCounterDataSource', - 'ResourceForUpdate', - 'SyslogDataSource', - 'WindowsEventLogDataSource', - 'KnownDataCollectionRuleAssociationProvisioningState', - 'KnownDataCollectionRuleProvisioningState', - 'KnownDataCollectionRuleResourceKind', - 'KnownDataFlowStreams', - 'KnownExtensionDataSourceStreams', - 'KnownPerfCounterDataSourceStreams', - 'KnownSyslogDataSourceFacilityNames', - 'KnownSyslogDataSourceLogLevels', - 'KnownSyslogDataSourceStreams', - 'KnownWindowsEventLogDataSourceStreams', + "AzureMonitorMetricsDestination", + "DataCollectionRule", + "DataCollectionRuleAssociation", + "DataCollectionRuleAssociationProxyOnlyResource", + "DataCollectionRuleAssociationProxyOnlyResourceListResult", + "DataCollectionRuleAssociationProxyOnlyResourceProperties", + "DataCollectionRuleDataSources", + "DataCollectionRuleDestinations", + "DataCollectionRuleResource", + "DataCollectionRuleResourceListResult", + "DataCollectionRuleResourceProperties", + "DataFlow", + "DataSourcesSpec", + "DestinationsSpec", + "DestinationsSpecAzureMonitorMetrics", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "ExtensionDataSource", + "LogAnalyticsDestination", + "PerfCounterDataSource", + "ResourceForUpdate", + "SyslogDataSource", + "WindowsEventLogDataSource", + "KnownDataCollectionRuleAssociationProvisioningState", + "KnownDataCollectionRuleProvisioningState", + "KnownDataCollectionRuleResourceKind", + "KnownDataFlowStreams", + "KnownExtensionDataSourceStreams", + "KnownPerfCounterDataSourceStreams", + "KnownSyslogDataSourceFacilityNames", + "KnownSyslogDataSourceLogLevels", + "KnownSyslogDataSourceStreams", + "KnownWindowsEventLogDataSourceStreams", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py index 51578214c398..0b62a84a255b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_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. @@ -6,17 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AzureMonitorMetricsDestination(msrest.serialization.Model): +class AzureMonitorMetricsDestination(_serialization.Model): """Azure Monitor Metrics destination. :ivar name: A friendly name for the destination. @@ -26,26 +32,21 @@ class AzureMonitorMetricsDestination(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. :paramtype name: str """ - super(AzureMonitorMetricsDestination, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class DataCollectionRule(msrest.serialization.Model): +class DataCollectionRule(_serialization.Model): """Definition of what monitoring data to collect and where that data should be sent. Variables are only populated by the server, and will be ignored when sending a request. @@ -65,23 +66,23 @@ class DataCollectionRule(msrest.serialization.Model): :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleProvisioningState """ _validation = { - 'immutable_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "immutable_id": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'data_sources': {'key': 'dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "immutable_id": {"key": "immutableId", "type": "str"}, + "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, + "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, + "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -107,7 +108,7 @@ def __init__( :keyword data_flows: The specification of data flows. :paramtype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] """ - super(DataCollectionRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.immutable_id = None self.data_sources = data_sources @@ -116,7 +117,7 @@ def __init__( self.provisioning_state = None -class DataCollectionRuleAssociation(msrest.serialization.Model): +class DataCollectionRuleAssociation(_serialization.Model): """Definition of association of a data collection rule with a monitored Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -127,28 +128,22 @@ class DataCollectionRuleAssociation(msrest.serialization.Model): associated. :vartype data_collection_rule_id: str :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'dataCollectionRuleId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_rule_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, **kwargs): """ :keyword description: Description of the association. :paramtype description: str @@ -156,13 +151,13 @@ def __init__( associated. :paramtype data_collection_rule_id: str """ - super(DataCollectionRuleAssociation, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.data_collection_rule_id = data_collection_rule_id self.provisioning_state = None -class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model): +class DataCollectionRuleAssociationProxyOnlyResource(_serialization.Model): """Definition of generic ARM proxy resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -181,36 +176,30 @@ class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model) associated. :vartype data_collection_rule_id: str :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'properties.dataCollectionRuleId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "data_collection_rule_id": {"key": "properties.dataCollectionRuleId", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_rule_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, **kwargs): """ :keyword description: Description of the association. :paramtype description: str @@ -218,7 +207,7 @@ def __init__( associated. :paramtype data_collection_rule_id: str """ - super(DataCollectionRuleAssociationProxyOnlyResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -228,12 +217,12 @@ def __init__( self.provisioning_state = None -class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serialization.Model): +class DataCollectionRuleAssociationProxyOnlyResourceListResult(_serialization.Model): """A pageable list of resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. A list of resources. + :ivar value: A list of resources. Required. :vartype value: list[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] :ivar next_link: The URL to use for getting the next set of results. @@ -241,12 +230,12 @@ class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serializat """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCollectionRuleAssociationProxyOnlyResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataCollectionRuleAssociationProxyOnlyResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -257,13 +246,13 @@ def __init__( **kwargs ): """ - :keyword value: Required. A list of resources. + :keyword value: A list of resources. Required. :paramtype value: list[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(DataCollectionRuleAssociationProxyOnlyResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -279,28 +268,22 @@ class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRul associated. :vartype data_collection_rule_id: str :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'dataCollectionRuleId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_rule_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, **kwargs): """ :keyword description: Description of the association. :paramtype description: str @@ -308,10 +291,10 @@ def __init__( associated. :paramtype data_collection_rule_id: str """ - super(DataCollectionRuleAssociationProxyOnlyResourceProperties, self).__init__(description=description, data_collection_rule_id=data_collection_rule_id, **kwargs) + super().__init__(description=description, data_collection_rule_id=data_collection_rule_id, **kwargs) -class DataSourcesSpec(msrest.serialization.Model): +class DataSourcesSpec(_serialization.Model): """Specification of data sources that will be collected. :ivar performance_counters: The list of performance counter data source configurations. @@ -328,10 +311,10 @@ class DataSourcesSpec(msrest.serialization.Model): """ _attribute_map = { - 'performance_counters': {'key': 'performanceCounters', 'type': '[PerfCounterDataSource]'}, - 'windows_event_logs': {'key': 'windowsEventLogs', 'type': '[WindowsEventLogDataSource]'}, - 'syslog': {'key': 'syslog', 'type': '[SyslogDataSource]'}, - 'extensions': {'key': 'extensions', 'type': '[ExtensionDataSource]'}, + "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, + "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, + "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, + "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, } def __init__( @@ -356,7 +339,7 @@ def __init__( :paramtype extensions: list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] """ - super(DataSourcesSpec, self).__init__(**kwargs) + super().__init__(**kwargs) self.performance_counters = performance_counters self.windows_event_logs = windows_event_logs self.syslog = syslog @@ -364,27 +347,27 @@ def __init__( class DataCollectionRuleDataSources(DataSourcesSpec): - """The specification of data sources. -This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. + """The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~$(python-base-namespace).v2019_11_01_preview.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~$(python-base-namespace).v2019_11_01_preview.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: - list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: + list[~$(python-base-namespace).v2019_11_01_preview.models.PerfCounterDataSource] + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: + list[~$(python-base-namespace).v2019_11_01_preview.models.WindowsEventLogDataSource] + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: + list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] """ _attribute_map = { - 'performance_counters': {'key': 'performanceCounters', 'type': '[PerfCounterDataSource]'}, - 'windows_event_logs': {'key': 'windowsEventLogs', 'type': '[WindowsEventLogDataSource]'}, - 'syslog': {'key': 'syslog', 'type': '[SyslogDataSource]'}, - 'extensions': {'key': 'extensions', 'type': '[ExtensionDataSource]'}, + "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, + "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, + "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, + "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, } def __init__( @@ -409,10 +392,16 @@ def __init__( :paramtype extensions: list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] """ - super(DataCollectionRuleDataSources, self).__init__(performance_counters=performance_counters, windows_event_logs=windows_event_logs, syslog=syslog, extensions=extensions, **kwargs) + super().__init__( + performance_counters=performance_counters, + windows_event_logs=windows_event_logs, + syslog=syslog, + extensions=extensions, + **kwargs + ) -class DestinationsSpec(msrest.serialization.Model): +class DestinationsSpec(_serialization.Model): """Specification of destinations that can be used in data flows. :ivar log_analytics: List of Log Analytics destinations. @@ -424,8 +413,8 @@ class DestinationsSpec(msrest.serialization.Model): """ _attribute_map = { - 'log_analytics': {'key': 'logAnalytics', 'type': '[LogAnalyticsDestination]'}, - 'azure_monitor_metrics': {'key': 'azureMonitorMetrics', 'type': 'DestinationsSpecAzureMonitorMetrics'}, + "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, + "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, } def __init__( @@ -443,7 +432,7 @@ def __init__( :paramtype azure_monitor_metrics: ~$(python-base-namespace).v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics """ - super(DestinationsSpec, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_analytics = log_analytics self.azure_monitor_metrics = azure_monitor_metrics @@ -460,8 +449,8 @@ class DataCollectionRuleDestinations(DestinationsSpec): """ _attribute_map = { - 'log_analytics': {'key': 'logAnalytics', 'type': '[LogAnalyticsDestination]'}, - 'azure_monitor_metrics': {'key': 'azureMonitorMetrics', 'type': 'DestinationsSpecAzureMonitorMetrics'}, + "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, + "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, } def __init__( @@ -479,21 +468,21 @@ def __init__( :paramtype azure_monitor_metrics: ~$(python-base-namespace).v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics """ - super(DataCollectionRuleDestinations, self).__init__(log_analytics=log_analytics, azure_monitor_metrics=azure_monitor_metrics, **kwargs) + super().__init__(log_analytics=log_analytics, azure_monitor_metrics=azure_monitor_metrics, **kwargs) -class DataCollectionRuleResource(msrest.serialization.Model): +class DataCollectionRuleResource(_serialization.Model): # pylint: disable=too-many-instance-attributes """Definition of ARM tracked top level 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 location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Known values are: "Linux", "Windows". + :ivar kind: The kind of the resource. Known values are: "Linux" and "Windows". :vartype kind: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleResourceKind :ivar id: Fully qualified ID of the resource. @@ -519,35 +508,35 @@ class DataCollectionRuleResource(msrest.serialization.Model): :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleProvisioningState """ _validation = { - 'location': {'required': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'immutable_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "location": {"required": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "immutable_id": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'immutable_id': {'key': 'properties.immutableId', 'type': 'str'}, - 'data_sources': {'key': 'properties.dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'properties.destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'properties.dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "kind": {"key": "kind", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "immutable_id": {"key": "properties.immutableId", "type": "str"}, + "data_sources": {"key": "properties.dataSources", "type": "DataCollectionRuleDataSources"}, + "destinations": {"key": "properties.destinations", "type": "DataCollectionRuleDestinations"}, + "data_flows": {"key": "properties.dataFlows", "type": "[DataFlow]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -563,11 +552,11 @@ def __init__( **kwargs ): """ - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Known values are: "Linux", "Windows". + :keyword kind: The kind of the resource. Known values are: "Linux" and "Windows". :paramtype kind: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleResourceKind :keyword description: Description of the data collection rule. @@ -583,7 +572,7 @@ def __init__( :keyword data_flows: The specification of data flows. :paramtype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] """ - super(DataCollectionRuleResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.kind = kind @@ -599,12 +588,12 @@ def __init__( self.provisioning_state = None -class DataCollectionRuleResourceListResult(msrest.serialization.Model): +class DataCollectionRuleResourceListResult(_serialization.Model): """A pageable list of resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. A list of resources. + :ivar value: A list of resources. Required. :vartype value: list[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource] :ivar next_link: The URL to use for getting the next set of results. @@ -612,29 +601,23 @@ class DataCollectionRuleResourceListResult(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCollectionRuleResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataCollectionRuleResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["_models.DataCollectionRuleResource"], - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs): """ - :keyword value: Required. A list of resources. + :keyword value: A list of resources. Required. :paramtype value: list[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(DataCollectionRuleResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -659,23 +642,23 @@ class DataCollectionRuleResourceProperties(DataCollectionRule): :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleProvisioningState """ _validation = { - 'immutable_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "immutable_id": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'data_sources': {'key': 'dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "immutable_id": {"key": "immutableId", "type": "str"}, + "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, + "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, + "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -701,10 +684,16 @@ def __init__( :keyword data_flows: The specification of data flows. :paramtype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] """ - super(DataCollectionRuleResourceProperties, self).__init__(description=description, data_sources=data_sources, destinations=destinations, data_flows=data_flows, **kwargs) + super().__init__( + description=description, + data_sources=data_sources, + destinations=destinations, + data_flows=data_flows, + **kwargs + ) -class DataFlow(msrest.serialization.Model): +class DataFlow(_serialization.Model): """Definition of which streams are sent to which destinations. :ivar streams: List of streams for this data flow. @@ -715,8 +704,8 @@ class DataFlow(msrest.serialization.Model): """ _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'destinations': {'key': 'destinations', 'type': '[str]'}, + "streams": {"key": "streams", "type": "[str]"}, + "destinations": {"key": "destinations", "type": "[str]"}, } def __init__( @@ -733,7 +722,7 @@ def __init__( :keyword destinations: List of destinations for this data flow. :paramtype destinations: list[str] """ - super(DataFlow, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.destinations = destinations @@ -748,25 +737,20 @@ class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. :paramtype name: str """ - super(DestinationsSpecAzureMonitorMetrics, self).__init__(name=name, **kwargs) + super().__init__(name=name, **kwargs) -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -774,31 +758,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -817,28 +797,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -846,7 +822,7 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. @@ -854,57 +830,52 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~$(python-base-namespace).v2019_11_01_preview.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ExtensionDataSource(msrest.serialization.Model): +class ExtensionDataSource(_serialization.Model): """Definition of which data will be collected from a separate VM extension that integrates with the Azure Monitor Agent. -Collected from either Windows and Linux machines, depending on which extension is defined. + Collected from either Windows and Linux machines, depending on which extension is defined. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to Azure. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownExtensionDataSourceStreams] - :ivar extension_name: Required. The name of the VM extension. - :vartype extension_name: str - :ivar extension_settings: The extension settings. The format is specific for particular - extension. - :vartype extension_settings: any - :ivar input_data_sources: The list of data sources this extension needs data from. - :vartype input_data_sources: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownExtensionDataSourceStreams] + :ivar extension_name: The name of the VM extension. Required. + :vartype extension_name: str + :ivar extension_settings: The extension settings. The format is specific for particular + extension. + :vartype extension_settings: JSON + :ivar input_data_sources: The list of data sources this extension needs data from. + :vartype input_data_sources: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _validation = { - 'extension_name': {'required': True}, + "extension_name": {"required": True}, } _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'extension_name': {'key': 'extensionName', 'type': 'str'}, - 'extension_settings': {'key': 'extensionSettings', 'type': 'object'}, - 'input_data_sources': {'key': 'inputDataSources', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "extension_name": {"key": "extensionName", "type": "str"}, + "extension_settings": {"key": "extensionSettings", "type": "object"}, + "input_data_sources": {"key": "inputDataSources", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -912,7 +883,7 @@ def __init__( *, extension_name: str, streams: Optional[List[Union[str, "_models.KnownExtensionDataSourceStreams"]]] = None, - extension_settings: Optional[Any] = None, + extension_settings: Optional[JSON] = None, input_data_sources: Optional[List[str]] = None, name: Optional[str] = None, **kwargs @@ -923,11 +894,11 @@ def __init__( Analytics the data will be sent to. :paramtype streams: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownExtensionDataSourceStreams] - :keyword extension_name: Required. The name of the VM extension. + :keyword extension_name: The name of the VM extension. Required. :paramtype extension_name: str :keyword extension_settings: The extension settings. The format is specific for particular extension. - :paramtype extension_settings: any + :paramtype extension_settings: JSON :keyword input_data_sources: The list of data sources this extension needs data from. :paramtype input_data_sources: list[str] :keyword name: A friendly name for the data source. @@ -935,7 +906,7 @@ def __init__( collection rule. :paramtype name: str """ - super(ExtensionDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.extension_name = extension_name self.extension_settings = extension_settings @@ -943,7 +914,7 @@ def __init__( self.name = name -class LogAnalyticsDestination(msrest.serialization.Model): +class LogAnalyticsDestination(_serialization.Model): """Log Analytics destination. Variables are only populated by the server, and will be ignored when sending a request. @@ -959,22 +930,16 @@ class LogAnalyticsDestination(msrest.serialization.Model): """ _validation = { - 'workspace_id': {'readonly': True}, + "workspace_id": {"readonly": True}, } _attribute_map = { - 'workspace_resource_id': {'key': 'workspaceResourceId', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "workspace_resource_id": {"key": "workspaceResourceId", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - workspace_resource_id: Optional[str] = None, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, workspace_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs): """ :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. :paramtype workspace_resource_id: str @@ -983,40 +948,40 @@ def __init__( collection rule. :paramtype name: str """ - super(LogAnalyticsDestination, self).__init__(**kwargs) + super().__init__(**kwargs) self.workspace_resource_id = workspace_resource_id self.workspace_id = None self.name = name -class PerfCounterDataSource(msrest.serialization.Model): +class PerfCounterDataSource(_serialization.Model): """Definition of which performance counters will be collected and how they will be collected by this data collection rule. -Collected from both Windows and Linux machines where the counter is present. + Collected from both Windows and Linux machines where the counter is present. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownPerfCounterDataSourceStreams] - :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :vartype sampling_frequency_in_seconds: int - :ivar counter_specifiers: A list of specifier names of the performance counters you want to - collect. - Use a wildcard (*) to collect a counter for all instances. - To get a list of performance counters on Windows, run the command 'typeperf'. - :vartype counter_specifiers: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownPerfCounterDataSourceStreams] + :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter + measurements (samples). + :vartype sampling_frequency_in_seconds: int + :ivar counter_specifiers: A list of specifier names of the performance counters you want to + collect. + Use a wildcard (*) to collect a counter for all instances. + To get a list of performance counters on Windows, run the command 'typeperf'. + :vartype counter_specifiers: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'sampling_frequency_in_seconds': {'key': 'samplingFrequencyInSeconds', 'type': 'int'}, - 'counter_specifiers': {'key': 'counterSpecifiers', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "sampling_frequency_in_seconds": {"key": "samplingFrequencyInSeconds", "type": "int"}, + "counter_specifiers": {"key": "counterSpecifiers", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -1047,64 +1012,59 @@ def __init__( collection rule. :paramtype name: str """ - super(PerfCounterDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.sampling_frequency_in_seconds = sampling_frequency_in_seconds self.counter_specifiers = counter_specifiers self.name = name -class ResourceForUpdate(msrest.serialization.Model): +class ResourceForUpdate(_serialization.Model): """Definition of ARM tracked top level resource properties for update operation. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :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 - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceForUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class SyslogDataSource(msrest.serialization.Model): +class SyslogDataSource(_serialization.Model): """Definition of which syslog data will be collected and how it will be collected. -Only collected from Linux machines. + Only collected from Linux machines. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceStreams] - :ivar facility_names: The list of facility names. - :vartype facility_names: list[str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceFacilityNames] - :ivar log_levels: The log levels to collect. - :vartype log_levels: list[str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceLogLevels] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceStreams] + :ivar facility_names: The list of facility names. + :vartype facility_names: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceFacilityNames] + :ivar log_levels: The log levels to collect. + :vartype log_levels: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceLogLevels] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'facility_names': {'key': 'facilityNames', 'type': '[str]'}, - 'log_levels': {'key': 'logLevels', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "facility_names": {"key": "facilityNames", "type": "[str]"}, + "log_levels": {"key": "logLevels", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -1133,34 +1093,34 @@ def __init__( collection rule. :paramtype name: str """ - super(SyslogDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.facility_names = facility_names self.log_levels = log_levels self.name = name -class WindowsEventLogDataSource(msrest.serialization.Model): +class WindowsEventLogDataSource(_serialization.Model): """Definition of which Windows Event Log events will be collected and how they will be collected. -Only collected from Windows machines. + Only collected from Windows machines. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownWindowsEventLogDataSourceStreams] - :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. - :vartype x_path_queries: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownWindowsEventLogDataSourceStreams] + :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. + :vartype x_path_queries: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'x_path_queries': {'key': 'xPathQueries', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "x_path_queries": {"key": "xPathQueries", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -1184,7 +1144,7 @@ def __init__( collection rule. :paramtype name: str """ - super(WindowsEventLogDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.x_path_queries = x_path_queries self.name = name diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py index 714dcb202e72..a1feab4806d0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py @@ -11,8 +11,7 @@ class KnownDataCollectionRuleAssociationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state. - """ + """The resource provisioning state.""" CREATING = "Creating" UPDATING = "Updating" @@ -20,9 +19,9 @@ class KnownDataCollectionRuleAssociationProvisioningState(str, Enum, metaclass=C SUCCEEDED = "Succeeded" FAILED = "Failed" + class KnownDataCollectionRuleProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state. - """ + """The resource provisioning state.""" CREATING = "Creating" UPDATING = "Updating" @@ -30,14 +29,16 @@ class KnownDataCollectionRuleProvisioningState(str, Enum, metaclass=CaseInsensit SUCCEEDED = "Succeeded" FAILED = "Failed" + class KnownDataCollectionRuleResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the resource. - """ + """The kind of the resource.""" LINUX = "Linux" WINDOWS = "Windows" + class KnownDataFlowStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownDataFlowStreams.""" MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -45,7 +46,9 @@ class KnownDataFlowStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" + class KnownExtensionDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownExtensionDataSourceStreams.""" MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -53,12 +56,16 @@ class KnownExtensionDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMe MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" + class KnownPerfCounterDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownPerfCounterDataSourceStreams.""" MICROSOFT_PERF = "Microsoft-Perf" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" + class KnownSyslogDataSourceFacilityNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownSyslogDataSourceFacilityNames.""" AUTH = "auth" AUTHPRIV = "authpriv" @@ -82,7 +89,9 @@ class KnownSyslogDataSourceFacilityNames(str, Enum, metaclass=CaseInsensitiveEnu LOCAL7 = "local7" ASTERISK = "*" + class KnownSyslogDataSourceLogLevels(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownSyslogDataSourceLogLevels.""" DEBUG = "Debug" INFO = "Info" @@ -94,11 +103,15 @@ class KnownSyslogDataSourceLogLevels(str, Enum, metaclass=CaseInsensitiveEnumMet EMERGENCY = "Emergency" ASTERISK = "*" + class KnownSyslogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownSyslogDataSourceStreams.""" MICROSOFT_SYSLOG = "Microsoft-Syslog" + class KnownWindowsEventLogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownWindowsEventLogDataSourceStreams.""" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" MICROSOFT_EVENT = "Microsoft-Event" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/__init__.py index 09d431fd767d..8bc953b60497 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DataCollectionRuleAssociationsOperations', - 'DataCollectionRulesOperations', + "DataCollectionRuleAssociationsOperations", + "DataCollectionRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py index f1b3af5e4b65..b39f6deccfd1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,194 +25,156 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_resource_request( - resource_uri: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_rule_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( - resource_uri: str, - association_name: str, - **kwargs: Any -) -> HttpRequest: +def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - resource_uri: str, - association_name: str, - *, - json: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_uri: str, - association_name: str, - **kwargs: Any -) -> HttpRequest: + _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(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DataCollectionRuleAssociationsOperations: """ @@ -228,43 +195,39 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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_resource( - self, - resource_uri: str, - **kwargs: Any - ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_uri: str, **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified resource. Lists associations for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list_by_resource.metadata['url'], + template_url=self.list_by_resource.metadata["url"], headers=_headers, params=_params, ) @@ -272,21 +235,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -295,10 +257,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -309,54 +269,49 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore + list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore @distributed_trace def list_by_rule( - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any - ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_rule_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_rule.metadata['url'], + template_url=self.list_by_rule.metadata["url"], headers=_headers, params=_params, ) @@ -364,23 +319,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_rule_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -389,10 +341,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -403,50 +353,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore + list_by_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore @distributed_trace def get( - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Returns the specified association. Returns the specified association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) + :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] - request = build_get_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -454,10 +396,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -465,57 +406,125 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - - @distributed_trace + @overload def create( self, resource_uri: str, association_name: str, body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Creates or updates an association. Creates or updates an association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) + :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create( + self, + resource_uri: str, + association_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: + """Creates or updates an association. + + Creates or updates an association. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param association_name: The name of the association. The name is case insensitive. Required. + :type association_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_uri: str, + association_name: str, + body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: + """Creates or updates an association. + + Creates or updates an association. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param association_name: The name of the association. The name is case insensitive. Required. + :type association_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") + else: + _json = None request = build_create_request( resource_uri=resource_uri, @@ -523,7 +532,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -531,10 +541,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -543,56 +552,49 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + create.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> None: """Deletes an association. Deletes an association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -600,10 +602,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -614,5 +615,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py index 15f71cd7dabb..85b06e49dea0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +25,209 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - *, - json: Optional[_models.DataCollectionRuleResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_update_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - *, - json: Optional[_models.ResourceForUpdate] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_delete_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + class DataCollectionRulesOperations: """ @@ -277,44 +248,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.DataCollectionRuleResourceListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleResource"]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 DataCollectionRuleResourceListResult or the result - of cls(response) + :return: An iterator like instance of either DataCollectionRuleResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -322,15 +290,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -346,10 +310,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -360,45 +322,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.DataCollectionRuleResourceListResult]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionRuleResource"]: """Lists all data collection rules in the specified subscription. Lists all data collection rules in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result - of cls(response) + :return: An iterator like instance of either DataCollectionRuleResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -406,14 +362,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -429,10 +382,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -443,51 +394,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any ) -> _models.DataCollectionRuleResource: """Returns the specified data collection rule. Returns the specified data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -495,10 +439,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -506,22 +449,23 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, data_collection_rule_name: str, body: Optional[_models.DataCollectionRuleResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleResource: """Creates or updates a data collection rule. @@ -529,42 +473,112 @@ def create( Creates or updates a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Creates or updates a data collection rule. + + Creates or updates a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Creates or updates a data collection rule. + + Creates or updates a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionRuleResource") + else: + _json = None request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -572,10 +586,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -584,25 +597,26 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, data_collection_rule_name: str, body: Optional[_models.ResourceForUpdate] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleResource: """Updates part of a data collection rule. @@ -610,42 +624,111 @@ def update( Updates part of a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.ResourceForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Updates part of a data collection rule. + + Updates part of a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[Union[_models.ResourceForUpdate, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Updates part of a data collection rule. + + Updates part of a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2019_11_01_preview.models.ResourceForUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - if body is not None: - _json = self._serialize.body(body, 'ResourceForUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "ResourceForUpdate") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -653,10 +736,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -664,55 +746,49 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any ) -> None: """Deletes a data collection rule. Deletes a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -720,10 +796,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -734,5 +809,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py index 24ef9950ab69..6769079daccf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py @@ -25,43 +25,40 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 :keyword api_version: Api Version. Default value is "2020-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2020-01-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json index b9c51d72cb60..bf8fca7f72ca 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json @@ -10,14 +10,14 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 } @@ -25,7 +25,7 @@ "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 } @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py index e12bfe7cdd4f..19296b7e4e2a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ManagementGroupDiagnosticSettingsOperations @@ -22,14 +21,15 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations operations :vartype management_group_diagnostic_settings: $(python-base-namespace).v2020_01_01_preview.operations.ManagementGroupDiagnosticSettingsOperations - :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 base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -39,10 +39,7 @@ class MonitorManagementClient: """ def __init__( - self, - credential: "TokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -55,12 +52,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -69,7 +61,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py index 41d28e9db87f..d128e92641dc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py @@ -25,42 +25,37 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 :keyword api_version: Api Version. Default value is "2020-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2020-01-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py index 4613ac3ebaa7..de4aa0aec67b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ManagementGroupDiagnosticSettingsOperations @@ -22,14 +21,15 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations operations :vartype management_group_diagnostic_settings: $(python-base-namespace).v2020_01_01_preview.aio.operations.ManagementGroupDiagnosticSettingsOperations - :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 base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -39,10 +39,7 @@ class MonitorManagementClient: """ def __init__( - self, - credential: "AsyncTokenCredential", - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -55,12 +52,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -69,7 +61,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/__init__.py index d9ec384c7ee2..0a55570458ff 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ManagementGroupDiagnosticSettingsOperations', + "ManagementGroupDiagnosticSettingsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py index 19972f3614d8..87dc85c7bc9b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_group_diagnostic_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._management_group_diagnostic_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementGroupDiagnosticSettingsOperations: """ .. warning:: @@ -43,43 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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, - management_group_id: str, - name: str, - **kwargs: Any + self, management_group_id: str, name: str, **kwargs: Any ) -> _models.ManagementGroupDiagnosticSettingsResource: """Gets the active management group diagnostic settings for the specified resource. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) + :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] - request = build_get_request( management_group_id=management_group_id, name=name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -87,10 +94,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -98,52 +104,117 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + + @overload + async def create_or_update( + self, + management_group_id: str, + name: str, + parameters: _models.ManagementGroupDiagnosticSettingsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementGroupDiagnosticSettingsResource: + """Creates or updates management group diagnostic settings for the specified resource. + + :param management_group_id: The management group id. Required. + :type management_group_id: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: + ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ManagementGroupDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + management_group_id: str, + name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementGroupDiagnosticSettingsResource: + """Creates or updates management group diagnostic settings for the specified resource. + :param management_group_id: The management group id. Required. + :type management_group_id: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. 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: ManagementGroupDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( self, management_group_id: str, name: str, - parameters: _models.ManagementGroupDiagnosticSettingsResource, + parameters: Union[_models.ManagementGroupDiagnosticSettingsResource, IO], **kwargs: Any ) -> _models.ManagementGroupDiagnosticSettingsResource: """Creates or updates management group diagnostic settings for the specified resource. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. :type parameters: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) + :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementGroupDiagnosticSettingsResource") request = build_create_or_update_request( management_group_id=management_group_id, @@ -151,7 +222,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -159,10 +231,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -170,51 +241,44 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - management_group_id: str, - name: str, - **kwargs: Any + self, management_group_id: str, name: str, **kwargs: Any ) -> None: """Deletes existing management group diagnostic settings for the specified resource. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( management_group_id=management_group_id, name=name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -222,10 +286,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -236,43 +299,39 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore - + delete.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace def list( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable[_models.ManagementGroupDiagnosticSettingsResourceCollection]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.ManagementGroupDiagnosticSettingsResource"]: """Gets the active management group diagnostic settings list for the specified management group. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - ManagementGroupDiagnosticSettingsResourceCollection or the result of cls(response) + :return: An iterator like instance of either ManagementGroupDiagnosticSettingsResource or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -280,14 +339,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - management_group_id=management_group_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -303,10 +359,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -317,8 +371,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py index 104364b71e26..7bd4bf700a00 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py @@ -11,16 +11,16 @@ from ._models_py3 import ManagementGroupDiagnosticSettingsResourceCollection from ._models_py3 import ManagementGroupLogSettings from ._models_py3 import ManagementGroupProxyOnlyResource - from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ErrorResponse', - 'ManagementGroupDiagnosticSettingsResource', - 'ManagementGroupDiagnosticSettingsResourceCollection', - 'ManagementGroupLogSettings', - 'ManagementGroupProxyOnlyResource', + "ErrorResponse", + "ManagementGroupDiagnosticSettingsResource", + "ManagementGroupDiagnosticSettingsResourceCollection", + "ManagementGroupLogSettings", + "ManagementGroupProxyOnlyResource", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py index b0cf692ec6a5..02902c0a3490 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_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. @@ -6,17 +7,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, TYPE_CHECKING +from typing import List, Optional -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models - -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -26,29 +22,23 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ManagementGroupProxyOnlyResource(msrest.serialization.Model): +class ManagementGroupProxyOnlyResource(_serialization.Model): """A proxy only azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -64,29 +54,24 @@ class ManagementGroupProxyOnlyResource(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'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, **kwargs): """ :keyword location: Location of the resource. :paramtype location: str """ - super(ManagementGroupProxyOnlyResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -127,22 +112,22 @@ class ManagementGroupDiagnosticSettingsResource(ManagementGroupProxyOnlyResource """ _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'event_hub_name': {'key': 'properties.eventHubName', 'type': 'str'}, - 'logs': {'key': 'properties.logs', 'type': '[ManagementGroupLogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, + "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, + "logs": {"key": "properties.logs", "type": "[ManagementGroupLogSettings]"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, } def __init__( @@ -179,7 +164,7 @@ def __init__( /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. :paramtype workspace_id: str """ - super(ManagementGroupDiagnosticSettingsResource, self).__init__(location=location, **kwargs) + super().__init__(location=location, **kwargs) self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id self.event_hub_authorization_rule_id = event_hub_authorization_rule_id @@ -188,7 +173,7 @@ def __init__( self.workspace_id = workspace_id -class ManagementGroupDiagnosticSettingsResourceCollection(msrest.serialization.Model): +class ManagementGroupDiagnosticSettingsResourceCollection(_serialization.Model): """Represents a collection of management group diagnostic settings resources. :ivar value: The collection of management group diagnostic settings resources. @@ -197,60 +182,49 @@ class ManagementGroupDiagnosticSettingsResourceCollection(msrest.serialization.M """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ManagementGroupDiagnosticSettingsResource]'}, + "value": {"key": "value", "type": "[ManagementGroupDiagnosticSettingsResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ManagementGroupDiagnosticSettingsResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ManagementGroupDiagnosticSettingsResource"]] = None, **kwargs): """ :keyword value: The collection of management group diagnostic settings resources. :paramtype value: list[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource] """ - super(ManagementGroupDiagnosticSettingsResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ManagementGroupLogSettings(msrest.serialization.Model): +class ManagementGroupLogSettings(_serialization.Model): """Part of Management Group diagnostic setting. Specifies the settings for a particular log. All required parameters must be populated in order to send to Azure. - :ivar category: Required. Name of a Management Group Diagnostic Log category for a resource - type this setting is applied to. + :ivar category: Name of a Management Group Diagnostic Log category for a resource type this + setting is applied to. Required. :vartype category: str - :ivar enabled: Required. a value indicating whether this log is enabled. + :ivar enabled: a value indicating whether this log is enabled. Required. :vartype enabled: bool """ _validation = { - 'category': {'required': True}, - 'enabled': {'required': True}, + "category": {"required": True}, + "enabled": {"required": True}, } _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "category": {"key": "category", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - category: str, - enabled: bool, - **kwargs - ): + def __init__(self, *, category: str, enabled: bool, **kwargs): """ - :keyword category: Required. Name of a Management Group Diagnostic Log category for a resource - type this setting is applied to. + :keyword category: Name of a Management Group Diagnostic Log category for a resource type this + setting is applied to. Required. :paramtype category: str - :keyword enabled: Required. a value indicating whether this log is enabled. + :keyword enabled: a value indicating whether this log is enabled. Required. :paramtype enabled: bool """ - super(ManagementGroupLogSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.category = category self.enabled = enabled diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/__init__.py index d9ec384c7ee2..0a55570458ff 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ManagementGroupDiagnosticSettingsOperations', + "ManagementGroupDiagnosticSettingsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py index 7f5cd7c26220..bb806a94c86c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,157 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - management_group_id: str, - name: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(management_group_id: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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( - management_group_id: str, - name: str, - *, - json: Optional[_models.ManagementGroupDiagnosticSettingsResource] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(management_group_id: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - management_group_id: str, - name: str, - **kwargs: Any -) -> HttpRequest: + _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(management_group_id: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - management_group_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_request(management_group_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ManagementGroupDiagnosticSettingsOperations: """ @@ -191,43 +168,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - management_group_id: str, - name: str, - **kwargs: Any + self, management_group_id: str, name: str, **kwargs: Any ) -> _models.ManagementGroupDiagnosticSettingsResource: """Gets the active management group diagnostic settings for the specified resource. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) + :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] - request = build_get_request( management_group_id=management_group_id, name=name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -235,10 +205,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,52 +215,117 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + + @overload + def create_or_update( + self, + management_group_id: str, + name: str, + parameters: _models.ManagementGroupDiagnosticSettingsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementGroupDiagnosticSettingsResource: + """Creates or updates management group diagnostic settings for the specified resource. + + :param management_group_id: The management group id. Required. + :type management_group_id: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: + ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ManagementGroupDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + management_group_id: str, + name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementGroupDiagnosticSettingsResource: + """Creates or updates management group diagnostic settings for the specified resource. + :param management_group_id: The management group id. Required. + :type management_group_id: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. 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: ManagementGroupDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( self, management_group_id: str, name: str, - parameters: _models.ManagementGroupDiagnosticSettingsResource, + parameters: Union[_models.ManagementGroupDiagnosticSettingsResource, IO], **kwargs: Any ) -> _models.ManagementGroupDiagnosticSettingsResource: """Creates or updates management group diagnostic settings for the specified resource. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. :type parameters: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) + :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementGroupDiagnosticSettingsResource") request = build_create_or_update_request( management_group_id=management_group_id, @@ -299,7 +333,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -307,10 +342,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -318,51 +352,44 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - management_group_id: str, - name: str, - **kwargs: Any + self, management_group_id: str, name: str, **kwargs: Any ) -> None: """Deletes existing management group diagnostic settings for the specified resource. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( management_group_id=management_group_id, name=name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -370,10 +397,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -384,43 +410,39 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore - + delete.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace def list( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable[_models.ManagementGroupDiagnosticSettingsResourceCollection]: + self, management_group_id: str, **kwargs: Any + ) -> Iterable["_models.ManagementGroupDiagnosticSettingsResource"]: """Gets the active management group diagnostic settings list for the specified management group. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - ManagementGroupDiagnosticSettingsResourceCollection or the result of cls(response) + :return: An iterator like instance of either ManagementGroupDiagnosticSettingsResource or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -428,14 +450,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - management_group_id=management_group_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -451,10 +470,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -465,8 +482,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py index ae668e8ace76..e6cba4ff262e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. 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: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-05-01-preview") # type: str + api_version = kwargs.pop("api_version", "2020-05-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json index 7709ce6d006e..e7e8fcaa5297 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py index 07abd9fb7f66..8147bee343a0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ScheduledQueryRulesOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations :vartype scheduled_query_rules: $(python-base-namespace).v2020_05_01_preview.operations.ScheduledQueryRulesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -46,7 +46,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -57,12 +59,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -71,7 +68,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py index e33b0619cb1c..0431945b030f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-05-01-preview") # type: str + api_version = kwargs.pop("api_version", "2020-05-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py index 3a7bde119e46..07701fad49a3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ScheduledQueryRulesOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations :vartype scheduled_query_rules: $(python-base-namespace).v2020_05_01_preview.aio.operations.ScheduledQueryRulesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -46,7 +46,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -57,12 +59,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -71,7 +68,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/__init__.py index a33ab10efeb3..40cd07056c01 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ScheduledQueryRulesOperations', + "ScheduledQueryRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py index 35237519b83d..1ff23db940c6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._scheduled_query_rules_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._scheduled_query_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ScheduledQueryRulesOperations: """ .. warning:: @@ -43,38 +59,33 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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, - **kwargs: Any - ) -> AsyncIterable[_models.ScheduledQueryRuleResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ScheduledQueryRuleResource"]: """Retrieve a scheduled query rule definitions in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScheduledQueryRuleResourceCollection or the result - of cls(response) + :return: An iterator like instance of either ScheduledQueryRuleResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -82,14 +93,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -105,10 +113,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -119,47 +125,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ScheduledQueryRuleResourceCollection]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ScheduledQueryRuleResource"]: """Retrieve scheduled query rule definitions in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ScheduledQueryRuleResourceCollection or the result - of cls(response) + :return: An iterator like instance of either ScheduledQueryRuleResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -167,15 +169,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -191,10 +189,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -205,48 +201,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: + async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.ScheduledQueryRuleResource: """Retrieve an scheduled query rule definition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource, or the result of cls(response) + :return: ScheduledQueryRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -254,10 +241,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -265,60 +251,126 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScheduledQueryRuleResource', pipeline_response) + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, rule_name: str, parameters: _models.ScheduledQueryRuleResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ScheduledQueryRuleResource: """Creates or updates a scheduled query rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. + :param parameters: The parameters of the rule to create or update. Required. :type parameters: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Creates or updates a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. 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: ScheduledQueryRuleResource, or the result of cls(response) + :return: ScheduledQueryRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.ScheduledQueryRuleResource, IO], + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Creates or updates a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a model type or a + IO type. Required. + :type parameters: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResource] - _json = self._serialize.body(parameters, 'ScheduledQueryRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScheduledQueryRuleResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -326,10 +378,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -338,63 +389,129 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScheduledQueryRuleResource', pipeline_response) + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScheduledQueryRuleResource', pipeline_response) + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, rule_name: str, parameters: _models.ScheduledQueryRuleResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ScheduledQueryRuleResource: """Update a scheduled query rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to update. + :param parameters: The parameters of the rule to update. Required. :type parameters: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Update a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. 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: ScheduledQueryRuleResource, or the result of cls(response) + :return: ScheduledQueryRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.ScheduledQueryRuleResourcePatch, IO], + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Update a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResource] - _json = self._serialize.body(parameters, 'ScheduledQueryRuleResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScheduledQueryRuleResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -402,10 +519,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -413,52 +529,46 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScheduledQueryRuleResource', pipeline_response) + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, **kwargs: Any ) -> None: """Deletes a scheduled query rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -466,10 +576,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -480,5 +589,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py index 711c3a649649..2cae1c6fc22b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py @@ -20,34 +20,32 @@ from ._models_py3 import ScheduledQueryRuleResourcePatch from ._models_py3 import TrackedResource - -from ._monitor_management_client_enums import ( - AlertSeverity, - ConditionOperator, - DimensionOperator, - TimeAggregation, -) +from ._monitor_management_client_enums import AlertSeverity +from ._monitor_management_client_enums import ConditionOperator +from ._monitor_management_client_enums import DimensionOperator +from ._monitor_management_client_enums import TimeAggregation from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Action', - 'Condition', - 'ConditionFailingPeriods', - 'Dimension', - 'ErrorAdditionalInfo', - 'ErrorContract', - 'ErrorResponse', - 'Resource', - 'ScheduledQueryRuleCriteria', - 'ScheduledQueryRuleResource', - 'ScheduledQueryRuleResourceCollection', - 'ScheduledQueryRuleResourcePatch', - 'TrackedResource', - 'AlertSeverity', - 'ConditionOperator', - 'DimensionOperator', - 'TimeAggregation', + "Action", + "Condition", + "ConditionFailingPeriods", + "Dimension", + "ErrorAdditionalInfo", + "ErrorContract", + "ErrorResponse", + "Resource", + "ScheduledQueryRuleCriteria", + "ScheduledQueryRuleResource", + "ScheduledQueryRuleResourceCollection", + "ScheduledQueryRuleResourcePatch", + "TrackedResource", + "AlertSeverity", + "ConditionOperator", + "DimensionOperator", + "TimeAggregation", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py index bd48ab2b1fd0..e2dc856d2c62 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/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. @@ -9,15 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Actions to invoke when the alert fires. :ivar action_group_id: Action Group resource Id to invoke when the alert fires. @@ -27,16 +27,12 @@ class Action(msrest.serialization.Model): """ _attribute_map = { - 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, - 'web_hook_properties': {'key': 'webHookProperties', 'type': '{str}'}, + "action_group_id": {"key": "actionGroupId", "type": "str"}, + "web_hook_properties": {"key": "webHookProperties", "type": "{str}"}, } def __init__( - self, - *, - action_group_id: Optional[str] = None, - web_hook_properties: Optional[Dict[str, str]] = None, - **kwargs + self, *, action_group_id: Optional[str] = None, web_hook_properties: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword action_group_id: Action Group resource Id to invoke when the alert fires. @@ -44,20 +40,20 @@ def __init__( :keyword web_hook_properties: The properties of a webhook object. :paramtype web_hook_properties: dict[str, str] """ - super(Action, self).__init__(**kwargs) + super().__init__(**kwargs) self.action_group_id = action_group_id self.web_hook_properties = web_hook_properties -class Condition(msrest.serialization.Model): +class Condition(_serialization.Model): """A condition of the scheduled query rule. All required parameters must be populated in order to send to Azure. :ivar query: Log query alert. :vartype query: str - :ivar time_aggregation: Required. Aggregation type. Known values are: "Count", "Average", - "Minimum", "Maximum", "Total". + :ivar time_aggregation: Aggregation type. Required. Known values are: "Count", "Average", + "Minimum", "Maximum", and "Total". :vartype time_aggregation: str or ~$(python-base-namespace).v2020_05_01_preview.models.TimeAggregation :ivar metric_measure_column: The column containing the metric measure number. @@ -67,11 +63,11 @@ class Condition(msrest.serialization.Model): :vartype resource_id_column: str :ivar dimensions: List of Dimensions conditions. :vartype dimensions: list[~$(python-base-namespace).v2020_05_01_preview.models.Dimension] - :ivar operator: Required. The criteria operator. Known values are: "Equals", "GreaterThan", - "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :ivar operator: The criteria operator. Required. Known values are: "Equals", "GreaterThan", + "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2020_05_01_preview.models.ConditionOperator - :ivar threshold: Required. the criteria threshold value that activates the alert. + :ivar threshold: the criteria threshold value that activates the alert. Required. :vartype threshold: float :ivar failing_periods: The minimum number of violations required within the selected lookback time window required to raise an alert. @@ -80,20 +76,20 @@ class Condition(msrest.serialization.Model): """ _validation = { - 'time_aggregation': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, + "time_aggregation": {"required": True}, + "operator": {"required": True}, + "threshold": {"required": True}, } _attribute_map = { - 'query': {'key': 'query', 'type': 'str'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - 'metric_measure_column': {'key': 'metricMeasureColumn', 'type': 'str'}, - 'resource_id_column': {'key': 'resourceIdColumn', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'failing_periods': {'key': 'failingPeriods', 'type': 'ConditionFailingPeriods'}, + "query": {"key": "query", "type": "str"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, + "metric_measure_column": {"key": "metricMeasureColumn", "type": "str"}, + "resource_id_column": {"key": "resourceIdColumn", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "failing_periods": {"key": "failingPeriods", "type": "ConditionFailingPeriods"}, } def __init__( @@ -112,8 +108,8 @@ def __init__( """ :keyword query: Log query alert. :paramtype query: str - :keyword time_aggregation: Required. Aggregation type. Known values are: "Count", "Average", - "Minimum", "Maximum", "Total". + :keyword time_aggregation: Aggregation type. Required. Known values are: "Count", "Average", + "Minimum", "Maximum", and "Total". :paramtype time_aggregation: str or ~$(python-base-namespace).v2020_05_01_preview.models.TimeAggregation :keyword metric_measure_column: The column containing the metric measure number. @@ -123,18 +119,18 @@ def __init__( :paramtype resource_id_column: str :keyword dimensions: List of Dimensions conditions. :paramtype dimensions: list[~$(python-base-namespace).v2020_05_01_preview.models.Dimension] - :keyword operator: Required. The criteria operator. Known values are: "Equals", "GreaterThan", - "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :keyword operator: The criteria operator. Required. Known values are: "Equals", "GreaterThan", + "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2020_05_01_preview.models.ConditionOperator - :keyword threshold: Required. the criteria threshold value that activates the alert. + :keyword threshold: the criteria threshold value that activates the alert. Required. :paramtype threshold: float :keyword failing_periods: The minimum number of violations required within the selected lookback time window required to raise an alert. :paramtype failing_periods: ~$(python-base-namespace).v2020_05_01_preview.models.ConditionFailingPeriods """ - super(Condition, self).__init__(**kwargs) + super().__init__(**kwargs) self.query = query self.time_aggregation = time_aggregation self.metric_measure_column = metric_measure_column @@ -145,96 +141,83 @@ def __init__( self.failing_periods = failing_periods -class ConditionFailingPeriods(msrest.serialization.Model): +class ConditionFailingPeriods(_serialization.Model): """The minimum number of violations required within the selected lookback time window required to raise an alert. :ivar number_of_evaluation_periods: The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. Default value is 1. - :vartype number_of_evaluation_periods: long + :vartype number_of_evaluation_periods: int :ivar min_failing_periods_to_alert: The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. Default value is 1. - :vartype min_failing_periods_to_alert: long + :vartype min_failing_periods_to_alert: int """ _attribute_map = { - 'number_of_evaluation_periods': {'key': 'numberOfEvaluationPeriods', 'type': 'long'}, - 'min_failing_periods_to_alert': {'key': 'minFailingPeriodsToAlert', 'type': 'long'}, + "number_of_evaluation_periods": {"key": "numberOfEvaluationPeriods", "type": "int"}, + "min_failing_periods_to_alert": {"key": "minFailingPeriodsToAlert", "type": "int"}, } - def __init__( - self, - *, - number_of_evaluation_periods: Optional[int] = 1, - min_failing_periods_to_alert: Optional[int] = 1, - **kwargs - ): + def __init__(self, *, number_of_evaluation_periods: int = 1, min_failing_periods_to_alert: int = 1, **kwargs): """ :keyword number_of_evaluation_periods: The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. Default value is 1. - :paramtype number_of_evaluation_periods: long + :paramtype number_of_evaluation_periods: int :keyword min_failing_periods_to_alert: The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. Default value is 1. - :paramtype min_failing_periods_to_alert: long + :paramtype min_failing_periods_to_alert: int """ - super(ConditionFailingPeriods, self).__init__(**kwargs) + super().__init__(**kwargs) self.number_of_evaluation_periods = number_of_evaluation_periods self.min_failing_periods_to_alert = min_failing_periods_to_alert -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension splitting and filtering definition. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the dimension. + :ivar name: Name of the dimension. Required. :vartype name: str - :ivar operator: Required. Operator for dimension values. Known values are: "Include", + :ivar operator: Operator for dimension values. Required. Known values are: "Include" and "Exclude". :vartype operator: str or ~$(python-base-namespace).v2020_05_01_preview.models.DimensionOperator - :ivar values: Required. List of dimension values. + :ivar values: List of dimension values. Required. :vartype values: list[str] """ _validation = { - 'name': {'required': True}, - 'operator': {'required': True}, - 'values': {'required': True}, + "name": {"required": True}, + "operator": {"required": True}, + "values": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "operator": {"key": "operator", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, } - def __init__( - self, - *, - name: str, - operator: Union[str, "_models.DimensionOperator"], - values: List[str], - **kwargs - ): + def __init__(self, *, name: str, operator: Union[str, "_models.DimensionOperator"], values: List[str], **kwargs): """ - :keyword name: Required. Name of the dimension. + :keyword name: Name of the dimension. Required. :paramtype name: str - :keyword operator: Required. Operator for dimension values. Known values are: "Include", + :keyword operator: Operator for dimension values. Required. Known values are: "Include" and "Exclude". :paramtype operator: str or ~$(python-base-namespace).v2020_05_01_preview.models.DimensionOperator - :keyword values: Required. List of dimension values. + :keyword values: List of dimension values. Required. :paramtype values: list[str] """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.operator = operator self.values = values -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -242,31 +225,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorContract(msrest.serialization.Model): +class ErrorContract(_serialization.Model): """Describes the format of Error response. :ivar error: The error details. @@ -274,24 +253,19 @@ class ErrorContract(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponse"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): """ :keyword error: The error details. :paramtype error: ~$(python-base-namespace).v2020_05_01_preview.models.ErrorResponse """ - super(ErrorContract, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -310,28 +284,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -339,7 +309,7 @@ def __init__( self.additional_info = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -355,30 +325,26 @@ class Resource(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(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None -class ScheduledQueryRuleCriteria(msrest.serialization.Model): +class ScheduledQueryRuleCriteria(_serialization.Model): """The rule criteria that defines the conditions of the scheduled query rule. :ivar all_of: A list of conditions to evaluate against the specified scopes. @@ -386,20 +352,15 @@ class ScheduledQueryRuleCriteria(msrest.serialization.Model): """ _attribute_map = { - 'all_of': {'key': 'allOf', 'type': '[Condition]'}, + "all_of": {"key": "allOf", "type": "[Condition]"}, } - def __init__( - self, - *, - all_of: Optional[List["_models.Condition"]] = None, - **kwargs - ): + def __init__(self, *, all_of: Optional[List["_models.Condition"]] = None, **kwargs): """ :keyword all_of: A list of conditions to evaluate against the specified scopes. :paramtype all_of: list[~$(python-base-namespace).v2020_05_01_preview.models.Condition] """ - super(ScheduledQueryRuleCriteria, self).__init__(**kwargs) + super().__init__(**kwargs) self.all_of = all_of @@ -418,46 +379,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class ScheduledQueryRuleResource(TrackedResource): +class ScheduledQueryRuleResource(TrackedResource): # pylint: disable=too-many-instance-attributes """The scheduled query rule resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -472,9 +427,9 @@ class ScheduledQueryRuleResource(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, @@ -495,7 +450,7 @@ class ScheduledQueryRuleResource(TrackedResource): :ivar display_name: The display name of the alert rule. :vartype display_name: str :ivar severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is - severest. Known values are: 0, 1, 2, 3, 4. + severest. Known values are: 0, 1, 2, 3, and 4. :vartype severity: float or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value should be true or false. @@ -527,38 +482,38 @@ class ScheduledQueryRuleResource(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'etag': {'readonly': True}, - 'created_with_api_version': {'readonly': True}, - 'is_legacy_log_analytics_rule': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "kind": {"readonly": True}, + "etag": {"readonly": True}, + "created_with_api_version": {"readonly": True}, + "is_legacy_log_analytics_rule": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'created_with_api_version': {'key': 'properties.createdWithApiVersion', 'type': 'str'}, - 'is_legacy_log_analytics_rule': {'key': 'properties.isLegacyLogAnalyticsRule', 'type': 'bool'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'float'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'evaluation_frequency': {'key': 'properties.evaluationFrequency', 'type': 'duration'}, - 'window_size': {'key': 'properties.windowSize', 'type': 'duration'}, - 'override_query_time_range': {'key': 'properties.overrideQueryTimeRange', 'type': 'duration'}, - 'target_resource_types': {'key': 'properties.targetResourceTypes', 'type': '[str]'}, - 'criteria': {'key': 'properties.criteria', 'type': 'ScheduledQueryRuleCriteria'}, - 'mute_actions_duration': {'key': 'properties.muteActionsDuration', 'type': 'duration'}, - 'actions': {'key': 'properties.actions', 'type': '[Action]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "created_with_api_version": {"key": "properties.createdWithApiVersion", "type": "str"}, + "is_legacy_log_analytics_rule": {"key": "properties.isLegacyLogAnalyticsRule", "type": "bool"}, + "description": {"key": "properties.description", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "severity": {"key": "properties.severity", "type": "float"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "scopes": {"key": "properties.scopes", "type": "[str]"}, + "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, + "window_size": {"key": "properties.windowSize", "type": "duration"}, + "override_query_time_range": {"key": "properties.overrideQueryTimeRange", "type": "duration"}, + "target_resource_types": {"key": "properties.targetResourceTypes", "type": "[str]"}, + "criteria": {"key": "properties.criteria", "type": "ScheduledQueryRuleCriteria"}, + "mute_actions_duration": {"key": "properties.muteActionsDuration", "type": "duration"}, + "actions": {"key": "properties.actions", "type": "[Action]"}, } def __init__( @@ -581,16 +536,16 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword description: The description of the scheduled query rule. :paramtype description: str :keyword display_name: The display name of the alert rule. :paramtype display_name: str :keyword severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is - severest. Known values are: 0, 1, 2, 3, 4. + severest. Known values are: 0, 1, 2, 3, and 4. :paramtype severity: float or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value @@ -621,7 +576,7 @@ def __init__( :keyword actions: :paramtype actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] """ - super(ScheduledQueryRuleResource, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.kind = None self.etag = None self.created_with_api_version = None @@ -640,7 +595,7 @@ def __init__( self.actions = actions -class ScheduledQueryRuleResourceCollection(msrest.serialization.Model): +class ScheduledQueryRuleResourceCollection(_serialization.Model): """Represents a collection of scheduled query rule resources. :ivar value: The values for the scheduled query rule resources. @@ -649,30 +604,25 @@ class ScheduledQueryRuleResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ScheduledQueryRuleResource]'}, + "value": {"key": "value", "type": "[ScheduledQueryRuleResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ScheduledQueryRuleResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ScheduledQueryRuleResource"]] = None, **kwargs): """ :keyword value: The values for the scheduled query rule resources. :paramtype value: list[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource] """ - super(ScheduledQueryRuleResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ScheduledQueryRuleResourcePatch(msrest.serialization.Model): +class ScheduledQueryRuleResourcePatch(_serialization.Model): # pylint: disable=too-many-instance-attributes """The scheduled query rule resource for patch operations. Variables are only populated by the server, and will be ignored when sending a request. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar created_with_api_version: The api-version used when creating this alert rule. :vartype created_with_api_version: str @@ -683,7 +633,7 @@ class ScheduledQueryRuleResourcePatch(msrest.serialization.Model): :ivar display_name: The display name of the alert rule. :vartype display_name: str :ivar severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is - severest. Known values are: 0, 1, 2, 3, 4. + severest. Known values are: 0, 1, 2, 3, and 4. :vartype severity: float or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value should be true or false. @@ -715,26 +665,26 @@ class ScheduledQueryRuleResourcePatch(msrest.serialization.Model): """ _validation = { - 'created_with_api_version': {'readonly': True}, - 'is_legacy_log_analytics_rule': {'readonly': True}, + "created_with_api_version": {"readonly": True}, + "is_legacy_log_analytics_rule": {"readonly": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'created_with_api_version': {'key': 'properties.createdWithApiVersion', 'type': 'str'}, - 'is_legacy_log_analytics_rule': {'key': 'properties.isLegacyLogAnalyticsRule', 'type': 'bool'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'float'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'evaluation_frequency': {'key': 'properties.evaluationFrequency', 'type': 'duration'}, - 'window_size': {'key': 'properties.windowSize', 'type': 'duration'}, - 'override_query_time_range': {'key': 'properties.overrideQueryTimeRange', 'type': 'duration'}, - 'target_resource_types': {'key': 'properties.targetResourceTypes', 'type': '[str]'}, - 'criteria': {'key': 'properties.criteria', 'type': 'ScheduledQueryRuleCriteria'}, - 'mute_actions_duration': {'key': 'properties.muteActionsDuration', 'type': 'duration'}, - 'actions': {'key': 'properties.actions', 'type': '[Action]'}, + "tags": {"key": "tags", "type": "{str}"}, + "created_with_api_version": {"key": "properties.createdWithApiVersion", "type": "str"}, + "is_legacy_log_analytics_rule": {"key": "properties.isLegacyLogAnalyticsRule", "type": "bool"}, + "description": {"key": "properties.description", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "severity": {"key": "properties.severity", "type": "float"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "scopes": {"key": "properties.scopes", "type": "[str]"}, + "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, + "window_size": {"key": "properties.windowSize", "type": "duration"}, + "override_query_time_range": {"key": "properties.overrideQueryTimeRange", "type": "duration"}, + "target_resource_types": {"key": "properties.targetResourceTypes", "type": "[str]"}, + "criteria": {"key": "properties.criteria", "type": "ScheduledQueryRuleCriteria"}, + "mute_actions_duration": {"key": "properties.muteActionsDuration", "type": "duration"}, + "actions": {"key": "properties.actions", "type": "[Action]"}, } def __init__( @@ -756,14 +706,14 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword description: The description of the scheduled query rule. :paramtype description: str :keyword display_name: The display name of the alert rule. :paramtype display_name: str :keyword severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is - severest. Known values are: 0, 1, 2, 3, 4. + severest. Known values are: 0, 1, 2, 3, and 4. :paramtype severity: float or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value @@ -794,7 +744,7 @@ def __init__( :keyword actions: :paramtype actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] """ - super(ScheduledQueryRuleResourcePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.created_with_api_version = None self.is_legacy_log_analytics_rule = None diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py index 8264f06f67a2..745c9374e7d6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py @@ -11,8 +11,7 @@ class AlertSeverity(float, Enum, metaclass=CaseInsensitiveEnumMeta): - """Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest - """ + """Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest.""" ZERO = 0 ONE = 1 @@ -20,9 +19,9 @@ class AlertSeverity(float, Enum, metaclass=CaseInsensitiveEnumMeta): THREE = 3 FOUR = 4 + class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The criteria operator. - """ + """The criteria operator.""" EQUALS = "Equals" GREATER_THAN = "GreaterThan" @@ -30,16 +29,16 @@ class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + class DimensionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operator for dimension values - """ + """Operator for dimension values.""" INCLUDE = "Include" EXCLUDE = "Exclude" + class TimeAggregation(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Aggregation type - """ + """Aggregation type.""" COUNT = "Count" AVERAGE = "Average" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/__init__.py index a33ab10efeb3..40cd07056c01 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ScheduledQueryRulesOperations', + "ScheduledQueryRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py index ad90b52bc0e4..5d5c2a4863bd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +25,203 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( - subscription_id: str, - resource_group_name: str, - rule_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - rule_name: str, - *, - json: Optional[_models.ScheduledQueryRuleResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_update_request( - subscription_id: str, - resource_group_name: str, - rule_name: str, - *, - json: Optional[_models.ScheduledQueryRuleResourcePatch] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_delete_request( - subscription_id: str, - resource_group_name: str, - rule_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_delete_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + class ScheduledQueryRulesOperations: """ @@ -277,38 +242,33 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - **kwargs: Any - ) -> Iterable[_models.ScheduledQueryRuleResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ScheduledQueryRuleResource"]: """Retrieve a scheduled query rule definitions in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScheduledQueryRuleResourceCollection or the result - of cls(response) + :return: An iterator like instance of either ScheduledQueryRuleResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -316,14 +276,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -339,10 +296,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -353,47 +308,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.ScheduledQueryRuleResourceCollection]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ScheduledQueryRuleResource"]: """Retrieve scheduled query rule definitions in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ScheduledQueryRuleResourceCollection or the result - of cls(response) + :return: An iterator like instance of either ScheduledQueryRuleResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -401,15 +352,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -425,10 +372,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -439,48 +384,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: + def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.ScheduledQueryRuleResource: """Retrieve an scheduled query rule definition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource, or the result of cls(response) + :return: ScheduledQueryRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -488,10 +424,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -499,60 +434,126 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScheduledQueryRuleResource', pipeline_response) + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, rule_name: str, parameters: _models.ScheduledQueryRuleResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ScheduledQueryRuleResource: """Creates or updates a scheduled query rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. + :param parameters: The parameters of the rule to create or update. Required. :type parameters: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ScheduledQueryRuleResource, or the result of cls(response) + :return: ScheduledQueryRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Creates or updates a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. 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: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.ScheduledQueryRuleResource, IO], + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Creates or updates a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a model type or a + IO type. Required. + :type parameters: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResource] - _json = self._serialize.body(parameters, 'ScheduledQueryRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScheduledQueryRuleResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -560,10 +561,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -572,63 +572,129 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScheduledQueryRuleResource', pipeline_response) + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScheduledQueryRuleResource', pipeline_response) + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, rule_name: str, parameters: _models.ScheduledQueryRuleResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ScheduledQueryRuleResource: """Update a scheduled query rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to update. + :param parameters: The parameters of the rule to update. Required. :type parameters: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Update a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. 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: ScheduledQueryRuleResource, or the result of cls(response) + :return: ScheduledQueryRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.ScheduledQueryRuleResourcePatch, IO], + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Update a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResource] - _json = self._serialize.body(parameters, 'ScheduledQueryRuleResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScheduledQueryRuleResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -636,10 +702,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -647,52 +712,46 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScheduledQueryRuleResource', pipeline_response) + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - rule_name: str, - **kwargs: Any + self, resource_group_name: str, rule_name: str, **kwargs: Any ) -> None: """Deletes a scheduled query rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param rule_name: The name of the rule. + :param rule_name: The name of the rule. Required. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -700,10 +759,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -714,5 +772,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py index 22f6bfab9772..b26fd7e5ea92 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", "2020-10-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json index 84588921906b..95a4e46d1b8a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py index cc2fe0d25248..83b34dd8a854 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActivityLogAlertsOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar activity_log_alerts: ActivityLogAlertsOperations operations :vartype activity_log_alerts: $(python-base-namespace).v2020_10_01.operations.ActivityLogAlertsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -46,7 +46,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -57,12 +59,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -71,7 +68,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py index 55911295e09b..b677dfda241d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-10-01") # type: str + api_version = kwargs.pop("api_version", "2020-10-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py index 57f9823ba9b7..74f37766599e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActivityLogAlertsOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar activity_log_alerts: ActivityLogAlertsOperations operations :vartype activity_log_alerts: $(python-base-namespace).v2020_10_01.aio.operations.ActivityLogAlertsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -46,7 +46,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -57,12 +59,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -71,7 +68,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/__init__.py index 26aff77830bf..605798ce7feb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActivityLogAlertsOperations', + "ActivityLogAlertsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py index f4a6f22e218f..7b86e3354d85 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._activity_log_alerts_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_request -T = TypeVar('T') +from ...operations._activity_log_alerts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ActivityLogAlertsOperations: """ .. warning:: @@ -43,51 +59,119 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, activity_log_alert_name: str, activity_log_alert_rule: _models.ActivityLogAlertResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActivityLogAlertResource: """Create a new Activity Log Alert rule or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. :type activity_log_alert_name: str :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. + Required. :type activity_log_alert_rule: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_rule: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new Activity Log Alert rule or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. + :type activity_log_alert_name: str + :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. + Required. + :type activity_log_alert_rule: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_rule: Union[_models.ActivityLogAlertResource, IO], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new Activity Log Alert rule or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. + :type activity_log_alert_name: str + :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. Is + either a model type or a IO type. Required. + :type activity_log_alert_rule: + ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - _json = self._serialize.body(activity_log_alert_rule, 'ActivityLogAlertResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert_rule, (IO, bytes)): + _content = activity_log_alert_rule + else: + _json = self._serialize.body(activity_log_alert_rule, "ActivityLogAlertResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -95,10 +179,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -107,55 +190,49 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any ) -> _models.ActivityLogAlertResource: """Get an Activity Log Alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. :type activity_log_alert_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -163,10 +240,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -174,52 +250,46 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any ) -> None: """Delete an Activity Log Alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. :type activity_log_alert_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -227,10 +297,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -241,15 +310,16 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, activity_log_alert_name: str, activity_log_alert_rule_patch: _models.AlertRulePatchObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActivityLogAlertResource: """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update @@ -257,39 +327,108 @@ async def update( CreateOrUpdate operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. :type activity_log_alert_name: str - :param activity_log_alert_rule_patch: Parameters supplied to the operation. + :param activity_log_alert_rule_patch: Parameters supplied to the operation. Required. :type activity_log_alert_rule_patch: ~$(python-base-namespace).v2020_10_01.models.AlertRulePatchObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_rule_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update + the Alert rule tags, and to enable or disable the Alert rule. To update other fields use + CreateOrUpdate operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. + :type activity_log_alert_name: str + :param activity_log_alert_rule_patch: Parameters supplied to the operation. Required. + :type activity_log_alert_rule_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_rule_patch: Union[_models.AlertRulePatchObject, IO], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update + the Alert rule tags, and to enable or disable the Alert rule. To update other fields use + CreateOrUpdate operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. + :type activity_log_alert_name: str + :param activity_log_alert_rule_patch: Parameters supplied to the operation. Is either a model + type or a IO type. Required. + :type activity_log_alert_rule_patch: + ~$(python-base-namespace).v2020_10_01.models.AlertRulePatchObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - _json = self._serialize.body(activity_log_alert_rule_patch, 'AlertRulePatchObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert_rule_patch, (IO, bytes)): + _content = activity_log_alert_rule_patch + else: + _json = self._serialize.body(activity_log_alert_rule_patch, "AlertRulePatchObject") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -297,10 +436,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -308,46 +446,42 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> AsyncIterable[_models.AlertRuleList]: + def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActivityLogAlertResource"]: """Get a list of all Activity Log Alert rules in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleList or the result of cls(response) + :return: An iterator like instance of either ActivityLogAlertResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -355,14 +489,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -378,10 +509,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -392,46 +521,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.AlertRuleList]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ActivityLogAlertResource"]: """Get a list of all Activity Log Alert rules in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 AlertRuleList or the result of cls(response) + :return: An iterator like instance of either ActivityLogAlertResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -439,15 +565,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -463,10 +585,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -477,8 +597,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py index a1e8a4c73d50..6f14c5c24a84 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py @@ -16,21 +16,21 @@ from ._models_py3 import AlertRulePatchObject from ._models_py3 import AzureResource from ._models_py3 import ErrorResponse - from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroup', - 'ActionList', - 'ActivityLogAlertResource', - 'AlertRuleAllOfCondition', - 'AlertRuleAnyOfOrLeafCondition', - 'AlertRuleLeafCondition', - 'AlertRuleList', - 'AlertRulePatchObject', - 'AzureResource', - 'ErrorResponse', + "ActionGroup", + "ActionList", + "ActivityLogAlertResource", + "AlertRuleAllOfCondition", + "AlertRuleAnyOfOrLeafCondition", + "AlertRuleLeafCondition", + "AlertRuleList", + "AlertRulePatchObject", + "AzureResource", + "ErrorResponse", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py index f59200eb3161..ef4dee4fd3f8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_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. @@ -8,21 +9,20 @@ from typing import Dict, List, Optional, TYPE_CHECKING -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class ActionGroup(msrest.serialization.Model): +class ActionGroup(_serialization.Model): """A pointer to an Azure Action Group. All required parameters must be populated in order to send to Azure. - :ivar action_group_id: Required. The resource ID of the Action Group. This cannot be null or - empty. + :ivar action_group_id: The resource ID of the Action Group. This cannot be null or empty. + Required. :vartype action_group_id: str :ivar webhook_properties: the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. @@ -30,35 +30,29 @@ class ActionGroup(msrest.serialization.Model): """ _validation = { - 'action_group_id': {'required': True}, + "action_group_id": {"required": True}, } _attribute_map = { - 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, - 'webhook_properties': {'key': 'webhookProperties', 'type': '{str}'}, + "action_group_id": {"key": "actionGroupId", "type": "str"}, + "webhook_properties": {"key": "webhookProperties", "type": "{str}"}, } - def __init__( - self, - *, - action_group_id: str, - webhook_properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, action_group_id: str, webhook_properties: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword action_group_id: Required. The resource ID of the Action Group. This cannot be null or - empty. + :keyword action_group_id: The resource ID of the Action Group. This cannot be null or empty. + Required. :paramtype action_group_id: str :keyword webhook_properties: the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. :paramtype webhook_properties: dict[str, str] """ - super(ActionGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.action_group_id = action_group_id self.webhook_properties = webhook_properties -class ActionList(msrest.serialization.Model): +class ActionList(_serialization.Model): """A list of Activity Log Alert rule actions. :ivar action_groups: The list of the Action Groups. @@ -66,24 +60,19 @@ class ActionList(msrest.serialization.Model): """ _attribute_map = { - 'action_groups': {'key': 'actionGroups', 'type': '[ActionGroup]'}, + "action_groups": {"key": "actionGroups", "type": "[ActionGroup]"}, } - def __init__( - self, - *, - action_groups: Optional[List["_models.ActionGroup"]] = None, - **kwargs - ): + def __init__(self, *, action_groups: Optional[List["_models.ActionGroup"]] = None, **kwargs): """ :keyword action_groups: The list of the Action Groups. :paramtype action_groups: list[~$(python-base-namespace).v2020_10_01.models.ActionGroup] """ - super(ActionList, self).__init__(**kwargs) + super().__init__(**kwargs) self.action_groups = action_groups -class AzureResource(msrest.serialization.Model): +class AzureResource(_serialization.Model): """An Azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -97,39 +86,33 @@ class AzureResource(msrest.serialization.Model): :ivar location: The location of the resource. Since Azure Activity Log Alerts is a global service, the location of the rules should always be 'global'. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] """ _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = "global", - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str = "global", tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: The location of the resource. Since Azure Activity Log Alerts is a global service, the location of the rules should always be 'global'. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] """ - super(AzureResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -151,7 +134,7 @@ class ActivityLogAlertResource(AzureResource): :ivar location: The location of the resource. Since Azure Activity Log Alerts is a global service, the location of the rules should always be 'global'. :vartype location: str - :ivar tags: A set of tags. The tags of the resource. + :ivar tags: The tags of the resource. :vartype tags: dict[str, str] :ivar scopes: A list of resource IDs that will be used as prefixes. The alert will only apply to Activity Log events with resource IDs that fall under one of these prefixes. This list must @@ -169,33 +152,33 @@ class ActivityLogAlertResource(AzureResource): """ _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'condition': {'key': 'properties.condition', 'type': 'AlertRuleAllOfCondition'}, - 'actions': {'key': 'properties.actions', 'type': 'ActionList'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'description': {'key': 'properties.description', 'type': 'str'}, + "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}"}, + "scopes": {"key": "properties.scopes", "type": "[str]"}, + "condition": {"key": "properties.condition", "type": "AlertRuleAllOfCondition"}, + "actions": {"key": "properties.actions", "type": "ActionList"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "description": {"key": "properties.description", "type": "str"}, } def __init__( self, *, - location: Optional[str] = "global", + location: str = "global", tags: Optional[Dict[str, str]] = None, scopes: Optional[List[str]] = None, condition: Optional["_models.AlertRuleAllOfCondition"] = None, actions: Optional["_models.ActionList"] = None, - enabled: Optional[bool] = True, + enabled: bool = True, description: Optional[str] = None, **kwargs ): @@ -203,7 +186,7 @@ def __init__( :keyword location: The location of the resource. Since Azure Activity Log Alerts is a global service, the location of the rules should always be 'global'. :paramtype location: str - :keyword tags: A set of tags. The tags of the resource. + :keyword tags: The tags of the resource. :paramtype tags: dict[str, str] :keyword scopes: A list of resource IDs that will be used as prefixes. The alert will only apply to Activity Log events with resource IDs that fall under one of these prefixes. This list @@ -219,7 +202,7 @@ def __init__( :keyword description: A description of this Activity Log Alert rule. :paramtype description: str """ - super(ActivityLogAlertResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.scopes = scopes self.condition = condition self.actions = actions @@ -227,60 +210,55 @@ def __init__( self.description = description -class AlertRuleAllOfCondition(msrest.serialization.Model): +class AlertRuleAllOfCondition(_serialization.Model): """An Activity Log Alert rule condition that is met when all its member conditions are met. All required parameters must be populated in order to send to Azure. - :ivar all_of: Required. The list of Activity Log Alert rule conditions. + :ivar all_of: The list of Activity Log Alert rule conditions. Required. :vartype all_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleAnyOfOrLeafCondition] """ _validation = { - 'all_of': {'required': True}, + "all_of": {"required": True}, } _attribute_map = { - 'all_of': {'key': 'allOf', 'type': '[AlertRuleAnyOfOrLeafCondition]'}, + "all_of": {"key": "allOf", "type": "[AlertRuleAnyOfOrLeafCondition]"}, } - def __init__( - self, - *, - all_of: List["_models.AlertRuleAnyOfOrLeafCondition"], - **kwargs - ): + def __init__(self, *, all_of: List["_models.AlertRuleAnyOfOrLeafCondition"], **kwargs): """ - :keyword all_of: Required. The list of Activity Log Alert rule conditions. + :keyword all_of: The list of Activity Log Alert rule conditions. Required. :paramtype all_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleAnyOfOrLeafCondition] """ - super(AlertRuleAllOfCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.all_of = all_of -class AlertRuleLeafCondition(msrest.serialization.Model): +class AlertRuleLeafCondition(_serialization.Model): """An Activity Log Alert rule condition that is met by comparing the field and value of an Activity Log event. -This condition must contain 'field' and either 'equals' or 'containsAny'. - - :ivar field: The name of the Activity Log event's field that this condition will examine. - The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', - 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', - 'resourceType', or anything beginning with 'properties'. - :vartype field: str - :ivar equals: The value of the event's field will be compared to this value (case-insensitive) - to determine if the condition is met. - :vartype equals: str - :ivar contains_any: The value of the event's field will be compared to the values in this array - (case-insensitive) to determine if the condition is met. - :vartype contains_any: list[str] + This condition must contain 'field' and either 'equals' or 'containsAny'. + + :ivar field: The name of the Activity Log event's field that this condition will examine. + The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', + 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', + 'resourceType', or anything beginning with 'properties'. + :vartype field: str + :ivar equals: The value of the event's field will be compared to this value (case-insensitive) + to determine if the condition is met. + :vartype equals: str + :ivar contains_any: The value of the event's field will be compared to the values in this array + (case-insensitive) to determine if the condition is met. + :vartype contains_any: list[str] """ _attribute_map = { - 'field': {'key': 'field', 'type': 'str'}, - 'equals': {'key': 'equals', 'type': 'str'}, - 'contains_any': {'key': 'containsAny', 'type': '[str]'}, + "field": {"key": "field", "type": "str"}, + "equals": {"key": "equals", "type": "str"}, + "contains_any": {"key": "containsAny", "type": "[str]"}, } def __init__( @@ -304,7 +282,7 @@ def __init__( array (case-insensitive) to determine if the condition is met. :paramtype contains_any: list[str] """ - super(AlertRuleLeafCondition, self).__init__(**kwargs) + super().__init__(**kwargs) self.field = field self.equals = equals self.contains_any = contains_any @@ -312,37 +290,37 @@ def __init__( class AlertRuleAnyOfOrLeafCondition(AlertRuleLeafCondition): """An Activity Log Alert rule condition that is met when all its member conditions are met. -Each condition can be of one of the following types: -**Important**\ : Each type has its unique subset of properties. Properties from different types CANNOT exist in one condition. - - -* **Leaf Condition -** must contain 'field' and either 'equals' or 'containsAny'. - *Please note, 'anyOf' should **not** be set in a Leaf Condition.* - - * **AnyOf Condition -** must contain **only** 'anyOf' (which is an array of Leaf Conditions). - *Please note, 'field', 'equals' and 'containsAny' should **not** be set in an AnyOf Condition.*. - - :ivar field: The name of the Activity Log event's field that this condition will examine. - The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', - 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', - 'resourceType', or anything beginning with 'properties'. - :vartype field: str - :ivar equals: The value of the event's field will be compared to this value (case-insensitive) - to determine if the condition is met. - :vartype equals: str - :ivar contains_any: The value of the event's field will be compared to the values in this array - (case-insensitive) to determine if the condition is met. - :vartype contains_any: list[str] - :ivar any_of: An Activity Log Alert rule condition that is met when at least one of its member - leaf conditions are met. - :vartype any_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] + Each condition can be of one of the following types: + **Important**\ : Each type has its unique subset of properties. Properties from different types CANNOT exist in one condition. + + + * **Leaf Condition -** must contain 'field' and either 'equals' or 'containsAny'. + *Please note, 'anyOf' should **not** be set in a Leaf Condition.* + + * **AnyOf Condition -** must contain **only** 'anyOf' (which is an array of Leaf Conditions). + *Please note, 'field', 'equals' and 'containsAny' should **not** be set in an AnyOf Condition.*. + + :ivar field: The name of the Activity Log event's field that this condition will examine. + The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', + 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', + 'resourceType', or anything beginning with 'properties'. + :vartype field: str + :ivar equals: The value of the event's field will be compared to this value (case-insensitive) + to determine if the condition is met. + :vartype equals: str + :ivar contains_any: The value of the event's field will be compared to the values in this array + (case-insensitive) to determine if the condition is met. + :vartype contains_any: list[str] + :ivar any_of: An Activity Log Alert rule condition that is met when at least one of its member + leaf conditions are met. + :vartype any_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] """ _attribute_map = { - 'field': {'key': 'field', 'type': 'str'}, - 'equals': {'key': 'equals', 'type': 'str'}, - 'contains_any': {'key': 'containsAny', 'type': '[str]'}, - 'any_of': {'key': 'anyOf', 'type': '[AlertRuleLeafCondition]'}, + "field": {"key": "field", "type": "str"}, + "equals": {"key": "equals", "type": "str"}, + "contains_any": {"key": "containsAny", "type": "[str]"}, + "any_of": {"key": "anyOf", "type": "[AlertRuleLeafCondition]"}, } def __init__( @@ -370,11 +348,11 @@ def __init__( member leaf conditions are met. :paramtype any_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] """ - super(AlertRuleAnyOfOrLeafCondition, self).__init__(field=field, equals=equals, contains_any=contains_any, **kwargs) + super().__init__(field=field, equals=equals, contains_any=contains_any, **kwargs) self.any_of = any_of -class AlertRuleList(msrest.serialization.Model): +class AlertRuleList(_serialization.Model): """A list of Activity Log Alert rules. :ivar value: The list of Activity Log Alert rules. @@ -384,8 +362,8 @@ class AlertRuleList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ActivityLogAlertResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ActivityLogAlertResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -401,15 +379,15 @@ def __init__( :keyword next_link: Provides the link to retrieve the next set of elements. :paramtype next_link: str """ - super(AlertRuleList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class AlertRulePatchObject(msrest.serialization.Model): +class AlertRulePatchObject(_serialization.Model): """An Activity Log Alert rule object for the body of patch operations. - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert rule is not enabled, then none of its actions will be activated. @@ -417,30 +395,24 @@ class AlertRulePatchObject(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - enabled: Optional[bool] = True, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): """ - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert rule is not enabled, then none of its actions will be activated. :paramtype enabled: bool """ - super(AlertRulePatchObject, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.enabled = enabled -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """The error response. Variables are only populated by the server, and will be ignored when sending a request. @@ -452,21 +424,17 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py index 26aff77830bf..605798ce7feb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActivityLogAlertsOperations', + "ActivityLogAlertsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py index db7819267d1b..9b4c324e2b23 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +25,207 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - activity_log_alert_name: str, - *, - json: Optional[_models.ActivityLogAlertResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - activity_log_alert_name: str, - *, - json: Optional[_models.AlertRulePatchObject] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_id_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ActivityLogAlertsOperations: """ @@ -277,51 +246,119 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, activity_log_alert_name: str, activity_log_alert_rule: _models.ActivityLogAlertResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActivityLogAlertResource: """Create a new Activity Log Alert rule or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. :type activity_log_alert_name: str :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. + Required. :type activity_log_alert_rule: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_rule: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new Activity Log Alert rule or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. + :type activity_log_alert_name: str + :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. + Required. + :type activity_log_alert_rule: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_rule: Union[_models.ActivityLogAlertResource, IO], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new Activity Log Alert rule or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. + :type activity_log_alert_name: str + :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. Is + either a model type or a IO type. Required. + :type activity_log_alert_rule: + ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - _json = self._serialize.body(activity_log_alert_rule, 'ActivityLogAlertResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert_rule, (IO, bytes)): + _content = activity_log_alert_rule + else: + _json = self._serialize.body(activity_log_alert_rule, "ActivityLogAlertResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -329,10 +366,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -341,55 +377,49 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any ) -> _models.ActivityLogAlertResource: """Get an Activity Log Alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. :type activity_log_alert_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -397,10 +427,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -408,52 +437,46 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - activity_log_alert_name: str, - **kwargs: Any + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any ) -> None: """Delete an Activity Log Alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. :type activity_log_alert_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -461,10 +484,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -475,15 +497,16 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, activity_log_alert_name: str, activity_log_alert_rule_patch: _models.AlertRulePatchObject, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActivityLogAlertResource: """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update @@ -491,39 +514,108 @@ def update( CreateOrUpdate operation. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. :type activity_log_alert_name: str - :param activity_log_alert_rule_patch: Parameters supplied to the operation. + :param activity_log_alert_rule_patch: Parameters supplied to the operation. Required. :type activity_log_alert_rule_patch: ~$(python-base-namespace).v2020_10_01.models.AlertRulePatchObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActivityLogAlertResource, or the result of cls(response) + :return: ActivityLogAlertResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_rule_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update + the Alert rule tags, and to enable or disable the Alert rule. To update other fields use + CreateOrUpdate operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. + :type activity_log_alert_name: str + :param activity_log_alert_rule_patch: Parameters supplied to the operation. Required. + :type activity_log_alert_rule_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_rule_patch: Union[_models.AlertRulePatchObject, IO], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update + the Alert rule tags, and to enable or disable the Alert rule. To update other fields use + CreateOrUpdate operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. + :type activity_log_alert_name: str + :param activity_log_alert_rule_patch: Parameters supplied to the operation. Is either a model + type or a IO type. Required. + :type activity_log_alert_rule_patch: + ~$(python-base-namespace).v2020_10_01.models.AlertRulePatchObject or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActivityLogAlertResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] - _json = self._serialize.body(activity_log_alert_rule_patch, 'AlertRulePatchObject') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert_rule_patch, (IO, bytes)): + _content = activity_log_alert_rule_patch + else: + _json = self._serialize.body(activity_log_alert_rule_patch, "AlertRulePatchObject") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -531,10 +623,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,46 +633,42 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> Iterable[_models.AlertRuleList]: + def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActivityLogAlertResource"]: """Get a list of all Activity Log Alert rules in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleList or the result of cls(response) + :return: An iterator like instance of either ActivityLogAlertResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -589,14 +676,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -612,10 +696,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -626,46 +708,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.AlertRuleList]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ActivityLogAlertResource"]: """Get a list of all Activity Log Alert rules in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 AlertRuleList or the result of cls(response) + :return: An iterator like instance of either ActivityLogAlertResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -673,15 +752,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -697,10 +772,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -711,8 +784,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py index 984c88249141..4d0e38444d6c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-04-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", "2021-04-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json index c36a245f3f25..9795233a61a2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py index 703c12089c2b..45b2dc3a676f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py @@ -9,20 +9,24 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import DataCollectionEndpointsOperations, DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations +from .operations import ( + DataCollectionEndpointsOperations, + DataCollectionRuleAssociationsOperations, + DataCollectionRulesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar data_collection_endpoints: DataCollectionEndpointsOperations operations @@ -34,9 +38,9 @@ class MonitorManagementClient: :ivar data_collection_rules: DataCollectionRulesOperations operations :vartype data_collection_rules: $(python-base-namespace).v2021_04_01.operations.DataCollectionRulesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -52,7 +56,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -69,12 +75,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -83,7 +84,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py index b4586432cdb2..9ce19cb4be68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-04-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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", "2021-04-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py index 2521839d04e5..f57e156361e1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py @@ -9,20 +9,24 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import DataCollectionEndpointsOperations, DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations +from .operations import ( + DataCollectionEndpointsOperations, + DataCollectionRuleAssociationsOperations, + DataCollectionRulesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar data_collection_endpoints: DataCollectionEndpointsOperations operations @@ -34,9 +38,9 @@ class MonitorManagementClient: :ivar data_collection_rules: DataCollectionRulesOperations operations :vartype data_collection_rules: $(python-base-namespace).v2021_04_01.aio.operations.DataCollectionRulesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -52,7 +56,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -69,12 +75,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -83,7 +84,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/__init__.py index eea5749564d8..9d11e549f9e4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/__init__.py @@ -13,10 +13,11 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DataCollectionEndpointsOperations', - 'DataCollectionRuleAssociationsOperations', - 'DataCollectionRulesOperations', + "DataCollectionEndpointsOperations", + "DataCollectionRuleAssociationsOperations", + "DataCollectionRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py index 0bb2999f5675..149b628448e7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._data_collection_endpoints_operations import build_create_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._data_collection_endpoints_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DataCollectionEndpointsOperations: """ .. warning:: @@ -43,44 +59,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionEndpointResourceListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataCollectionEndpointResource"]: """Lists all data collection endpoints in the specified resource group. Lists all data collection endpoints in the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 DataCollectionEndpointResourceListResult or the - result of cls(response) + :return: An iterator like instance of either DataCollectionEndpointResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -88,15 +101,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -112,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -126,45 +133,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionEndpointResourceListResult]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionEndpointResource"]: """Lists all data collection endpoints in the specified subscription. Lists all data collection endpoints in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResourceListResult or the - result of cls(response) + :return: An iterator like instance of either DataCollectionEndpointResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -172,14 +173,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -195,10 +193,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -209,51 +205,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any ) -> _models.DataCollectionEndpointResource: """Returns the specified data collection endpoint. Returns the specified data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource, or the result of cls(response) + :return: DataCollectionEndpointResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -261,10 +250,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -272,22 +260,23 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, data_collection_endpoint_name: str, body: Optional[_models.DataCollectionEndpointResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionEndpointResource: """Creates or updates a data collection endpoint. @@ -295,42 +284,111 @@ async def create( Creates or updates a data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Creates or updates a data collection endpoint. + + Creates or updates a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[Union[_models.DataCollectionEndpointResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Creates or updates a data collection endpoint. + + Creates or updates a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionEndpointResource, or the result of cls(response) + :return: DataCollectionEndpointResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionEndpointResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionEndpointResource") + else: + _json = None request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -338,10 +396,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -350,25 +407,26 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, data_collection_endpoint_name: str, body: Optional[_models.ResourceForUpdate] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionEndpointResource: """Updates part of a data collection endpoint. @@ -376,42 +434,111 @@ async def update( Updates part of a data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Updates part of a data collection endpoint. + + Updates part of a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionEndpointResource, or the result of cls(response) + :return: DataCollectionEndpointResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[Union[_models.ResourceForUpdate, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Updates part of a data collection endpoint. + + Updates part of a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] - if body is not None: - _json = self._serialize.body(body, 'ResourceForUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "ResourceForUpdate") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -419,10 +546,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -430,55 +556,49 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any ) -> None: """Deletes a data collection endpoint. Deletes a data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -486,10 +606,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -500,5 +619,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py index 3a8011712e06..0683c491a983 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,18 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._data_collection_rule_associations_operations import build_create_request, build_delete_request, build_get_request, build_list_by_resource_request, build_list_by_rule_request -T = TypeVar('T') +from ...operations._data_collection_rule_associations_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_request, + build_list_by_rule_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DataCollectionRuleAssociationsOperations: """ .. warning:: @@ -43,43 +58,39 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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_resource( - self, - resource_uri: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_uri: str, **kwargs: Any + ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified resource. Lists associations for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list_by_resource.metadata['url'], + template_url=self.list_by_resource.metadata["url"], headers=_headers, params=_params, ) @@ -87,21 +98,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,10 +120,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,54 +132,49 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore + list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore @distributed_trace def list_by_rule( - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_rule_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_rule.metadata['url'], + template_url=self.list_by_rule.metadata["url"], headers=_headers, params=_params, ) @@ -179,23 +182,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_rule_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -204,10 +204,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -218,50 +216,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore + list_by_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore @distributed_trace_async async def get( - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Returns the specified association. Returns the specified association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) + :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] - request = build_get_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -269,10 +259,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,57 +269,125 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_uri: str, association_name: str, body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Creates or updates an association. Creates or updates an association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_uri: str, + association_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: + """Creates or updates an association. + + Creates or updates an association. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param association_name: The name of the association. The name is case insensitive. Required. + :type association_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_uri: str, + association_name: str, + body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: + """Creates or updates an association. + + Creates or updates an association. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param association_name: The name of the association. The name is case insensitive. Required. + :type association_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) + :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") + else: + _json = None request = build_create_request( resource_uri=resource_uri, @@ -338,7 +395,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -346,10 +404,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -358,56 +415,49 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + create.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> None: """Deletes an association. Deletes an association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -415,10 +465,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -429,5 +478,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py index 1640b72faf75..791f1be3f4f0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._data_collection_rules_operations import build_create_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._data_collection_rules_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DataCollectionRulesOperations: """ .. warning:: @@ -43,44 +59,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionRuleResourceListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataCollectionRuleResource"]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 DataCollectionRuleResourceListResult or the result - of cls(response) + :return: An iterator like instance of either DataCollectionRuleResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -88,15 +101,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -112,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -126,45 +133,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionRuleResourceListResult]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionRuleResource"]: """Lists all data collection rules in the specified subscription. Lists all data collection rules in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result - of cls(response) + :return: An iterator like instance of either DataCollectionRuleResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -172,14 +173,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -195,10 +193,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -209,51 +205,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any ) -> _models.DataCollectionRuleResource: """Returns the specified data collection rule. Returns the specified data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -261,10 +250,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -272,22 +260,23 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, data_collection_rule_name: str, body: Optional[_models.DataCollectionRuleResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleResource: """Creates or updates a data collection rule. @@ -295,42 +284,111 @@ async def create( Creates or updates a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Creates or updates a data collection rule. + + Creates or updates a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Creates or updates a data collection rule. + + Creates or updates a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionRuleResource") + else: + _json = None request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -338,10 +396,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -350,25 +407,26 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, data_collection_rule_name: str, body: Optional[_models.ResourceForUpdate] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleResource: """Updates part of a data collection rule. @@ -376,42 +434,111 @@ async def update( Updates part of a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Updates part of a data collection rule. + + Updates part of a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[Union[_models.ResourceForUpdate, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Updates part of a data collection rule. + + Updates part of a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - if body is not None: - _json = self._serialize.body(body, 'ResourceForUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "ResourceForUpdate") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -419,10 +546,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -430,55 +556,49 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any ) -> None: """Deletes a data collection rule. Deletes a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -486,10 +606,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -500,5 +619,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py index 1ec1c4b6e771..86bd994a6563 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py @@ -45,79 +45,77 @@ from ._models_py3 import SystemData from ._models_py3 import WindowsEventLogDataSource - -from ._monitor_management_client_enums import ( - CreatedByType, - KnownDataCollectionEndpointProvisioningState, - KnownDataCollectionEndpointResourceKind, - KnownDataCollectionRuleAssociationProvisioningState, - KnownDataCollectionRuleProvisioningState, - KnownDataCollectionRuleResourceKind, - KnownDataFlowStreams, - KnownExtensionDataSourceStreams, - KnownPerfCounterDataSourceStreams, - KnownPublicNetworkAccessOptions, - KnownSyslogDataSourceFacilityNames, - KnownSyslogDataSourceLogLevels, - KnownSyslogDataSourceStreams, - KnownWindowsEventLogDataSourceStreams, -) +from ._monitor_management_client_enums import CreatedByType +from ._monitor_management_client_enums import KnownDataCollectionEndpointProvisioningState +from ._monitor_management_client_enums import KnownDataCollectionEndpointResourceKind +from ._monitor_management_client_enums import KnownDataCollectionRuleAssociationProvisioningState +from ._monitor_management_client_enums import KnownDataCollectionRuleProvisioningState +from ._monitor_management_client_enums import KnownDataCollectionRuleResourceKind +from ._monitor_management_client_enums import KnownDataFlowStreams +from ._monitor_management_client_enums import KnownExtensionDataSourceStreams +from ._monitor_management_client_enums import KnownPerfCounterDataSourceStreams +from ._monitor_management_client_enums import KnownPublicNetworkAccessOptions +from ._monitor_management_client_enums import KnownSyslogDataSourceFacilityNames +from ._monitor_management_client_enums import KnownSyslogDataSourceLogLevels +from ._monitor_management_client_enums import KnownSyslogDataSourceStreams +from ._monitor_management_client_enums import KnownWindowsEventLogDataSourceStreams from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AzureMonitorMetricsDestination', - 'ConfigurationAccessEndpointSpec', - 'DataCollectionEndpoint', - 'DataCollectionEndpointConfigurationAccess', - 'DataCollectionEndpointLogsIngestion', - 'DataCollectionEndpointNetworkAcls', - 'DataCollectionEndpointResource', - 'DataCollectionEndpointResourceListResult', - 'DataCollectionEndpointResourceProperties', - 'DataCollectionEndpointResourceSystemData', - 'DataCollectionRule', - 'DataCollectionRuleAssociation', - 'DataCollectionRuleAssociationProxyOnlyResource', - 'DataCollectionRuleAssociationProxyOnlyResourceListResult', - 'DataCollectionRuleAssociationProxyOnlyResourceProperties', - 'DataCollectionRuleAssociationProxyOnlyResourceSystemData', - 'DataCollectionRuleDataSources', - 'DataCollectionRuleDestinations', - 'DataCollectionRuleResource', - 'DataCollectionRuleResourceListResult', - 'DataCollectionRuleResourceProperties', - 'DataCollectionRuleResourceSystemData', - 'DataFlow', - 'DataSourcesSpec', - 'DestinationsSpec', - 'DestinationsSpecAzureMonitorMetrics', - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponseCommonV2', - 'ExtensionDataSource', - 'LogAnalyticsDestination', - 'LogsIngestionEndpointSpec', - 'NetworkRuleSet', - 'PerfCounterDataSource', - 'ResourceForUpdate', - 'SyslogDataSource', - 'SystemData', - 'WindowsEventLogDataSource', - 'CreatedByType', - 'KnownDataCollectionEndpointProvisioningState', - 'KnownDataCollectionEndpointResourceKind', - 'KnownDataCollectionRuleAssociationProvisioningState', - 'KnownDataCollectionRuleProvisioningState', - 'KnownDataCollectionRuleResourceKind', - 'KnownDataFlowStreams', - 'KnownExtensionDataSourceStreams', - 'KnownPerfCounterDataSourceStreams', - 'KnownPublicNetworkAccessOptions', - 'KnownSyslogDataSourceFacilityNames', - 'KnownSyslogDataSourceLogLevels', - 'KnownSyslogDataSourceStreams', - 'KnownWindowsEventLogDataSourceStreams', + "AzureMonitorMetricsDestination", + "ConfigurationAccessEndpointSpec", + "DataCollectionEndpoint", + "DataCollectionEndpointConfigurationAccess", + "DataCollectionEndpointLogsIngestion", + "DataCollectionEndpointNetworkAcls", + "DataCollectionEndpointResource", + "DataCollectionEndpointResourceListResult", + "DataCollectionEndpointResourceProperties", + "DataCollectionEndpointResourceSystemData", + "DataCollectionRule", + "DataCollectionRuleAssociation", + "DataCollectionRuleAssociationProxyOnlyResource", + "DataCollectionRuleAssociationProxyOnlyResourceListResult", + "DataCollectionRuleAssociationProxyOnlyResourceProperties", + "DataCollectionRuleAssociationProxyOnlyResourceSystemData", + "DataCollectionRuleDataSources", + "DataCollectionRuleDestinations", + "DataCollectionRuleResource", + "DataCollectionRuleResourceListResult", + "DataCollectionRuleResourceProperties", + "DataCollectionRuleResourceSystemData", + "DataFlow", + "DataSourcesSpec", + "DestinationsSpec", + "DestinationsSpecAzureMonitorMetrics", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponseCommonV2", + "ExtensionDataSource", + "LogAnalyticsDestination", + "LogsIngestionEndpointSpec", + "NetworkRuleSet", + "PerfCounterDataSource", + "ResourceForUpdate", + "SyslogDataSource", + "SystemData", + "WindowsEventLogDataSource", + "CreatedByType", + "KnownDataCollectionEndpointProvisioningState", + "KnownDataCollectionEndpointResourceKind", + "KnownDataCollectionRuleAssociationProvisioningState", + "KnownDataCollectionRuleProvisioningState", + "KnownDataCollectionRuleResourceKind", + "KnownDataFlowStreams", + "KnownExtensionDataSourceStreams", + "KnownPerfCounterDataSourceStreams", + "KnownPublicNetworkAccessOptions", + "KnownSyslogDataSourceFacilityNames", + "KnownSyslogDataSourceLogLevels", + "KnownSyslogDataSourceStreams", + "KnownWindowsEventLogDataSourceStreams", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py index 19ee9462b543..455717ca16c7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_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,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AzureMonitorMetricsDestination(msrest.serialization.Model): +class AzureMonitorMetricsDestination(_serialization.Model): """Azure Monitor Metrics destination. :ivar name: A friendly name for the destination. @@ -27,26 +33,21 @@ class AzureMonitorMetricsDestination(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. :paramtype name: str """ - super(AzureMonitorMetricsDestination, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class ConfigurationAccessEndpointSpec(msrest.serialization.Model): +class ConfigurationAccessEndpointSpec(_serialization.Model): """Definition of the endpoint used for accessing configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -56,24 +57,20 @@ class ConfigurationAccessEndpointSpec(msrest.serialization.Model): """ _validation = { - 'endpoint': {'readonly': True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ConfigurationAccessEndpointSpec, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.endpoint = None -class DataCollectionEndpoint(msrest.serialization.Model): +class DataCollectionEndpoint(_serialization.Model): """Definition of data collection endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -93,22 +90,22 @@ class DataCollectionEndpoint(msrest.serialization.Model): :vartype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointProvisioningState """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'configuration_access': {'key': 'configurationAccess', 'type': 'DataCollectionEndpointConfigurationAccess'}, - 'logs_ingestion': {'key': 'logsIngestion', 'type': 'DataCollectionEndpointLogsIngestion'}, - 'network_acls': {'key': 'networkAcls', 'type': 'DataCollectionEndpointNetworkAcls'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "immutable_id": {"key": "immutableId", "type": "str"}, + "configuration_access": {"key": "configurationAccess", "type": "DataCollectionEndpointConfigurationAccess"}, + "logs_ingestion": {"key": "logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, + "network_acls": {"key": "networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -137,7 +134,7 @@ def __init__( :paramtype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls """ - super(DataCollectionEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.immutable_id = immutable_id self.configuration_access = configuration_access @@ -156,23 +153,19 @@ class DataCollectionEndpointConfigurationAccess(ConfigurationAccessEndpointSpec) """ _validation = { - 'endpoint': {'readonly': True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DataCollectionEndpointConfigurationAccess, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class LogsIngestionEndpointSpec(msrest.serialization.Model): +class LogsIngestionEndpointSpec(_serialization.Model): """Definition of the endpoint used for ingesting logs. Variables are only populated by the server, and will be ignored when sending a request. @@ -182,20 +175,16 @@ class LogsIngestionEndpointSpec(msrest.serialization.Model): """ _validation = { - 'endpoint': {'readonly': True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LogsIngestionEndpointSpec, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.endpoint = None @@ -209,48 +198,41 @@ class DataCollectionEndpointLogsIngestion(LogsIngestionEndpointSpec): """ _validation = { - 'endpoint': {'readonly': True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DataCollectionEndpointLogsIngestion, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Definition of the network rules. :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions """ _attribute_map = { - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, } def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, - **kwargs + self, *, public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, **kwargs ): """ :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_network_access = public_network_access @@ -258,42 +240,39 @@ class DataCollectionEndpointNetworkAcls(NetworkRuleSet): """Network access control rules for the endpoints. :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions """ _attribute_map = { - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, } def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, - **kwargs + self, *, public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, **kwargs ): """ :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions """ - super(DataCollectionEndpointNetworkAcls, self).__init__(public_network_access=public_network_access, **kwargs) + super().__init__(public_network_access=public_network_access, **kwargs) -class DataCollectionEndpointResource(msrest.serialization.Model): +class DataCollectionEndpointResource(_serialization.Model): # pylint: disable=too-many-instance-attributes """Definition of ARM tracked top level 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 location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Known values are: "Linux", "Windows". + :ivar kind: The kind of the resource. Known values are: "Linux" and "Windows". :vartype kind: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointResourceKind :ivar id: Fully qualified ID of the resource. @@ -322,36 +301,39 @@ class DataCollectionEndpointResource(msrest.serialization.Model): :vartype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointProvisioningState """ _validation = { - 'location': {'required': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "location": {"required": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'DataCollectionEndpointResourceSystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'immutable_id': {'key': 'properties.immutableId', 'type': 'str'}, - 'configuration_access': {'key': 'properties.configurationAccess', 'type': 'DataCollectionEndpointConfigurationAccess'}, - 'logs_ingestion': {'key': 'properties.logsIngestion', 'type': 'DataCollectionEndpointLogsIngestion'}, - 'network_acls': {'key': 'properties.networkAcls', 'type': 'DataCollectionEndpointNetworkAcls'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "kind": {"key": "kind", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "system_data": {"key": "systemData", "type": "DataCollectionEndpointResourceSystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "immutable_id": {"key": "properties.immutableId", "type": "str"}, + "configuration_access": { + "key": "properties.configurationAccess", + "type": "DataCollectionEndpointConfigurationAccess", + }, + "logs_ingestion": {"key": "properties.logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, + "network_acls": {"key": "properties.networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -368,11 +350,11 @@ def __init__( **kwargs ): """ - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Known values are: "Linux", "Windows". + :keyword kind: The kind of the resource. Known values are: "Linux" and "Windows". :paramtype kind: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointResourceKind :keyword description: Description of the data collection endpoint. @@ -390,7 +372,7 @@ def __init__( :paramtype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls """ - super(DataCollectionEndpointResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.kind = kind @@ -407,12 +389,12 @@ def __init__( self.provisioning_state = None -class DataCollectionEndpointResourceListResult(msrest.serialization.Model): +class DataCollectionEndpointResourceListResult(_serialization.Model): """A pageable list of resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. A list of resources. + :ivar value: A list of resources. Required. :vartype value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource] :ivar next_link: The URL to use for getting the next set of results. @@ -420,29 +402,25 @@ class DataCollectionEndpointResourceListResult(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCollectionEndpointResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataCollectionEndpointResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: List["_models.DataCollectionEndpointResource"], - next_link: Optional[str] = None, - **kwargs + self, *, value: List["_models.DataCollectionEndpointResource"], next_link: Optional[str] = None, **kwargs ): """ - :keyword value: Required. A list of resources. + :keyword value: A list of resources. Required. :paramtype value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(DataCollectionEndpointResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -467,22 +445,22 @@ class DataCollectionEndpointResourceProperties(DataCollectionEndpoint): :vartype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointProvisioningState """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'configuration_access': {'key': 'configurationAccess', 'type': 'DataCollectionEndpointConfigurationAccess'}, - 'logs_ingestion': {'key': 'logsIngestion', 'type': 'DataCollectionEndpointLogsIngestion'}, - 'network_acls': {'key': 'networkAcls', 'type': 'DataCollectionEndpointNetworkAcls'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "immutable_id": {"key": "immutableId", "type": "str"}, + "configuration_access": {"key": "configurationAccess", "type": "DataCollectionEndpointConfigurationAccess"}, + "logs_ingestion": {"key": "logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, + "network_acls": {"key": "networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -511,23 +489,30 @@ def __init__( :paramtype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls """ - super(DataCollectionEndpointResourceProperties, self).__init__(description=description, immutable_id=immutable_id, configuration_access=configuration_access, logs_ingestion=logs_ingestion, network_acls=network_acls, **kwargs) + super().__init__( + description=description, + immutable_id=immutable_id, + configuration_access=configuration_access, + logs_ingestion=logs_ingestion, + network_acls=network_acls, + **kwargs + ) -class SystemData(msrest.serialization.Model): +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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -535,12 +520,12 @@ class SystemData(msrest.serialization.Model): """ _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__( @@ -558,20 +543,20 @@ def __init__( :keyword created_by: The identity that created the resource. :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -586,14 +571,14 @@ class DataCollectionEndpointResourceSystemData(SystemData): :ivar created_by: The identity that created the resource. :vartype created_by: str :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -601,12 +586,12 @@ class DataCollectionEndpointResourceSystemData(SystemData): """ _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__( @@ -624,23 +609,31 @@ def __init__( :keyword created_by: The identity that created the resource. :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(DataCollectionEndpointResourceSystemData, self).__init__(created_by=created_by, created_by_type=created_by_type, created_at=created_at, last_modified_by=last_modified_by, last_modified_by_type=last_modified_by_type, last_modified_at=last_modified_at, **kwargs) + super().__init__( + created_by=created_by, + created_by_type=created_by_type, + created_at=created_at, + last_modified_by=last_modified_by, + last_modified_by_type=last_modified_by_type, + last_modified_at=last_modified_at, + **kwargs + ) -class DataCollectionRule(msrest.serialization.Model): +class DataCollectionRule(_serialization.Model): """Definition of what monitoring data to collect and where that data should be sent. Variables are only populated by the server, and will be ignored when sending a request. @@ -660,23 +653,23 @@ class DataCollectionRule(msrest.serialization.Model): :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleProvisioningState """ _validation = { - 'immutable_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "immutable_id": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'data_sources': {'key': 'dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "immutable_id": {"key": "immutableId", "type": "str"}, + "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, + "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, + "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -702,7 +695,7 @@ def __init__( :keyword data_flows: The specification of data flows. :paramtype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] """ - super(DataCollectionRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.immutable_id = None self.data_sources = data_sources @@ -711,7 +704,7 @@ def __init__( self.provisioning_state = None -class DataCollectionRuleAssociation(msrest.serialization.Model): +class DataCollectionRuleAssociation(_serialization.Model): """Definition of association of a data collection rule with a monitored Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -725,20 +718,20 @@ class DataCollectionRuleAssociation(msrest.serialization.Model): be associated. :vartype data_collection_endpoint_id: str :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleAssociationProvisioningState """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'dataCollectionRuleId', 'type': 'str'}, - 'data_collection_endpoint_id': {'key': 'dataCollectionEndpointId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, + "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -759,14 +752,14 @@ def __init__( to be associated. :paramtype data_collection_endpoint_id: str """ - super(DataCollectionRuleAssociation, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.data_collection_rule_id = data_collection_rule_id self.data_collection_endpoint_id = data_collection_endpoint_id self.provisioning_state = None -class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model): +class DataCollectionRuleAssociationProxyOnlyResource(_serialization.Model): """Definition of generic ARM proxy resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -791,30 +784,30 @@ class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model) be associated. :vartype data_collection_endpoint_id: str :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleAssociationProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'DataCollectionRuleAssociationProxyOnlyResourceSystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'properties.dataCollectionRuleId', 'type': 'str'}, - 'data_collection_endpoint_id': {'key': 'properties.dataCollectionEndpointId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "system_data": {"key": "systemData", "type": "DataCollectionRuleAssociationProxyOnlyResourceSystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "data_collection_rule_id": {"key": "properties.dataCollectionRuleId", "type": "str"}, + "data_collection_endpoint_id": {"key": "properties.dataCollectionEndpointId", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -835,7 +828,7 @@ def __init__( to be associated. :paramtype data_collection_endpoint_id: str """ - super(DataCollectionRuleAssociationProxyOnlyResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -847,12 +840,12 @@ def __init__( self.provisioning_state = None -class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serialization.Model): +class DataCollectionRuleAssociationProxyOnlyResourceListResult(_serialization.Model): """A pageable list of resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. A list of resources. + :ivar value: A list of resources. Required. :vartype value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] :ivar next_link: The URL to use for getting the next set of results. @@ -860,12 +853,12 @@ class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serializat """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCollectionRuleAssociationProxyOnlyResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataCollectionRuleAssociationProxyOnlyResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -876,13 +869,13 @@ def __init__( **kwargs ): """ - :keyword value: Required. A list of resources. + :keyword value: A list of resources. Required. :paramtype value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(DataCollectionRuleAssociationProxyOnlyResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -901,20 +894,20 @@ class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRul be associated. :vartype data_collection_endpoint_id: str :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleAssociationProvisioningState """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'dataCollectionRuleId', 'type': 'str'}, - 'data_collection_endpoint_id': {'key': 'dataCollectionEndpointId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, + "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -935,7 +928,12 @@ def __init__( to be associated. :paramtype data_collection_endpoint_id: str """ - super(DataCollectionRuleAssociationProxyOnlyResourceProperties, self).__init__(description=description, data_collection_rule_id=data_collection_rule_id, data_collection_endpoint_id=data_collection_endpoint_id, **kwargs) + super().__init__( + description=description, + data_collection_rule_id=data_collection_rule_id, + data_collection_endpoint_id=data_collection_endpoint_id, + **kwargs + ) class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): @@ -944,14 +942,14 @@ class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): :ivar created_by: The identity that created the resource. :vartype created_by: str :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -959,12 +957,12 @@ class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): """ _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__( @@ -982,23 +980,31 @@ def __init__( :keyword created_by: The identity that created the resource. :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(DataCollectionRuleAssociationProxyOnlyResourceSystemData, self).__init__(created_by=created_by, created_by_type=created_by_type, created_at=created_at, last_modified_by=last_modified_by, last_modified_by_type=last_modified_by_type, last_modified_at=last_modified_at, **kwargs) + super().__init__( + created_by=created_by, + created_by_type=created_by_type, + created_at=created_at, + last_modified_by=last_modified_by, + last_modified_by_type=last_modified_by_type, + last_modified_at=last_modified_at, + **kwargs + ) -class DataSourcesSpec(msrest.serialization.Model): +class DataSourcesSpec(_serialization.Model): """Specification of data sources that will be collected. :ivar performance_counters: The list of performance counter data source configurations. @@ -1014,10 +1020,10 @@ class DataSourcesSpec(msrest.serialization.Model): """ _attribute_map = { - 'performance_counters': {'key': 'performanceCounters', 'type': '[PerfCounterDataSource]'}, - 'windows_event_logs': {'key': 'windowsEventLogs', 'type': '[WindowsEventLogDataSource]'}, - 'syslog': {'key': 'syslog', 'type': '[SyslogDataSource]'}, - 'extensions': {'key': 'extensions', 'type': '[ExtensionDataSource]'}, + "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, + "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, + "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, + "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, } def __init__( @@ -1041,7 +1047,7 @@ def __init__( :keyword extensions: The list of Azure VM extension data source configurations. :paramtype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] """ - super(DataSourcesSpec, self).__init__(**kwargs) + super().__init__(**kwargs) self.performance_counters = performance_counters self.windows_event_logs = windows_event_logs self.syslog = syslog @@ -1049,26 +1055,26 @@ def __init__( class DataCollectionRuleDataSources(DataSourcesSpec): - """The specification of data sources. -This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. + """The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~$(python-base-namespace).v2021_04_01.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~$(python-base-namespace).v2021_04_01.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: + list[~$(python-base-namespace).v2021_04_01.models.PerfCounterDataSource] + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: + list[~$(python-base-namespace).v2021_04_01.models.WindowsEventLogDataSource] + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] """ _attribute_map = { - 'performance_counters': {'key': 'performanceCounters', 'type': '[PerfCounterDataSource]'}, - 'windows_event_logs': {'key': 'windowsEventLogs', 'type': '[WindowsEventLogDataSource]'}, - 'syslog': {'key': 'syslog', 'type': '[SyslogDataSource]'}, - 'extensions': {'key': 'extensions', 'type': '[ExtensionDataSource]'}, + "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, + "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, + "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, + "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, } def __init__( @@ -1092,10 +1098,16 @@ def __init__( :keyword extensions: The list of Azure VM extension data source configurations. :paramtype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] """ - super(DataCollectionRuleDataSources, self).__init__(performance_counters=performance_counters, windows_event_logs=windows_event_logs, syslog=syslog, extensions=extensions, **kwargs) + super().__init__( + performance_counters=performance_counters, + windows_event_logs=windows_event_logs, + syslog=syslog, + extensions=extensions, + **kwargs + ) -class DestinationsSpec(msrest.serialization.Model): +class DestinationsSpec(_serialization.Model): """Specification of destinations that can be used in data flows. :ivar log_analytics: List of Log Analytics destinations. @@ -1107,8 +1119,8 @@ class DestinationsSpec(msrest.serialization.Model): """ _attribute_map = { - 'log_analytics': {'key': 'logAnalytics', 'type': '[LogAnalyticsDestination]'}, - 'azure_monitor_metrics': {'key': 'azureMonitorMetrics', 'type': 'DestinationsSpecAzureMonitorMetrics'}, + "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, + "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, } def __init__( @@ -1126,7 +1138,7 @@ def __init__( :paramtype azure_monitor_metrics: ~$(python-base-namespace).v2021_04_01.models.DestinationsSpecAzureMonitorMetrics """ - super(DestinationsSpec, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_analytics = log_analytics self.azure_monitor_metrics = azure_monitor_metrics @@ -1143,8 +1155,8 @@ class DataCollectionRuleDestinations(DestinationsSpec): """ _attribute_map = { - 'log_analytics': {'key': 'logAnalytics', 'type': '[LogAnalyticsDestination]'}, - 'azure_monitor_metrics': {'key': 'azureMonitorMetrics', 'type': 'DestinationsSpecAzureMonitorMetrics'}, + "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, + "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, } def __init__( @@ -1162,21 +1174,21 @@ def __init__( :paramtype azure_monitor_metrics: ~$(python-base-namespace).v2021_04_01.models.DestinationsSpecAzureMonitorMetrics """ - super(DataCollectionRuleDestinations, self).__init__(log_analytics=log_analytics, azure_monitor_metrics=azure_monitor_metrics, **kwargs) + super().__init__(log_analytics=log_analytics, azure_monitor_metrics=azure_monitor_metrics, **kwargs) -class DataCollectionRuleResource(msrest.serialization.Model): +class DataCollectionRuleResource(_serialization.Model): # pylint: disable=too-many-instance-attributes """Definition of ARM tracked top level 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 location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Known values are: "Linux", "Windows". + :ivar kind: The kind of the resource. Known values are: "Linux" and "Windows". :vartype kind: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleResourceKind :ivar id: Fully qualified ID of the resource. @@ -1205,37 +1217,37 @@ class DataCollectionRuleResource(msrest.serialization.Model): :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleProvisioningState """ _validation = { - 'location': {'required': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'immutable_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "location": {"required": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "system_data": {"readonly": True}, + "immutable_id": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'DataCollectionRuleResourceSystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'immutable_id': {'key': 'properties.immutableId', 'type': 'str'}, - 'data_sources': {'key': 'properties.dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'properties.destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'properties.dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "kind": {"key": "kind", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "system_data": {"key": "systemData", "type": "DataCollectionRuleResourceSystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "immutable_id": {"key": "properties.immutableId", "type": "str"}, + "data_sources": {"key": "properties.dataSources", "type": "DataCollectionRuleDataSources"}, + "destinations": {"key": "properties.destinations", "type": "DataCollectionRuleDestinations"}, + "data_flows": {"key": "properties.dataFlows", "type": "[DataFlow]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -1251,11 +1263,11 @@ def __init__( **kwargs ): """ - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Known values are: "Linux", "Windows". + :keyword kind: The kind of the resource. Known values are: "Linux" and "Windows". :paramtype kind: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleResourceKind :keyword description: Description of the data collection rule. @@ -1271,7 +1283,7 @@ def __init__( :keyword data_flows: The specification of data flows. :paramtype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] """ - super(DataCollectionRuleResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.kind = kind @@ -1288,40 +1300,34 @@ def __init__( self.provisioning_state = None -class DataCollectionRuleResourceListResult(msrest.serialization.Model): +class DataCollectionRuleResourceListResult(_serialization.Model): """A pageable list of resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. A list of resources. + :ivar value: A list of resources. Required. :vartype value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCollectionRuleResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataCollectionRuleResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["_models.DataCollectionRuleResource"], - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs): """ - :keyword value: Required. A list of resources. + :keyword value: A list of resources. Required. :paramtype value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(DataCollectionRuleResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1346,23 +1352,23 @@ class DataCollectionRuleResourceProperties(DataCollectionRule): :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleProvisioningState """ _validation = { - 'immutable_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "immutable_id": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'data_sources': {'key': 'dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "immutable_id": {"key": "immutableId", "type": "str"}, + "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, + "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, + "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1388,7 +1394,13 @@ def __init__( :keyword data_flows: The specification of data flows. :paramtype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] """ - super(DataCollectionRuleResourceProperties, self).__init__(description=description, data_sources=data_sources, destinations=destinations, data_flows=data_flows, **kwargs) + super().__init__( + description=description, + data_sources=data_sources, + destinations=destinations, + data_flows=data_flows, + **kwargs + ) class DataCollectionRuleResourceSystemData(SystemData): @@ -1397,14 +1409,14 @@ class DataCollectionRuleResourceSystemData(SystemData): :ivar created_by: The identity that created the resource. :vartype created_by: str :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -1412,12 +1424,12 @@ class DataCollectionRuleResourceSystemData(SystemData): """ _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__( @@ -1435,23 +1447,31 @@ def __init__( :keyword created_by: The identity that created the resource. :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(DataCollectionRuleResourceSystemData, self).__init__(created_by=created_by, created_by_type=created_by_type, created_at=created_at, last_modified_by=last_modified_by, last_modified_by_type=last_modified_by_type, last_modified_at=last_modified_at, **kwargs) + super().__init__( + created_by=created_by, + created_by_type=created_by_type, + created_at=created_at, + last_modified_by=last_modified_by, + last_modified_by_type=last_modified_by_type, + last_modified_at=last_modified_at, + **kwargs + ) -class DataFlow(msrest.serialization.Model): +class DataFlow(_serialization.Model): """Definition of which streams are sent to which destinations. :ivar streams: List of streams for this data flow. @@ -1462,8 +1482,8 @@ class DataFlow(msrest.serialization.Model): """ _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'destinations': {'key': 'destinations', 'type': '[str]'}, + "streams": {"key": "streams", "type": "[str]"}, + "destinations": {"key": "destinations", "type": "[str]"}, } def __init__( @@ -1480,7 +1500,7 @@ def __init__( :keyword destinations: List of destinations for this data flow. :paramtype destinations: list[str] """ - super(DataFlow, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.destinations = destinations @@ -1495,25 +1515,20 @@ class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. :paramtype name: str """ - super(DestinationsSpecAzureMonitorMetrics, self).__init__(name=name, **kwargs) + super().__init__(name=name, **kwargs) -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -1521,31 +1536,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -1564,28 +1575,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -1593,7 +1600,7 @@ def __init__( self.additional_info = None -class ErrorResponseCommonV2(msrest.serialization.Model): +class ErrorResponseCommonV2(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. @@ -1601,57 +1608,52 @@ class ErrorResponseCommonV2(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~$(python-base-namespace).v2021_04_01.models.ErrorDetail """ - super(ErrorResponseCommonV2, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ExtensionDataSource(msrest.serialization.Model): +class ExtensionDataSource(_serialization.Model): """Definition of which data will be collected from a separate VM extension that integrates with the Azure Monitor Agent. -Collected from either Windows and Linux machines, depending on which extension is defined. + Collected from either Windows and Linux machines, depending on which extension is defined. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to Azure. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2021_04_01.models.KnownExtensionDataSourceStreams] - :ivar extension_name: Required. The name of the VM extension. - :vartype extension_name: str - :ivar extension_settings: The extension settings. The format is specific for particular - extension. - :vartype extension_settings: any - :ivar input_data_sources: The list of data sources this extension needs data from. - :vartype input_data_sources: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownExtensionDataSourceStreams] + :ivar extension_name: The name of the VM extension. Required. + :vartype extension_name: str + :ivar extension_settings: The extension settings. The format is specific for particular + extension. + :vartype extension_settings: JSON + :ivar input_data_sources: The list of data sources this extension needs data from. + :vartype input_data_sources: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _validation = { - 'extension_name': {'required': True}, + "extension_name": {"required": True}, } _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'extension_name': {'key': 'extensionName', 'type': 'str'}, - 'extension_settings': {'key': 'extensionSettings', 'type': 'object'}, - 'input_data_sources': {'key': 'inputDataSources', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "extension_name": {"key": "extensionName", "type": "str"}, + "extension_settings": {"key": "extensionSettings", "type": "object"}, + "input_data_sources": {"key": "inputDataSources", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -1659,7 +1661,7 @@ def __init__( *, extension_name: str, streams: Optional[List[Union[str, "_models.KnownExtensionDataSourceStreams"]]] = None, - extension_settings: Optional[Any] = None, + extension_settings: Optional[JSON] = None, input_data_sources: Optional[List[str]] = None, name: Optional[str] = None, **kwargs @@ -1670,11 +1672,11 @@ def __init__( Analytics the data will be sent to. :paramtype streams: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownExtensionDataSourceStreams] - :keyword extension_name: Required. The name of the VM extension. + :keyword extension_name: The name of the VM extension. Required. :paramtype extension_name: str :keyword extension_settings: The extension settings. The format is specific for particular extension. - :paramtype extension_settings: any + :paramtype extension_settings: JSON :keyword input_data_sources: The list of data sources this extension needs data from. :paramtype input_data_sources: list[str] :keyword name: A friendly name for the data source. @@ -1682,7 +1684,7 @@ def __init__( collection rule. :paramtype name: str """ - super(ExtensionDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.extension_name = extension_name self.extension_settings = extension_settings @@ -1690,7 +1692,7 @@ def __init__( self.name = name -class LogAnalyticsDestination(msrest.serialization.Model): +class LogAnalyticsDestination(_serialization.Model): """Log Analytics destination. Variables are only populated by the server, and will be ignored when sending a request. @@ -1706,22 +1708,16 @@ class LogAnalyticsDestination(msrest.serialization.Model): """ _validation = { - 'workspace_id': {'readonly': True}, + "workspace_id": {"readonly": True}, } _attribute_map = { - 'workspace_resource_id': {'key': 'workspaceResourceId', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "workspace_resource_id": {"key": "workspaceResourceId", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - workspace_resource_id: Optional[str] = None, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, workspace_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs): """ :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. :paramtype workspace_resource_id: str @@ -1730,40 +1726,40 @@ def __init__( collection rule. :paramtype name: str """ - super(LogAnalyticsDestination, self).__init__(**kwargs) + super().__init__(**kwargs) self.workspace_resource_id = workspace_resource_id self.workspace_id = None self.name = name -class PerfCounterDataSource(msrest.serialization.Model): +class PerfCounterDataSource(_serialization.Model): """Definition of which performance counters will be collected and how they will be collected by this data collection rule. -Collected from both Windows and Linux machines where the counter is present. + Collected from both Windows and Linux machines where the counter is present. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2021_04_01.models.KnownPerfCounterDataSourceStreams] - :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :vartype sampling_frequency_in_seconds: int - :ivar counter_specifiers: A list of specifier names of the performance counters you want to - collect. - Use a wildcard (*) to collect a counter for all instances. - To get a list of performance counters on Windows, run the command 'typeperf'. - :vartype counter_specifiers: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownPerfCounterDataSourceStreams] + :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter + measurements (samples). + :vartype sampling_frequency_in_seconds: int + :ivar counter_specifiers: A list of specifier names of the performance counters you want to + collect. + Use a wildcard (*) to collect a counter for all instances. + To get a list of performance counters on Windows, run the command 'typeperf'. + :vartype counter_specifiers: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'sampling_frequency_in_seconds': {'key': 'samplingFrequencyInSeconds', 'type': 'int'}, - 'counter_specifiers': {'key': 'counterSpecifiers', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "sampling_frequency_in_seconds": {"key": "samplingFrequencyInSeconds", "type": "int"}, + "counter_specifiers": {"key": "counterSpecifiers", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -1794,64 +1790,59 @@ def __init__( collection rule. :paramtype name: str """ - super(PerfCounterDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.sampling_frequency_in_seconds = sampling_frequency_in_seconds self.counter_specifiers = counter_specifiers self.name = name -class ResourceForUpdate(msrest.serialization.Model): +class ResourceForUpdate(_serialization.Model): """Definition of ARM tracked top level resource properties for update operation. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :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 - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceForUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class SyslogDataSource(msrest.serialization.Model): +class SyslogDataSource(_serialization.Model): """Definition of which syslog data will be collected and how it will be collected. -Only collected from Linux machines. + Only collected from Linux machines. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceStreams] - :ivar facility_names: The list of facility names. - :vartype facility_names: list[str or - ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceFacilityNames] - :ivar log_levels: The log levels to collect. - :vartype log_levels: list[str or - ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceLogLevels] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceStreams] + :ivar facility_names: The list of facility names. + :vartype facility_names: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceFacilityNames] + :ivar log_levels: The log levels to collect. + :vartype log_levels: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceLogLevels] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'facility_names': {'key': 'facilityNames', 'type': '[str]'}, - 'log_levels': {'key': 'logLevels', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "facility_names": {"key": "facilityNames", "type": "[str]"}, + "log_levels": {"key": "logLevels", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -1880,34 +1871,34 @@ def __init__( collection rule. :paramtype name: str """ - super(SyslogDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.facility_names = facility_names self.log_levels = log_levels self.name = name -class WindowsEventLogDataSource(msrest.serialization.Model): +class WindowsEventLogDataSource(_serialization.Model): """Definition of which Windows Event Log events will be collected and how they will be collected. -Only collected from Windows machines. + Only collected from Windows machines. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2021_04_01.models.KnownWindowsEventLogDataSourceStreams] - :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. - :vartype x_path_queries: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownWindowsEventLogDataSourceStreams] + :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. + :vartype x_path_queries: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'x_path_queries': {'key': 'xPathQueries', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "x_path_queries": {"key": "xPathQueries", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -1931,7 +1922,7 @@ def __init__( collection rule. :paramtype name: str """ - super(WindowsEventLogDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.x_path_queries = x_path_queries self.name = name diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py index b8366d4a41a1..c9edaf22bd95 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py @@ -11,17 +11,16 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class KnownDataCollectionEndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state. This property is READ-ONLY. - """ + """The resource provisioning state. This property is READ-ONLY.""" CREATING = "Creating" UPDATING = "Updating" @@ -29,16 +28,16 @@ class KnownDataCollectionEndpointProvisioningState(str, Enum, metaclass=CaseInse SUCCEEDED = "Succeeded" FAILED = "Failed" + class KnownDataCollectionEndpointResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the resource. - """ + """The kind of the resource.""" LINUX = "Linux" WINDOWS = "Windows" + class KnownDataCollectionRuleAssociationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state. - """ + """The resource provisioning state.""" CREATING = "Creating" UPDATING = "Updating" @@ -46,9 +45,9 @@ class KnownDataCollectionRuleAssociationProvisioningState(str, Enum, metaclass=C SUCCEEDED = "Succeeded" FAILED = "Failed" + class KnownDataCollectionRuleProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state. - """ + """The resource provisioning state.""" CREATING = "Creating" UPDATING = "Updating" @@ -56,14 +55,16 @@ class KnownDataCollectionRuleProvisioningState(str, Enum, metaclass=CaseInsensit SUCCEEDED = "Succeeded" FAILED = "Failed" + class KnownDataCollectionRuleResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the resource. - """ + """The kind of the resource.""" LINUX = "Linux" WINDOWS = "Windows" + class KnownDataFlowStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownDataFlowStreams.""" MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -71,7 +72,9 @@ class KnownDataFlowStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" + class KnownExtensionDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownExtensionDataSourceStreams.""" MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -79,11 +82,14 @@ class KnownExtensionDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMe MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" + class KnownPerfCounterDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownPerfCounterDataSourceStreams.""" MICROSOFT_PERF = "Microsoft-Perf" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" + class KnownPublicNetworkAccessOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The configuration to set whether network access from public internet to the endpoints are allowed. @@ -92,7 +98,9 @@ class KnownPublicNetworkAccessOptions(str, Enum, metaclass=CaseInsensitiveEnumMe ENABLED = "Enabled" DISABLED = "Disabled" + class KnownSyslogDataSourceFacilityNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownSyslogDataSourceFacilityNames.""" AUTH = "auth" AUTHPRIV = "authpriv" @@ -116,7 +124,9 @@ class KnownSyslogDataSourceFacilityNames(str, Enum, metaclass=CaseInsensitiveEnu LOCAL7 = "local7" ASTERISK = "*" + class KnownSyslogDataSourceLogLevels(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownSyslogDataSourceLogLevels.""" DEBUG = "Debug" INFO = "Info" @@ -128,11 +138,15 @@ class KnownSyslogDataSourceLogLevels(str, Enum, metaclass=CaseInsensitiveEnumMet EMERGENCY = "Emergency" ASTERISK = "*" + class KnownSyslogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownSyslogDataSourceStreams.""" MICROSOFT_SYSLOG = "Microsoft-Syslog" + class KnownWindowsEventLogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownWindowsEventLogDataSourceStreams.""" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" MICROSOFT_EVENT = "Microsoft-Event" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/__init__.py index eea5749564d8..9d11e549f9e4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/__init__.py @@ -13,10 +13,11 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DataCollectionEndpointsOperations', - 'DataCollectionRuleAssociationsOperations', - 'DataCollectionRulesOperations', + "DataCollectionEndpointsOperations", + "DataCollectionRuleAssociationsOperations", + "DataCollectionRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py index 347fc381c19e..18c915ae41cd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +25,217 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any + resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionEndpointName": _SERIALIZER.url( + "data_collection_endpoint_name", data_collection_endpoint_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - subscription_id: str, - resource_group_name: str, - data_collection_endpoint_name: str, - *, - json: Optional[_models.DataCollectionEndpointResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionEndpointName": _SERIALIZER.url( + "data_collection_endpoint_name", data_collection_endpoint_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_update_request( - subscription_id: str, - resource_group_name: str, - data_collection_endpoint_name: str, - *, - json: Optional[_models.ResourceForUpdate] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionEndpointName": _SERIALIZER.url( + "data_collection_endpoint_name", data_collection_endpoint_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_delete_request( - subscription_id: str, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any + resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionEndpointName": _SERIALIZER.url( + "data_collection_endpoint_name", data_collection_endpoint_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + class DataCollectionEndpointsOperations: """ @@ -277,44 +256,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.DataCollectionEndpointResourceListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.DataCollectionEndpointResource"]: """Lists all data collection endpoints in the specified resource group. Lists all data collection endpoints in the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 DataCollectionEndpointResourceListResult or the - result of cls(response) + :return: An iterator like instance of either DataCollectionEndpointResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -322,15 +298,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -346,10 +318,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -360,45 +330,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.DataCollectionEndpointResourceListResult]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionEndpointResource"]: """Lists all data collection endpoints in the specified subscription. Lists all data collection endpoints in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResourceListResult or the - result of cls(response) + :return: An iterator like instance of either DataCollectionEndpointResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -406,14 +370,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -429,10 +390,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -443,51 +402,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any ) -> _models.DataCollectionEndpointResource: """Returns the specified data collection endpoint. Returns the specified data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource, or the result of cls(response) + :return: DataCollectionEndpointResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -495,10 +447,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -506,22 +457,23 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, data_collection_endpoint_name: str, body: Optional[_models.DataCollectionEndpointResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionEndpointResource: """Creates or updates a data collection endpoint. @@ -529,42 +481,111 @@ def create( Creates or updates a data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Creates or updates a data collection endpoint. + + Creates or updates a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionEndpointResource, or the result of cls(response) + :return: DataCollectionEndpointResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[Union[_models.DataCollectionEndpointResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Creates or updates a data collection endpoint. + + Creates or updates a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionEndpointResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionEndpointResource") + else: + _json = None request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -572,10 +593,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -584,25 +604,26 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, data_collection_endpoint_name: str, body: Optional[_models.ResourceForUpdate] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionEndpointResource: """Updates part of a data collection endpoint. @@ -610,42 +631,111 @@ def update( Updates part of a data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionEndpointResource, or the result of cls(response) + :return: DataCollectionEndpointResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Updates part of a data collection endpoint. + + Updates part of a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[Union[_models.ResourceForUpdate, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Updates part of a data collection endpoint. + + Updates part of a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] - if body is not None: - _json = self._serialize.body(body, 'ResourceForUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "ResourceForUpdate") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -653,10 +743,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -664,55 +753,49 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any ) -> None: """Deletes a data collection endpoint. Deletes a data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -720,10 +803,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -734,5 +816,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py index 6219c8239c50..4aaf196912a5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,194 +25,156 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_resource_request( - resource_uri: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_rule_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( - resource_uri: str, - association_name: str, - **kwargs: Any -) -> HttpRequest: +def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - resource_uri: str, - association_name: str, - *, - json: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_uri: str, - association_name: str, - **kwargs: Any -) -> HttpRequest: + _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(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DataCollectionRuleAssociationsOperations: """ @@ -228,43 +195,39 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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_resource( - self, - resource_uri: str, - **kwargs: Any - ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_uri: str, **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified resource. Lists associations for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list_by_resource.metadata['url'], + template_url=self.list_by_resource.metadata["url"], headers=_headers, params=_params, ) @@ -272,21 +235,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -295,10 +257,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -309,54 +269,49 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore + list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore @distributed_trace def list_by_rule( - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any - ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_rule_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_rule.metadata['url'], + template_url=self.list_by_rule.metadata["url"], headers=_headers, params=_params, ) @@ -364,23 +319,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_rule_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -389,10 +341,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -403,50 +353,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore + list_by_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore @distributed_trace def get( - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Returns the specified association. Returns the specified association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) + :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] - request = build_get_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -454,10 +396,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -465,57 +406,125 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - @distributed_trace + @overload def create( self, resource_uri: str, association_name: str, body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Creates or updates an association. Creates or updates an association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) + :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create( + self, + resource_uri: str, + association_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: + """Creates or updates an association. + + Creates or updates an association. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param association_name: The name of the association. The name is case insensitive. Required. + :type association_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_uri: str, + association_name: str, + body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: + """Creates or updates an association. + + Creates or updates an association. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param association_name: The name of the association. The name is case insensitive. Required. + :type association_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") + else: + _json = None request = build_create_request( resource_uri=resource_uri, @@ -523,7 +532,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -531,10 +541,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -543,56 +552,49 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + create.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> None: """Deletes an association. Deletes an association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -600,10 +602,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -614,5 +615,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py index b4ad58840527..649e0fa9962e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +25,209 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - *, - json: Optional[_models.DataCollectionRuleResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_update_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - *, - json: Optional[_models.ResourceForUpdate] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_delete_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + class DataCollectionRulesOperations: """ @@ -277,44 +248,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.DataCollectionRuleResourceListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleResource"]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 DataCollectionRuleResourceListResult or the result - of cls(response) + :return: An iterator like instance of either DataCollectionRuleResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -322,15 +290,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -346,10 +310,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -360,45 +322,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.DataCollectionRuleResourceListResult]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionRuleResource"]: """Lists all data collection rules in the specified subscription. Lists all data collection rules in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result - of cls(response) + :return: An iterator like instance of either DataCollectionRuleResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -406,14 +362,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -429,10 +382,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -443,51 +394,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any ) -> _models.DataCollectionRuleResource: """Returns the specified data collection rule. Returns the specified data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -495,10 +439,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -506,22 +449,23 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, data_collection_rule_name: str, body: Optional[_models.DataCollectionRuleResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleResource: """Creates or updates a data collection rule. @@ -529,42 +473,111 @@ def create( Creates or updates a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Creates or updates a data collection rule. + + Creates or updates a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Creates or updates a data collection rule. + + Creates or updates a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionRuleResource") + else: + _json = None request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -572,10 +585,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -584,25 +596,26 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, data_collection_rule_name: str, body: Optional[_models.ResourceForUpdate] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleResource: """Updates part of a data collection rule. @@ -610,42 +623,111 @@ def update( Updates part of a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Updates part of a data collection rule. + + Updates part of a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[Union[_models.ResourceForUpdate, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Updates part of a data collection rule. + + Updates part of a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - if body is not None: - _json = self._serialize.body(body, 'ResourceForUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "ResourceForUpdate") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -653,10 +735,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -664,55 +745,49 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any ) -> None: """Deletes a data collection rule. Deletes a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -720,10 +795,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -734,5 +808,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py index 8762b312b134..85a437cbd398 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-05-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json index fff521006964..e9f96dd720ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py index 38028c186519..301cff76edbc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py @@ -9,20 +9,27 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import AutoscaleSettingsOperations, DiagnosticSettingsCategoryOperations, DiagnosticSettingsOperations, ManagementGroupDiagnosticSettingsOperations, PredictiveMetricOperations, SubscriptionDiagnosticSettingsOperations +from .operations import ( + AutoscaleSettingsOperations, + DiagnosticSettingsCategoryOperations, + DiagnosticSettingsOperations, + ManagementGroupDiagnosticSettingsOperations, + PredictiveMetricOperations, + SubscriptionDiagnosticSettingsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar autoscale_settings: AutoscaleSettingsOperations operations @@ -44,9 +51,9 @@ class MonitorManagementClient: :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations :vartype subscription_diagnostic_settings: $(python-base-namespace).v2021_05_01_preview.operations.SubscriptionDiagnosticSettingsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +69,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -88,12 +97,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -102,7 +106,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py index 11ff51a080fe..69fc77da4620 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-05-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py index 288c31769b43..4ebb70bee2d3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py @@ -9,20 +9,27 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import AutoscaleSettingsOperations, DiagnosticSettingsCategoryOperations, DiagnosticSettingsOperations, ManagementGroupDiagnosticSettingsOperations, PredictiveMetricOperations, SubscriptionDiagnosticSettingsOperations +from .operations import ( + AutoscaleSettingsOperations, + DiagnosticSettingsCategoryOperations, + DiagnosticSettingsOperations, + ManagementGroupDiagnosticSettingsOperations, + PredictiveMetricOperations, + SubscriptionDiagnosticSettingsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar autoscale_settings: AutoscaleSettingsOperations operations @@ -44,9 +51,9 @@ class MonitorManagementClient: :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations :vartype subscription_diagnostic_settings: $(python-base-namespace).v2021_05_01_preview.aio.operations.SubscriptionDiagnosticSettingsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,7 +69,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -88,12 +97,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -102,7 +106,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/__init__.py index 1d276a5b9094..8ada5606afee 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/__init__.py @@ -16,13 +16,14 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AutoscaleSettingsOperations', - 'PredictiveMetricOperations', - 'DiagnosticSettingsOperations', - 'DiagnosticSettingsCategoryOperations', - 'ManagementGroupDiagnosticSettingsOperations', - 'SubscriptionDiagnosticSettingsOperations', + "AutoscaleSettingsOperations", + "PredictiveMetricOperations", + "DiagnosticSettingsOperations", + "DiagnosticSettingsCategoryOperations", + "ManagementGroupDiagnosticSettingsOperations", + "SubscriptionDiagnosticSettingsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py index 813176a82244..7a1d8c22f7e1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._autoscale_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._autoscale_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AutoscaleSettingsOperations: """ .. warning:: @@ -43,42 +59,39 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.AutoscaleSettingResourceCollection]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AutoscaleSettingResource"]: """Lists the autoscale settings for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 AutoscaleSettingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either AutoscaleSettingResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -86,15 +99,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -110,10 +119,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,46 +131,110 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, autoscale_setting_name: str, parameters: _models.AutoscaleSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: Union[_models.AutoscaleSettingResource, IO], **kwargs: Any ) -> _models.AutoscaleSettingResource: """Creates or updates an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AutoscaleSettingResource, or the result of cls(response) + :return: AutoscaleSettingResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] - _json = self._serialize.body(parameters, 'AutoscaleSettingResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AutoscaleSettingResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -172,7 +243,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -180,10 +252,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -192,55 +263,49 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - autoscale_setting_name: str, - **kwargs: Any + self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any ) -> None: """Deletes and autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -248,10 +313,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -262,45 +326,39 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - autoscale_setting_name: str, - **kwargs: Any + self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any ) -> _models.AutoscaleSettingResource: """Gets an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource, or the result of cls(response) + :return: AutoscaleSettingResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] - request = build_get_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -308,10 +366,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -319,61 +376,129 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, autoscale_setting_name: str, autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AutoscaleSettingResource: """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. + :param autoscale_setting_resource: Parameters supplied to the operation. Required. :type autoscale_setting_resource: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Required. + :type autoscale_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: Union[_models.AutoscaleSettingResourcePatch, IO], + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Is either a model type + or a IO type. Required. + :type autoscale_setting_resource: + ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AutoscaleSettingResource, or the result of cls(response) + :return: AutoscaleSettingResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] - _json = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(autoscale_setting_resource, (IO, bytes)): + _content = autoscale_setting_resource + else: + _json = self._serialize.body(autoscale_setting_resource, "AutoscaleSettingResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -381,10 +506,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -392,47 +516,42 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.AutoscaleSettingResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AutoscaleSettingResource"]: """Lists the autoscale settings for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either AutoscaleSettingResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -440,14 +559,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -463,10 +579,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -477,8 +591,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py index 05573c513a18..609282fa3e15 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +28,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._diagnostic_settings_category_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DiagnosticSettingsCategoryOperations: """ .. warning:: @@ -43,42 +52,33 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get( - self, - resource_uri: str, - name: str, - **kwargs: Any - ) -> _models.DiagnosticSettingsCategoryResource: + async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResource: """Gets the diagnostic settings category for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsCategoryResource, or the result of cls(response) + :return: DiagnosticSettingsCategoryResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] - request = build_get_request( resource_uri=resource_uri, name=name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -86,10 +86,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -97,50 +96,44 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsCategoryResource', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsCategoryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore - + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore @distributed_trace - def list( - self, - resource_uri: str, - **kwargs: Any - ) -> AsyncIterable[_models.DiagnosticSettingsCategoryResourceCollection]: + def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.DiagnosticSettingsCategoryResource"]: """Lists the diagnostic settings categories for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticSettingsCategoryResourceCollection or - the result of cls(response) + :return: An iterator like instance of either DiagnosticSettingsCategoryResource or the result + of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -148,14 +141,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -171,10 +161,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -185,8 +173,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py index 914c28891bee..afe99c454994 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._diagnostic_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._diagnostic_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DiagnosticSettingsOperations: """ .. warning:: @@ -43,42 +57,33 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get( - self, - resource_uri: str, - name: str, - **kwargs: Any - ) -> _models.DiagnosticSettingsResource: + async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource, or the result of cls(response) + :return: DiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] - request = build_get_request( resource_uri=resource_uri, name=name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -86,10 +91,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -97,51 +101,103 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_uri: str, name: str, parameters: _models.DiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DiagnosticSettingsResource: """Creates or updates diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_uri: str, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. 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: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_uri: str, name: str, parameters: Union[_models.DiagnosticSettingsResource, IO], **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DiagnosticSettingsResource, or the result of cls(response) + :return: DiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'DiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticSettingsResource") request = build_create_or_update_request( resource_uri=resource_uri, @@ -149,7 +205,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -157,10 +214,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -168,51 +224,44 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_uri: str, - name: str, - **kwargs: Any + self, resource_uri: str, name: str, **kwargs: Any ) -> None: """Deletes existing diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_uri=resource_uri, name=name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -220,10 +269,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -234,43 +282,37 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace - def list( - self, - resource_uri: str, - **kwargs: Any - ) -> AsyncIterable[_models.DiagnosticSettingsResourceCollection]: + def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.DiagnosticSettingsResource"]: """Gets the active diagnostic settings list for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticSettingsResourceCollection or the result - of cls(response) + :return: An iterator like instance of either DiagnosticSettingsResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -278,14 +320,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -301,10 +340,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -315,8 +352,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py index 5ec94321acc7..a3fbcc4e4f4c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_group_diagnostic_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._management_group_diagnostic_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementGroupDiagnosticSettingsOperations: """ .. warning:: @@ -43,43 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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, - management_group_id: str, - name: str, - **kwargs: Any + self, management_group_id: str, name: str, **kwargs: Any ) -> _models.ManagementGroupDiagnosticSettingsResource: """Gets the active management group diagnostic settings for the specified resource. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) + :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] - request = build_get_request( management_group_id=management_group_id, name=name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -87,10 +94,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -98,52 +104,117 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + + @overload + async def create_or_update( + self, + management_group_id: str, + name: str, + parameters: _models.ManagementGroupDiagnosticSettingsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementGroupDiagnosticSettingsResource: + """Creates or updates management group diagnostic settings for the specified resource. + + :param management_group_id: The management group id. Required. + :type management_group_id: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: + ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ManagementGroupDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + management_group_id: str, + name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementGroupDiagnosticSettingsResource: + """Creates or updates management group diagnostic settings for the specified resource. + :param management_group_id: The management group id. Required. + :type management_group_id: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. 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: ManagementGroupDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( self, management_group_id: str, name: str, - parameters: _models.ManagementGroupDiagnosticSettingsResource, + parameters: Union[_models.ManagementGroupDiagnosticSettingsResource, IO], **kwargs: Any ) -> _models.ManagementGroupDiagnosticSettingsResource: """Creates or updates management group diagnostic settings for the specified resource. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) + :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementGroupDiagnosticSettingsResource") request = build_create_or_update_request( management_group_id=management_group_id, @@ -151,7 +222,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -159,10 +231,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -170,51 +241,44 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - management_group_id: str, - name: str, - **kwargs: Any + self, management_group_id: str, name: str, **kwargs: Any ) -> None: """Deletes existing management group diagnostic settings for the specified resource. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( management_group_id=management_group_id, name=name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -222,10 +286,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -236,43 +299,39 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + delete.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace def list( - self, - management_group_id: str, - **kwargs: Any - ) -> AsyncIterable[_models.ManagementGroupDiagnosticSettingsResourceCollection]: + self, management_group_id: str, **kwargs: Any + ) -> AsyncIterable["_models.ManagementGroupDiagnosticSettingsResource"]: """Gets the active management group diagnostic settings list for the specified management group. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - ManagementGroupDiagnosticSettingsResourceCollection or the result of cls(response) + :return: An iterator like instance of either ManagementGroupDiagnosticSettingsResource or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -280,14 +339,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - management_group_id=management_group_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -303,10 +359,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -317,8 +371,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py index 6fd294645327..f1cbfdb1f518 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py @@ -9,7 +9,13 @@ import datetime from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +26,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._predictive_metric_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PredictiveMetricOperations: """ .. warning:: @@ -42,7 +50,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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, @@ -58,50 +65,48 @@ async def get( """get predictive autoscale metric future data. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. + 'startDateTime_ISO/endDateTime_ISO'. Required. :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. + :param interval: The interval (i.e. timegrain) of the query. Required. :type interval: ~datetime.timedelta - :param metric_namespace: Metric namespace to query metric definitions for. + :param metric_namespace: Metric namespace to query metric definitions for. Required. :type metric_namespace: str :param metric_name: The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be - **'Metric%2Name1'**. + **'Metric%2Name1'**. Required. :type metric_name: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. + :param aggregation: The list of aggregation types (comma separated) to retrieve. Required. :type aggregation: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PredictiveResponse, or the result of cls(response) + :return: PredictiveResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PredictiveResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PredictiveResponse] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, - api_version=api_version, + subscription_id=self._config.subscription_id, timespan=timespan, interval=interval, metric_namespace=metric_namespace, metric_name=metric_name, aggregation=aggregation, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -109,10 +114,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -120,12 +124,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PredictiveResponse', pipeline_response) + deserialized = self._deserialize("PredictiveResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py index 31539242d922..2b22371ad8e5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._subscription_diagnostic_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._subscription_diagnostic_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SubscriptionDiagnosticSettingsOperations: """ .. warning:: @@ -43,40 +57,32 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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, - name: str, - **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: + async def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResource: """Gets the active subscription diagnostic settings for the specified resource. - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource, or the result of cls(response) + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] - request = build_get_request( - subscription_id=self._config.subscription_id, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -84,10 +90,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,57 +100,109 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, name: str, parameters: _models.SubscriptionDiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SubscriptionDiagnosticSettingsResource: """Creates or updates subscription diagnostic settings for the specified resource. - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. 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: SubscriptionDiagnosticSettingsResource, or the result of cls(response) + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, name: str, parameters: Union[_models.SubscriptionDiagnosticSettingsResource, IO], **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionDiagnosticSettingsResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -153,10 +210,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -164,48 +220,40 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - name: str, - **kwargs: Any - ) -> None: + async def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes existing subscription diagnostic settings for the specified resource. - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -213,10 +261,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -227,40 +274,35 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.SubscriptionDiagnosticSettingsResourceCollection]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SubscriptionDiagnosticSettingsResource"]: """Gets the active subscription diagnostic settings list for the specified subscriptionId. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionDiagnosticSettingsResourceCollection - or the result of cls(response) + :return: An iterator like instance of either SubscriptionDiagnosticSettingsResource or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -268,14 +310,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -291,10 +330,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -305,8 +342,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py index ac607879171c..ddb1ad6b0547 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py @@ -43,69 +43,67 @@ from ._models_py3 import TimeWindow from ._models_py3 import WebhookNotification - -from ._monitor_management_client_enums import ( - CategoryType, - ComparisonOperationType, - CreatedByType, - MetricStatisticType, - PredictiveAutoscalePolicyScaleMode, - RecurrenceFrequency, - ScaleDirection, - ScaleRuleMetricDimensionOperationType, - ScaleType, - TimeAggregationType, -) +from ._monitor_management_client_enums import CategoryType +from ._monitor_management_client_enums import ComparisonOperationType +from ._monitor_management_client_enums import CreatedByType +from ._monitor_management_client_enums import MetricStatisticType +from ._monitor_management_client_enums import PredictiveAutoscalePolicyScaleMode +from ._monitor_management_client_enums import RecurrenceFrequency +from ._monitor_management_client_enums import ScaleDirection +from ._monitor_management_client_enums import ScaleRuleMetricDimensionOperationType +from ._monitor_management_client_enums import ScaleType +from ._monitor_management_client_enums import TimeAggregationType from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AutoscaleErrorResponse', - 'AutoscaleErrorResponseError', - 'AutoscaleNotification', - 'AutoscaleProfile', - 'AutoscaleSettingResource', - 'AutoscaleSettingResourceCollection', - 'AutoscaleSettingResourcePatch', - 'DiagnosticSettingsCategoryResource', - 'DiagnosticSettingsCategoryResourceCollection', - 'DiagnosticSettingsResource', - 'DiagnosticSettingsResourceCollection', - 'EmailNotification', - 'ErrorResponse', - 'LogSettings', - 'ManagementGroupDiagnosticSettingsResource', - 'ManagementGroupDiagnosticSettingsResourceCollection', - 'ManagementGroupLogSettings', - 'MetricSettings', - 'MetricTrigger', - 'PredictiveAutoscalePolicy', - 'PredictiveResponse', - 'PredictiveValue', - 'Recurrence', - 'RecurrentSchedule', - 'Resource', - 'RetentionPolicy', - 'ScaleAction', - 'ScaleCapacity', - 'ScaleRule', - 'ScaleRuleMetricDimension', - 'SubscriptionDiagnosticSettingsResource', - 'SubscriptionDiagnosticSettingsResourceCollection', - 'SubscriptionLogSettings', - 'SystemData', - 'TimeWindow', - 'WebhookNotification', - 'CategoryType', - 'ComparisonOperationType', - 'CreatedByType', - 'MetricStatisticType', - 'PredictiveAutoscalePolicyScaleMode', - 'RecurrenceFrequency', - 'ScaleDirection', - 'ScaleRuleMetricDimensionOperationType', - 'ScaleType', - 'TimeAggregationType', + "AutoscaleErrorResponse", + "AutoscaleErrorResponseError", + "AutoscaleNotification", + "AutoscaleProfile", + "AutoscaleSettingResource", + "AutoscaleSettingResourceCollection", + "AutoscaleSettingResourcePatch", + "DiagnosticSettingsCategoryResource", + "DiagnosticSettingsCategoryResourceCollection", + "DiagnosticSettingsResource", + "DiagnosticSettingsResourceCollection", + "EmailNotification", + "ErrorResponse", + "LogSettings", + "ManagementGroupDiagnosticSettingsResource", + "ManagementGroupDiagnosticSettingsResourceCollection", + "ManagementGroupLogSettings", + "MetricSettings", + "MetricTrigger", + "PredictiveAutoscalePolicy", + "PredictiveResponse", + "PredictiveValue", + "Recurrence", + "RecurrentSchedule", + "Resource", + "RetentionPolicy", + "ScaleAction", + "ScaleCapacity", + "ScaleRule", + "ScaleRuleMetricDimension", + "SubscriptionDiagnosticSettingsResource", + "SubscriptionDiagnosticSettingsResourceCollection", + "SubscriptionLogSettings", + "SystemData", + "TimeWindow", + "WebhookNotification", + "CategoryType", + "ComparisonOperationType", + "CreatedByType", + "MetricStatisticType", + "PredictiveAutoscalePolicyScaleMode", + "RecurrenceFrequency", + "ScaleDirection", + "ScaleRuleMetricDimensionOperationType", + "ScaleType", + "TimeAggregationType", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py index ff45da247f54..5799ba559794 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_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. @@ -9,15 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class AutoscaleErrorResponse(msrest.serialization.Model): +class AutoscaleErrorResponse(_serialization.Model): """Describes the format of Error response. Variables are only populated by the server, and will be ignored when sending a request. @@ -30,31 +30,26 @@ class AutoscaleErrorResponse(msrest.serialization.Model): """ _validation = { - 'system_data': {'readonly': True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'error': {'key': 'error', 'type': 'AutoscaleErrorResponseError'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "error": {"key": "error", "type": "AutoscaleErrorResponseError"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - *, - error: Optional["_models.AutoscaleErrorResponseError"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.AutoscaleErrorResponseError"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleErrorResponseError """ - super(AutoscaleErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error self.system_data = None -class AutoscaleErrorResponseError(msrest.serialization.Model): +class AutoscaleErrorResponseError(_serialization.Model): """The error object. :ivar code: One of a server-defined set of error codes. @@ -68,10 +63,10 @@ class AutoscaleErrorResponseError(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "str"}, } def __init__( @@ -93,14 +88,14 @@ def __init__( :keyword details: A human-readable representation of the error's details. :paramtype details: str """ - super(AutoscaleErrorResponseError, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class AutoscaleNotification(msrest.serialization.Model): +class AutoscaleNotification(_serialization.Model): """Autoscale notification. Variables are only populated by the server, and will be ignored when sending a request. @@ -108,7 +103,7 @@ class AutoscaleNotification(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar operation: the operation associated with the notification and its value must be "scale". - Has constant value: "Scale". + Required. Default value is "Scale". :vartype operation: str :ivar email: the email notification. :vartype email: ~$(python-base-namespace).v2021_05_01_preview.models.EmailNotification @@ -118,13 +113,13 @@ class AutoscaleNotification(msrest.serialization.Model): """ _validation = { - 'operation': {'required': True, 'constant': True}, + "operation": {"required": True, "constant": True}, } _attribute_map = { - 'operation': {'key': 'operation', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'EmailNotification'}, - 'webhooks': {'key': 'webhooks', 'type': '[WebhookNotification]'}, + "operation": {"key": "operation", "type": "str"}, + "email": {"key": "email", "type": "EmailNotification"}, + "webhooks": {"key": "webhooks", "type": "[WebhookNotification]"}, } operation = "Scale" @@ -143,22 +138,22 @@ def __init__( :paramtype webhooks: list[~$(python-base-namespace).v2021_05_01_preview.models.WebhookNotification] """ - super(AutoscaleNotification, self).__init__(**kwargs) + super().__init__(**kwargs) self.email = email self.webhooks = webhooks -class AutoscaleProfile(msrest.serialization.Model): +class AutoscaleProfile(_serialization.Model): """Autoscale profile. All required parameters must be populated in order to send to Azure. - :ivar name: Required. the name of the profile. + :ivar name: the name of the profile. Required. :vartype name: str - :ivar capacity: Required. the number of instances that can be used during this profile. + :ivar capacity: the number of instances that can be used during this profile. Required. :vartype capacity: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleCapacity - :ivar rules: Required. the collection of rules that provide the triggers and parameters for the - scaling action. A maximum of 10 rules can be specified. + :ivar rules: the collection of rules that provide the triggers and parameters for the scaling + action. A maximum of 10 rules can be specified. Required. :vartype rules: list[~$(python-base-namespace).v2021_05_01_preview.models.ScaleRule] :ivar fixed_date: the specific date-time for the profile. This element is not used if the Recurrence element is used. @@ -169,17 +164,17 @@ class AutoscaleProfile(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'capacity': {'required': True}, - 'rules': {'required': True}, + "name": {"required": True}, + "capacity": {"required": True}, + "rules": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'ScaleCapacity'}, - 'rules': {'key': 'rules', 'type': '[ScaleRule]'}, - 'fixed_date': {'key': 'fixedDate', 'type': 'TimeWindow'}, - 'recurrence': {'key': 'recurrence', 'type': 'Recurrence'}, + "name": {"key": "name", "type": "str"}, + "capacity": {"key": "capacity", "type": "ScaleCapacity"}, + "rules": {"key": "rules", "type": "[ScaleRule]"}, + "fixed_date": {"key": "fixedDate", "type": "TimeWindow"}, + "recurrence": {"key": "recurrence", "type": "Recurrence"}, } def __init__( @@ -193,12 +188,12 @@ def __init__( **kwargs ): """ - :keyword name: Required. the name of the profile. + :keyword name: the name of the profile. Required. :paramtype name: str - :keyword capacity: Required. the number of instances that can be used during this profile. + :keyword capacity: the number of instances that can be used during this profile. Required. :paramtype capacity: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleCapacity - :keyword rules: Required. the collection of rules that provide the triggers and parameters for - the scaling action. A maximum of 10 rules can be specified. + :keyword rules: the collection of rules that provide the triggers and parameters for the + scaling action. A maximum of 10 rules can be specified. Required. :paramtype rules: list[~$(python-base-namespace).v2021_05_01_preview.models.ScaleRule] :keyword fixed_date: the specific date-time for the profile. This element is not used if the Recurrence element is used. @@ -207,7 +202,7 @@ def __init__( if the FixedDate element is used. :paramtype recurrence: ~$(python-base-namespace).v2021_05_01_preview.models.Recurrence """ - super(AutoscaleProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.capacity = capacity self.rules = rules @@ -215,7 +210,7 @@ def __init__( self.recurrence = recurrence -class AutoscaleSettingResource(msrest.serialization.Model): +class AutoscaleSettingResource(_serialization.Model): # pylint: disable=too-many-instance-attributes """The autoscale setting resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -228,17 +223,17 @@ class AutoscaleSettingResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar system_data: The system metadata related to the response. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - :ivar profiles: Required. the collection of automatic scaling profiles that specify different - scaling parameters for different time periods. A maximum of 20 profiles can be specified. + :ivar profiles: the collection of automatic scaling profiles that specify different scaling + parameters for different time periods. A maximum of 20 profiles can be specified. Required. :vartype profiles: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] :ivar notifications: the collection of notifications. :vartype notifications: @@ -260,28 +255,31 @@ class AutoscaleSettingResource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'profiles': {'required': True, 'max_items': 20, 'min_items': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "profiles": {"required": True, "max_items": 20, "min_items": 0}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'profiles': {'key': 'properties.profiles', 'type': '[AutoscaleProfile]'}, - 'notifications': {'key': 'properties.notifications', 'type': '[AutoscaleNotification]'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'predictive_autoscale_policy': {'key': 'properties.predictiveAutoscalePolicy', 'type': 'PredictiveAutoscalePolicy'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'target_resource_uri': {'key': 'properties.targetResourceUri', 'type': 'str'}, - 'target_resource_location': {'key': 'properties.targetResourceLocation', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "profiles": {"key": "properties.profiles", "type": "[AutoscaleProfile]"}, + "notifications": {"key": "properties.notifications", "type": "[AutoscaleNotification]"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "predictive_autoscale_policy": { + "key": "properties.predictiveAutoscalePolicy", + "type": "PredictiveAutoscalePolicy", + }, + "name_properties_name": {"key": "properties.name", "type": "str"}, + "target_resource_uri": {"key": "properties.targetResourceUri", "type": "str"}, + "target_resource_location": {"key": "properties.targetResourceLocation", "type": "str"}, } def __init__( @@ -291,7 +289,7 @@ def __init__( profiles: List["_models.AutoscaleProfile"], tags: Optional[Dict[str, str]] = None, notifications: Optional[List["_models.AutoscaleNotification"]] = None, - enabled: Optional[bool] = False, + enabled: bool = False, predictive_autoscale_policy: Optional["_models.PredictiveAutoscalePolicy"] = None, name_properties_name: Optional[str] = None, target_resource_uri: Optional[str] = None, @@ -299,16 +297,15 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] - :keyword profiles: Required. the collection of automatic scaling profiles that specify - different scaling parameters for different time periods. A maximum of 20 profiles can be - specified. + :keyword profiles: the collection of automatic scaling profiles that specify different scaling + parameters for different time periods. A maximum of 20 profiles can be specified. Required. :paramtype profiles: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] :keyword notifications: the collection of notifications. @@ -329,7 +326,7 @@ def __init__( should be added to. :paramtype target_resource_location: str """ - super(AutoscaleSettingResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -345,12 +342,12 @@ def __init__( self.target_resource_location = target_resource_location -class AutoscaleSettingResourceCollection(msrest.serialization.Model): +class AutoscaleSettingResourceCollection(_serialization.Model): """Represents a collection of autoscale setting resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. the values for the autoscale setting resources. + :ivar value: the values for the autoscale setting resources. Required. :vartype value: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource] :ivar next_link: URL to get the next set of results. @@ -358,37 +355,31 @@ class AutoscaleSettingResourceCollection(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[AutoscaleSettingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AutoscaleSettingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["_models.AutoscaleSettingResource"], - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs): """ - :keyword value: Required. the values for the autoscale setting resources. + :keyword value: the values for the autoscale setting resources. Required. :paramtype value: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource] :keyword next_link: URL to get the next set of results. :paramtype next_link: str """ - super(AutoscaleSettingResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class AutoscaleSettingResourcePatch(msrest.serialization.Model): +class AutoscaleSettingResourcePatch(_serialization.Model): """The autoscale setting object for patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar profiles: the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. @@ -413,18 +404,21 @@ class AutoscaleSettingResourcePatch(msrest.serialization.Model): """ _validation = { - 'profiles': {'max_items': 20, 'min_items': 0}, + "profiles": {"max_items": 20, "min_items": 0}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'profiles': {'key': 'properties.profiles', 'type': '[AutoscaleProfile]'}, - 'notifications': {'key': 'properties.notifications', 'type': '[AutoscaleNotification]'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'predictive_autoscale_policy': {'key': 'properties.predictiveAutoscalePolicy', 'type': 'PredictiveAutoscalePolicy'}, - 'name': {'key': 'properties.name', 'type': 'str'}, - 'target_resource_uri': {'key': 'properties.targetResourceUri', 'type': 'str'}, - 'target_resource_location': {'key': 'properties.targetResourceLocation', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "profiles": {"key": "properties.profiles", "type": "[AutoscaleProfile]"}, + "notifications": {"key": "properties.notifications", "type": "[AutoscaleNotification]"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "predictive_autoscale_policy": { + "key": "properties.predictiveAutoscalePolicy", + "type": "PredictiveAutoscalePolicy", + }, + "name": {"key": "properties.name", "type": "str"}, + "target_resource_uri": {"key": "properties.targetResourceUri", "type": "str"}, + "target_resource_location": {"key": "properties.targetResourceLocation", "type": "str"}, } def __init__( @@ -433,7 +427,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, profiles: Optional[List["_models.AutoscaleProfile"]] = None, notifications: Optional[List["_models.AutoscaleNotification"]] = None, - enabled: Optional[bool] = False, + enabled: bool = False, predictive_autoscale_policy: Optional["_models.PredictiveAutoscalePolicy"] = None, name: Optional[str] = None, target_resource_uri: Optional[str] = None, @@ -441,7 +435,7 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword profiles: the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. @@ -465,7 +459,7 @@ def __init__( should be added to. :paramtype target_resource_location: str """ - super(AutoscaleSettingResourcePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.profiles = profiles self.notifications = notifications @@ -476,7 +470,7 @@ def __init__( self.target_resource_location = target_resource_location -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -492,24 +486,20 @@ class Resource(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(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -530,8 +520,8 @@ class DiagnosticSettingsCategoryResource(Resource): :vartype type: str :ivar system_data: The system metadata related to this resource. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - :ivar category_type: The type of the diagnostic settings category. Known values are: "Metrics", - "Logs". + :ivar category_type: The type of the diagnostic settings category. Known values are: "Metrics" + and "Logs". :vartype category_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CategoryType :ivar category_groups: the collection of what category groups are supported. @@ -539,19 +529,19 @@ class DiagnosticSettingsCategoryResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "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'}, - 'category_type': {'key': 'properties.categoryType', 'type': 'str'}, - 'category_groups': {'key': 'properties.categoryGroups', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "category_type": {"key": "properties.categoryType", "type": "str"}, + "category_groups": {"key": "properties.categoryGroups", "type": "[str]"}, } def __init__( @@ -563,19 +553,19 @@ def __init__( ): """ :keyword category_type: The type of the diagnostic settings category. Known values are: - "Metrics", "Logs". + "Metrics" and "Logs". :paramtype category_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CategoryType :keyword category_groups: the collection of what category groups are supported. :paramtype category_groups: list[str] """ - super(DiagnosticSettingsCategoryResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.category_type = category_type self.category_groups = category_groups -class DiagnosticSettingsCategoryResourceCollection(msrest.serialization.Model): +class DiagnosticSettingsCategoryResourceCollection(_serialization.Model): """Represents a collection of diagnostic setting category resources. :ivar value: The collection of diagnostic settings category resources. @@ -584,25 +574,20 @@ class DiagnosticSettingsCategoryResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DiagnosticSettingsCategoryResource]'}, + "value": {"key": "value", "type": "[DiagnosticSettingsCategoryResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.DiagnosticSettingsCategoryResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DiagnosticSettingsCategoryResource"]] = None, **kwargs): """ :keyword value: The collection of diagnostic settings category resources. :paramtype value: list[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResource] """ - super(DiagnosticSettingsCategoryResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DiagnosticSettingsResource(Resource): +class DiagnosticSettingsResource(Resource): # pylint: disable=too-many-instance-attributes """The diagnostic setting resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -647,26 +632,26 @@ class DiagnosticSettingsResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "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'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'event_hub_name': {'key': 'properties.eventHubName', 'type': 'str'}, - 'metrics': {'key': 'properties.metrics', 'type': '[MetricSettings]'}, - 'logs': {'key': 'properties.logs', 'type': '[LogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, - 'marketplace_partner_id': {'key': 'properties.marketplacePartnerId', 'type': 'str'}, - 'log_analytics_destination_type': {'key': 'properties.logAnalyticsDestinationType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, + "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, + "metrics": {"key": "properties.metrics", "type": "[MetricSettings]"}, + "logs": {"key": "properties.logs", "type": "[LogSettings]"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, + "marketplace_partner_id": {"key": "properties.marketplacePartnerId", "type": "str"}, + "log_analytics_destination_type": {"key": "properties.logAnalyticsDestinationType", "type": "str"}, } def __init__( @@ -712,7 +697,7 @@ def __init__( name>`. Possible values are: Dedicated and null (null is default.). :paramtype log_analytics_destination_type: str """ - super(DiagnosticSettingsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id @@ -725,7 +710,7 @@ def __init__( self.log_analytics_destination_type = log_analytics_destination_type -class DiagnosticSettingsResourceCollection(msrest.serialization.Model): +class DiagnosticSettingsResourceCollection(_serialization.Model): """Represents a collection of alert rule resources. :ivar value: The collection of diagnostic settings resources;. @@ -734,25 +719,20 @@ class DiagnosticSettingsResourceCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DiagnosticSettingsResource]'}, + "value": {"key": "value", "type": "[DiagnosticSettingsResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.DiagnosticSettingsResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DiagnosticSettingsResource"]] = None, **kwargs): """ :keyword value: The collection of diagnostic settings resources;. :paramtype value: list[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource] """ - super(DiagnosticSettingsResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class EmailNotification(msrest.serialization.Model): +class EmailNotification(_serialization.Model): """Email notification of an autoscale event. :ivar send_to_subscription_administrator: a value indicating whether to send email to @@ -767,16 +747,16 @@ class EmailNotification(msrest.serialization.Model): """ _attribute_map = { - 'send_to_subscription_administrator': {'key': 'sendToSubscriptionAdministrator', 'type': 'bool'}, - 'send_to_subscription_co_administrators': {'key': 'sendToSubscriptionCoAdministrators', 'type': 'bool'}, - 'custom_emails': {'key': 'customEmails', 'type': '[str]'}, + "send_to_subscription_administrator": {"key": "sendToSubscriptionAdministrator", "type": "bool"}, + "send_to_subscription_co_administrators": {"key": "sendToSubscriptionCoAdministrators", "type": "bool"}, + "custom_emails": {"key": "customEmails", "type": "[str]"}, } def __init__( self, *, - send_to_subscription_administrator: Optional[bool] = False, - send_to_subscription_co_administrators: Optional[bool] = False, + send_to_subscription_administrator: bool = False, + send_to_subscription_co_administrators: bool = False, custom_emails: Optional[List[str]] = None, **kwargs ): @@ -791,13 +771,13 @@ def __init__( this attribute will be ignored. :paramtype custom_emails: list[str] """ - super(EmailNotification, self).__init__(**kwargs) + super().__init__(**kwargs) self.send_to_subscription_administrator = send_to_subscription_administrator self.send_to_subscription_co_administrators = send_to_subscription_co_administrators self.custom_emails = custom_emails -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -807,29 +787,23 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class LogSettings(msrest.serialization.Model): +class LogSettings(_serialization.Model): """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. All required parameters must be populated in order to send to Azure. @@ -842,21 +816,21 @@ class LogSettings(msrest.serialization.Model): is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. :vartype category_group: str - :ivar enabled: Required. a value indicating whether this log is enabled. + :ivar enabled: a value indicating whether this log is enabled. Required. :vartype enabled: bool :ivar retention_policy: the retention policy for this log. :vartype retention_policy: ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy """ _validation = { - 'enabled': {'required': True}, + "enabled": {"required": True}, } _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'category_group': {'key': 'categoryGroup', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, + "category": {"key": "category", "type": "str"}, + "category_group": {"key": "categoryGroup", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, } def __init__( @@ -877,20 +851,20 @@ def __init__( setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. :paramtype category_group: str - :keyword enabled: Required. a value indicating whether this log is enabled. + :keyword enabled: a value indicating whether this log is enabled. Required. :paramtype enabled: bool :keyword retention_policy: the retention policy for this log. :paramtype retention_policy: ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy """ - super(LogSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.category = category self.category_group = category_group self.enabled = enabled self.retention_policy = retention_policy -class ManagementGroupDiagnosticSettingsResource(Resource): +class ManagementGroupDiagnosticSettingsResource(Resource): # pylint: disable=too-many-instance-attributes """The management group diagnostic setting resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -929,24 +903,24 @@ class ManagementGroupDiagnosticSettingsResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "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'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'event_hub_name': {'key': 'properties.eventHubName', 'type': 'str'}, - 'logs': {'key': 'properties.logs', 'type': '[ManagementGroupLogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, - 'marketplace_partner_id': {'key': 'properties.marketplacePartnerId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, + "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, + "logs": {"key": "properties.logs", "type": "[ManagementGroupLogSettings]"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, + "marketplace_partner_id": {"key": "properties.marketplacePartnerId", "type": "str"}, } def __init__( @@ -984,7 +958,7 @@ def __init__( you would like to send Diagnostic Logs. :paramtype marketplace_partner_id: str """ - super(ManagementGroupDiagnosticSettingsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id @@ -995,7 +969,7 @@ def __init__( self.marketplace_partner_id = marketplace_partner_id -class ManagementGroupDiagnosticSettingsResourceCollection(msrest.serialization.Model): +class ManagementGroupDiagnosticSettingsResourceCollection(_serialization.Model): """Represents a collection of management group diagnostic settings resources. :ivar value: The collection of management group diagnostic settings resources. @@ -1004,25 +978,20 @@ class ManagementGroupDiagnosticSettingsResourceCollection(msrest.serialization.M """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ManagementGroupDiagnosticSettingsResource]'}, + "value": {"key": "value", "type": "[ManagementGroupDiagnosticSettingsResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ManagementGroupDiagnosticSettingsResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ManagementGroupDiagnosticSettingsResource"]] = None, **kwargs): """ :keyword value: The collection of management group diagnostic settings resources. :paramtype value: list[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource] """ - super(ManagementGroupDiagnosticSettingsResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ManagementGroupLogSettings(msrest.serialization.Model): +class ManagementGroupLogSettings(_serialization.Model): """Part of Management Group diagnostic setting. Specifies the settings for a particular log. All required parameters must be populated in order to send to Azure. @@ -1033,27 +1002,22 @@ class ManagementGroupLogSettings(msrest.serialization.Model): :ivar category_group: Name of a Management Group Diagnostic Log category group for a resource type this setting is applied to. :vartype category_group: str - :ivar enabled: Required. a value indicating whether this log is enabled. + :ivar enabled: a value indicating whether this log is enabled. Required. :vartype enabled: bool """ _validation = { - 'enabled': {'required': True}, + "enabled": {"required": True}, } _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'category_group': {'key': 'categoryGroup', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "category": {"key": "category", "type": "str"}, + "category_group": {"key": "categoryGroup", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, } def __init__( - self, - *, - enabled: bool, - category: Optional[str] = None, - category_group: Optional[str] = None, - **kwargs + self, *, enabled: bool, category: Optional[str] = None, category_group: Optional[str] = None, **kwargs ): """ :keyword category: Name of a Management Group Diagnostic Log category for a resource type this @@ -1062,16 +1026,16 @@ def __init__( :keyword category_group: Name of a Management Group Diagnostic Log category group for a resource type this setting is applied to. :paramtype category_group: str - :keyword enabled: Required. a value indicating whether this log is enabled. + :keyword enabled: a value indicating whether this log is enabled. Required. :paramtype enabled: bool """ - super(ManagementGroupLogSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.category = category self.category_group = category_group self.enabled = enabled -class MetricSettings(msrest.serialization.Model): +class MetricSettings(_serialization.Model): """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. All required parameters must be populated in order to send to Azure. @@ -1082,21 +1046,21 @@ class MetricSettings(msrest.serialization.Model): applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation. :vartype category: str - :ivar enabled: Required. a value indicating whether this category is enabled. + :ivar enabled: a value indicating whether this category is enabled. Required. :vartype enabled: bool :ivar retention_policy: the retention policy for this category. :vartype retention_policy: ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy """ _validation = { - 'enabled': {'required': True}, + "enabled": {"required": True}, } _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, + "time_grain": {"key": "timeGrain", "type": "duration"}, + "category": {"key": "category", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, } def __init__( @@ -1115,55 +1079,55 @@ def __init__( applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation. :paramtype category: str - :keyword enabled: Required. a value indicating whether this category is enabled. + :keyword enabled: a value indicating whether this category is enabled. Required. :paramtype enabled: bool :keyword retention_policy: the retention policy for this category. :paramtype retention_policy: ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy """ - super(MetricSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_grain = time_grain self.category = category self.enabled = enabled self.retention_policy = retention_policy -class MetricTrigger(msrest.serialization.Model): +class MetricTrigger(_serialization.Model): # pylint: disable=too-many-instance-attributes """The trigger that results in a scaling action. All required parameters must be populated in order to send to Azure. - :ivar metric_name: Required. the name of the metric that defines what the rule monitors. + :ivar metric_name: the name of the metric that defines what the rule monitors. Required. :vartype metric_name: str :ivar metric_namespace: the namespace of the metric that defines what the rule monitors. :vartype metric_namespace: str - :ivar metric_resource_uri: Required. the resource identifier of the resource the rule monitors. + :ivar metric_resource_uri: the resource identifier of the resource the rule monitors. Required. :vartype metric_resource_uri: str :ivar metric_resource_location: the location of the resource the rule monitors. :vartype metric_resource_location: str - :ivar time_grain: Required. the granularity of metrics the rule monitors. Must be one of the - predefined values returned from metric definitions for the metric. Must be between 12 hours and - 1 minute. + :ivar time_grain: the granularity of metrics the rule monitors. Must be one of the predefined + values returned from metric definitions for the metric. Must be between 12 hours and 1 minute. + Required. :vartype time_grain: ~datetime.timedelta - :ivar statistic: Required. the metric statistic type. How the metrics from multiple instances - are combined. Known values are: "Average", "Min", "Max", "Sum", "Count". + :ivar statistic: the metric statistic type. How the metrics from multiple instances are + combined. Required. Known values are: "Average", "Min", "Max", "Sum", and "Count". :vartype statistic: str or ~$(python-base-namespace).v2021_05_01_preview.models.MetricStatisticType - :ivar time_window: Required. the range of time in which instance data is collected. This value - must be greater than the delay in metric collection, which can vary from resource-to-resource. - Must be between 12 hours and 5 minutes. + :ivar time_window: the range of time in which instance data is collected. This value must be + greater than the delay in metric collection, which can vary from resource-to-resource. Must be + between 12 hours and 5 minutes. Required. :vartype time_window: ~datetime.timedelta - :ivar time_aggregation: Required. time aggregation type. How the data that is collected should - be combined over time. The default value is Average. Known values are: "Average", "Minimum", - "Maximum", "Total", "Count", "Last". + :ivar time_aggregation: time aggregation type. How the data that is collected should be + combined over time. The default value is Average. Required. Known values are: "Average", + "Minimum", "Maximum", "Total", "Count", and "Last". :vartype time_aggregation: str or ~$(python-base-namespace).v2021_05_01_preview.models.TimeAggregationType - :ivar operator: Required. the operator that is used to compare the metric data and the - threshold. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", - "LessThan", "LessThanOrEqual". + :ivar operator: the operator that is used to compare the metric data and the threshold. + Required. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + "LessThan", and "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2021_05_01_preview.models.ComparisonOperationType - :ivar threshold: Required. the threshold of the metric that triggers the scale action. + :ivar threshold: the threshold of the metric that triggers the scale action. Required. :vartype threshold: float :ivar dimensions: List of dimension conditions. For example: [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. @@ -1174,29 +1138,29 @@ class MetricTrigger(msrest.serialization.Model): """ _validation = { - 'metric_name': {'required': True}, - 'metric_resource_uri': {'required': True}, - 'time_grain': {'required': True}, - 'statistic': {'required': True}, - 'time_window': {'required': True}, - 'time_aggregation': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, + "metric_name": {"required": True}, + "metric_resource_uri": {"required": True}, + "time_grain": {"required": True}, + "statistic": {"required": True}, + "time_window": {"required": True}, + "time_aggregation": {"required": True}, + "operator": {"required": True}, + "threshold": {"required": True}, } _attribute_map = { - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'metric_resource_uri': {'key': 'metricResourceUri', 'type': 'str'}, - 'metric_resource_location': {'key': 'metricResourceLocation', 'type': 'str'}, - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'statistic': {'key': 'statistic', 'type': 'str'}, - 'time_window': {'key': 'timeWindow', 'type': 'duration'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'dimensions': {'key': 'dimensions', 'type': '[ScaleRuleMetricDimension]'}, - 'divide_per_instance': {'key': 'dividePerInstance', 'type': 'bool'}, + "metric_name": {"key": "metricName", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "metric_resource_uri": {"key": "metricResourceUri", "type": "str"}, + "metric_resource_location": {"key": "metricResourceLocation", "type": "str"}, + "time_grain": {"key": "timeGrain", "type": "duration"}, + "statistic": {"key": "statistic", "type": "str"}, + "time_window": {"key": "timeWindow", "type": "duration"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "dimensions": {"key": "dimensions", "type": "[ScaleRuleMetricDimension]"}, + "divide_per_instance": {"key": "dividePerInstance", "type": "bool"}, } def __init__( @@ -1217,38 +1181,38 @@ def __init__( **kwargs ): """ - :keyword metric_name: Required. the name of the metric that defines what the rule monitors. + :keyword metric_name: the name of the metric that defines what the rule monitors. Required. :paramtype metric_name: str :keyword metric_namespace: the namespace of the metric that defines what the rule monitors. :paramtype metric_namespace: str - :keyword metric_resource_uri: Required. the resource identifier of the resource the rule - monitors. + :keyword metric_resource_uri: the resource identifier of the resource the rule monitors. + Required. :paramtype metric_resource_uri: str :keyword metric_resource_location: the location of the resource the rule monitors. :paramtype metric_resource_location: str - :keyword time_grain: Required. the granularity of metrics the rule monitors. Must be one of the + :keyword time_grain: the granularity of metrics the rule monitors. Must be one of the predefined values returned from metric definitions for the metric. Must be between 12 hours and - 1 minute. + 1 minute. Required. :paramtype time_grain: ~datetime.timedelta - :keyword statistic: Required. the metric statistic type. How the metrics from multiple - instances are combined. Known values are: "Average", "Min", "Max", "Sum", "Count". + :keyword statistic: the metric statistic type. How the metrics from multiple instances are + combined. Required. Known values are: "Average", "Min", "Max", "Sum", and "Count". :paramtype statistic: str or ~$(python-base-namespace).v2021_05_01_preview.models.MetricStatisticType - :keyword time_window: Required. the range of time in which instance data is collected. This - value must be greater than the delay in metric collection, which can vary from - resource-to-resource. Must be between 12 hours and 5 minutes. + :keyword time_window: the range of time in which instance data is collected. This value must be + greater than the delay in metric collection, which can vary from resource-to-resource. Must be + between 12 hours and 5 minutes. Required. :paramtype time_window: ~datetime.timedelta - :keyword time_aggregation: Required. time aggregation type. How the data that is collected - should be combined over time. The default value is Average. Known values are: "Average", - "Minimum", "Maximum", "Total", "Count", "Last". + :keyword time_aggregation: time aggregation type. How the data that is collected should be + combined over time. The default value is Average. Required. Known values are: "Average", + "Minimum", "Maximum", "Total", "Count", and "Last". :paramtype time_aggregation: str or ~$(python-base-namespace).v2021_05_01_preview.models.TimeAggregationType - :keyword operator: Required. the operator that is used to compare the metric data and the - threshold. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", - "LessThan", "LessThanOrEqual". + :keyword operator: the operator that is used to compare the metric data and the threshold. + Required. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + "LessThan", and "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2021_05_01_preview.models.ComparisonOperationType - :keyword threshold: Required. the threshold of the metric that triggers the scale action. + :keyword threshold: the threshold of the metric that triggers the scale action. Required. :paramtype threshold: float :keyword dimensions: List of dimension conditions. For example: [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. @@ -1257,7 +1221,7 @@ def __init__( :keyword divide_per_instance: a value indicating whether metric should divide per instance. :paramtype divide_per_instance: bool """ - super(MetricTrigger, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_name = metric_name self.metric_namespace = metric_namespace self.metric_resource_uri = metric_resource_uri @@ -1272,13 +1236,13 @@ def __init__( self.divide_per_instance = divide_per_instance -class PredictiveAutoscalePolicy(msrest.serialization.Model): +class PredictiveAutoscalePolicy(_serialization.Model): """The parameters for enabling predictive autoscale. All required parameters must be populated in order to send to Azure. - :ivar scale_mode: Required. the predictive autoscale mode. Known values are: "Disabled", - "ForecastOnly", "Enabled". + :ivar scale_mode: the predictive autoscale mode. Required. Known values are: "Disabled", + "ForecastOnly", and "Enabled". :vartype scale_mode: str or ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicyScaleMode :ivar scale_look_ahead_time: the amount of time to specify by which instances are launched in @@ -1287,12 +1251,12 @@ class PredictiveAutoscalePolicy(msrest.serialization.Model): """ _validation = { - 'scale_mode': {'required': True}, + "scale_mode": {"required": True}, } _attribute_map = { - 'scale_mode': {'key': 'scaleMode', 'type': 'str'}, - 'scale_look_ahead_time': {'key': 'scaleLookAheadTime', 'type': 'duration'}, + "scale_mode": {"key": "scaleMode", "type": "str"}, + "scale_look_ahead_time": {"key": "scaleLookAheadTime", "type": "duration"}, } def __init__( @@ -1303,20 +1267,20 @@ def __init__( **kwargs ): """ - :keyword scale_mode: Required. the predictive autoscale mode. Known values are: "Disabled", - "ForecastOnly", "Enabled". + :keyword scale_mode: the predictive autoscale mode. Required. Known values are: "Disabled", + "ForecastOnly", and "Enabled". :paramtype scale_mode: str or ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicyScaleMode :keyword scale_look_ahead_time: the amount of time to specify by which instances are launched in advance. It must be between 1 minute and 60 minutes in ISO 8601 format. :paramtype scale_look_ahead_time: ~datetime.timedelta """ - super(PredictiveAutoscalePolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.scale_mode = scale_mode self.scale_look_ahead_time = scale_look_ahead_time -class PredictiveResponse(msrest.serialization.Model): +class PredictiveResponse(_serialization.Model): """The response to a metrics query. :ivar timespan: The timespan for which the data was retrieved. Its value consists of two @@ -1336,11 +1300,11 @@ class PredictiveResponse(msrest.serialization.Model): """ _attribute_map = { - 'timespan': {'key': 'timespan', 'type': 'str'}, - 'interval': {'key': 'interval', 'type': 'duration'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'target_resource_id': {'key': 'targetResourceId', 'type': 'str'}, - 'data': {'key': 'data', 'type': '[PredictiveValue]'}, + "timespan": {"key": "timespan", "type": "str"}, + "interval": {"key": "interval", "type": "duration"}, + "metric_name": {"key": "metricName", "type": "str"}, + "target_resource_id": {"key": "targetResourceId", "type": "str"}, + "data": {"key": "data", "type": "[PredictiveValue]"}, } def __init__( @@ -1369,7 +1333,7 @@ def __init__( :keyword data: the value of the collection. :paramtype data: list[~$(python-base-namespace).v2021_05_01_preview.models.PredictiveValue] """ - super(PredictiveResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.timespan = timespan self.interval = interval self.metric_name = metric_name @@ -1377,116 +1341,106 @@ def __init__( self.data = data -class PredictiveValue(msrest.serialization.Model): +class PredictiveValue(_serialization.Model): """Represents a predictive metric value in the given bucket. All required parameters must be populated in order to send to Azure. - :ivar time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :ivar time_stamp: the timestamp for the metric value in ISO 8601 format. Required. :vartype time_stamp: ~datetime.datetime - :ivar value: Required. Predictive value in this time bucket. + :ivar value: Predictive value in this time bucket. Required. :vartype value: float """ _validation = { - 'time_stamp': {'required': True}, - 'value': {'required': True}, + "time_stamp": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'value': {'key': 'value', 'type': 'float'}, + "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, + "value": {"key": "value", "type": "float"}, } - def __init__( - self, - *, - time_stamp: datetime.datetime, - value: float, - **kwargs - ): + def __init__(self, *, time_stamp: datetime.datetime, value: float, **kwargs): """ - :keyword time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. :paramtype time_stamp: ~datetime.datetime - :keyword value: Required. Predictive value in this time bucket. + :keyword value: Predictive value in this time bucket. Required. :paramtype value: float """ - super(PredictiveValue, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_stamp = time_stamp self.value = value -class Recurrence(msrest.serialization.Model): +class Recurrence(_serialization.Model): """The repeating times at which this profile begins. This element is not used if the FixedDate element is used. All required parameters must be populated in order to send to Azure. - :ivar frequency: Required. the recurrence frequency. How often the schedule profile should take - effect. This value must be Week, meaning each week will have the same set of profiles. For - example, to set a daily schedule, set **schedule** to every day of the week. The frequency - property specifies that the schedule is repeated weekly. Known values are: "None", "Second", - "Minute", "Hour", "Day", "Week", "Month", "Year". + :ivar frequency: the recurrence frequency. How often the schedule profile should take effect. + This value must be Week, meaning each week will have the same set of profiles. For example, to + set a daily schedule, set **schedule** to every day of the week. The frequency property + specifies that the schedule is repeated weekly. Required. Known values are: "None", "Second", + "Minute", "Hour", "Day", "Week", "Month", and "Year". :vartype frequency: str or ~$(python-base-namespace).v2021_05_01_preview.models.RecurrenceFrequency - :ivar schedule: Required. the scheduling constraints for when the profile begins. + :ivar schedule: the scheduling constraints for when the profile begins. Required. :vartype schedule: ~$(python-base-namespace).v2021_05_01_preview.models.RecurrentSchedule """ _validation = { - 'frequency': {'required': True}, - 'schedule': {'required': True}, + "frequency": {"required": True}, + "schedule": {"required": True}, } _attribute_map = { - 'frequency': {'key': 'frequency', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'RecurrentSchedule'}, + "frequency": {"key": "frequency", "type": "str"}, + "schedule": {"key": "schedule", "type": "RecurrentSchedule"}, } def __init__( - self, - *, - frequency: Union[str, "_models.RecurrenceFrequency"], - schedule: "_models.RecurrentSchedule", - **kwargs + self, *, frequency: Union[str, "_models.RecurrenceFrequency"], schedule: "_models.RecurrentSchedule", **kwargs ): """ - :keyword frequency: Required. the recurrence frequency. How often the schedule profile should - take effect. This value must be Week, meaning each week will have the same set of profiles. For + :keyword frequency: the recurrence frequency. How often the schedule profile should take + effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency - property specifies that the schedule is repeated weekly. Known values are: "None", "Second", - "Minute", "Hour", "Day", "Week", "Month", "Year". + property specifies that the schedule is repeated weekly. Required. Known values are: "None", + "Second", "Minute", "Hour", "Day", "Week", "Month", and "Year". :paramtype frequency: str or ~$(python-base-namespace).v2021_05_01_preview.models.RecurrenceFrequency - :keyword schedule: Required. the scheduling constraints for when the profile begins. + :keyword schedule: the scheduling constraints for when the profile begins. Required. :paramtype schedule: ~$(python-base-namespace).v2021_05_01_preview.models.RecurrentSchedule """ - super(Recurrence, self).__init__(**kwargs) + super().__init__(**kwargs) self.frequency = frequency self.schedule = schedule -class RecurrentSchedule(msrest.serialization.Model): +class RecurrentSchedule(_serialization.Model): """The scheduling constraints for when the profile begins. All required parameters must be populated in order to send to Azure. - :ivar time_zone: Required. the timezone for the hours of the profile. Some examples of valid - time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, - Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain - Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard - Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, - Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard - Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, - Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina - Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, - Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde - Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. - Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European - Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, - GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. - Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, - Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, - Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + :ivar time_zone: the timezone for the hours of the profile. Some examples of valid time zones + are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific + Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard + Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, + Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern + Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, + Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific SA + Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina Standard + Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, Bahia + Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard + Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe + Standard Time, Central Europe Standard Time, Romance Standard Time, Central European Standard + Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, GTB + Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe + Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel + Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, Arab + Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, @@ -1499,44 +1453,36 @@ class RecurrentSchedule(msrest.serialization.Model): Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands - Standard Time. + Standard Time. Required. :vartype time_zone: str - :ivar days: Required. the collection of days that the profile takes effect on. Possible values - are Sunday through Saturday. + :ivar days: the collection of days that the profile takes effect on. Possible values are Sunday + through Saturday. Required. :vartype days: list[str] - :ivar hours: Required. A collection of hours that the profile takes effect on. Values supported - are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + :ivar hours: A collection of hours that the profile takes effect on. Values supported are 0 to + 23 on the 24-hour clock (AM/PM times are not supported). Required. :vartype hours: list[int] - :ivar minutes: Required. A collection of minutes at which the profile takes effect at. + :ivar minutes: A collection of minutes at which the profile takes effect at. Required. :vartype minutes: list[int] """ _validation = { - 'time_zone': {'required': True}, - 'days': {'required': True}, - 'hours': {'required': True}, - 'minutes': {'required': True}, + "time_zone": {"required": True}, + "days": {"required": True}, + "hours": {"required": True}, + "minutes": {"required": True}, } _attribute_map = { - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'days': {'key': 'days', 'type': '[str]'}, - 'hours': {'key': 'hours', 'type': '[int]'}, - 'minutes': {'key': 'minutes', 'type': '[int]'}, + "time_zone": {"key": "timeZone", "type": "str"}, + "days": {"key": "days", "type": "[str]"}, + "hours": {"key": "hours", "type": "[int]"}, + "minutes": {"key": "minutes", "type": "[int]"}, } - def __init__( - self, - *, - time_zone: str, - days: List[str], - hours: List[int], - minutes: List[int], - **kwargs - ): + def __init__(self, *, time_zone: str, days: List[str], hours: List[int], minutes: List[int], **kwargs): """ - :keyword time_zone: Required. the timezone for the hours of the profile. Some examples of valid - time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, + :keyword time_zone: the timezone for the hours of the profile. Some examples of valid time + zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, @@ -1564,95 +1510,89 @@ def __init__( Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands - Standard Time. + Standard Time. Required. :paramtype time_zone: str - :keyword days: Required. the collection of days that the profile takes effect on. Possible - values are Sunday through Saturday. + :keyword days: the collection of days that the profile takes effect on. Possible values are + Sunday through Saturday. Required. :paramtype days: list[str] - :keyword hours: Required. A collection of hours that the profile takes effect on. Values - supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + :keyword hours: A collection of hours that the profile takes effect on. Values supported are 0 + to 23 on the 24-hour clock (AM/PM times are not supported). Required. :paramtype hours: list[int] - :keyword minutes: Required. A collection of minutes at which the profile takes effect at. + :keyword minutes: A collection of minutes at which the profile takes effect at. Required. :paramtype minutes: list[int] """ - super(RecurrentSchedule, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_zone = time_zone self.days = days self.hours = hours self.minutes = minutes -class RetentionPolicy(msrest.serialization.Model): +class RetentionPolicy(_serialization.Model): """Specifies the retention policy for the log. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :ivar enabled: a value indicating whether the retention policy is enabled. Required. :vartype enabled: bool - :ivar days: Required. the number of days for the retention in days. A value of 0 will retain - the events indefinitely. + :ivar days: the number of days for the retention in days. A value of 0 will retain the events + indefinitely. Required. :vartype days: int """ _validation = { - 'enabled': {'required': True}, - 'days': {'required': True, 'minimum': 0}, + "enabled": {"required": True}, + "days": {"required": True, "minimum": 0}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: bool, - days: int, - **kwargs - ): + def __init__(self, *, enabled: bool, days: int, **kwargs): """ - :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :keyword enabled: a value indicating whether the retention policy is enabled. Required. :paramtype enabled: bool - :keyword days: Required. the number of days for the retention in days. A value of 0 will retain - the events indefinitely. + :keyword days: the number of days for the retention in days. A value of 0 will retain the + events indefinitely. Required. :paramtype days: int """ - super(RetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class ScaleAction(msrest.serialization.Model): +class ScaleAction(_serialization.Model): """The parameters for the scaling action. All required parameters must be populated in order to send to Azure. - :ivar direction: Required. the scale direction. Whether the scaling action increases or - decreases the number of instances. Known values are: "None", "Increase", "Decrease". + :ivar direction: the scale direction. Whether the scaling action increases or decreases the + number of instances. Required. Known values are: "None", "Increase", and "Decrease". :vartype direction: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleDirection - :ivar type: Required. the type of action that should occur when the scale rule fires. Known - values are: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". + :ivar type: the type of action that should occur when the scale rule fires. Required. Known + values are: "ChangeCount", "PercentChangeCount", "ExactCount", and "ServiceAllowedNextValue". :vartype type: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleType :ivar value: the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. :vartype value: str - :ivar cooldown: Required. the amount of time to wait since the last scaling action before this - action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + :ivar cooldown: the amount of time to wait since the last scaling action before this action + occurs. It must be between 1 week and 1 minute in ISO 8601 format. Required. :vartype cooldown: ~datetime.timedelta """ _validation = { - 'direction': {'required': True}, - 'type': {'required': True}, - 'cooldown': {'required': True}, + "direction": {"required": True}, + "type": {"required": True}, + "cooldown": {"required": True}, } _attribute_map = { - 'direction': {'key': 'direction', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'cooldown': {'key': 'cooldown', 'type': 'duration'}, + "direction": {"key": "direction", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "cooldown": {"key": "cooldown", "type": "duration"}, } def __init__( @@ -1661,149 +1601,136 @@ def __init__( direction: Union[str, "_models.ScaleDirection"], type: Union[str, "_models.ScaleType"], cooldown: datetime.timedelta, - value: Optional[str] = "1", + value: str = "1", **kwargs ): """ - :keyword direction: Required. the scale direction. Whether the scaling action increases or - decreases the number of instances. Known values are: "None", "Increase", "Decrease". + :keyword direction: the scale direction. Whether the scaling action increases or decreases the + number of instances. Required. Known values are: "None", "Increase", and "Decrease". :paramtype direction: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleDirection - :keyword type: Required. the type of action that should occur when the scale rule fires. Known - values are: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". + :keyword type: the type of action that should occur when the scale rule fires. Required. Known + values are: "ChangeCount", "PercentChangeCount", "ExactCount", and "ServiceAllowedNextValue". :paramtype type: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleType :keyword value: the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. :paramtype value: str - :keyword cooldown: Required. the amount of time to wait since the last scaling action before - this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + :keyword cooldown: the amount of time to wait since the last scaling action before this action + occurs. It must be between 1 week and 1 minute in ISO 8601 format. Required. :paramtype cooldown: ~datetime.timedelta """ - super(ScaleAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.direction = direction self.type = type self.value = value self.cooldown = cooldown -class ScaleCapacity(msrest.serialization.Model): +class ScaleCapacity(_serialization.Model): """The number of instances that can be used during this profile. All required parameters must be populated in order to send to Azure. - :ivar minimum: Required. the minimum number of instances for the resource. + :ivar minimum: the minimum number of instances for the resource. Required. :vartype minimum: str - :ivar maximum: Required. the maximum number of instances for the resource. The actual maximum - number of instances is limited by the cores that are available in the subscription. + :ivar maximum: the maximum number of instances for the resource. The actual maximum number of + instances is limited by the cores that are available in the subscription. Required. :vartype maximum: str - :ivar default: Required. the number of instances that will be set if metrics are not available - for evaluation. The default is only used if the current instance count is lower than the - default. + :ivar default: the number of instances that will be set if metrics are not available for + evaluation. The default is only used if the current instance count is lower than the default. + Required. :vartype default: str """ _validation = { - 'minimum': {'required': True}, - 'maximum': {'required': True}, - 'default': {'required': True}, + "minimum": {"required": True}, + "maximum": {"required": True}, + "default": {"required": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'str'}, - 'maximum': {'key': 'maximum', 'type': 'str'}, - 'default': {'key': 'default', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "str"}, + "maximum": {"key": "maximum", "type": "str"}, + "default": {"key": "default", "type": "str"}, } - def __init__( - self, - *, - minimum: str, - maximum: str, - default: str, - **kwargs - ): + def __init__(self, *, minimum: str, maximum: str, default: str, **kwargs): """ - :keyword minimum: Required. the minimum number of instances for the resource. + :keyword minimum: the minimum number of instances for the resource. Required. :paramtype minimum: str - :keyword maximum: Required. the maximum number of instances for the resource. The actual - maximum number of instances is limited by the cores that are available in the subscription. + :keyword maximum: the maximum number of instances for the resource. The actual maximum number + of instances is limited by the cores that are available in the subscription. Required. :paramtype maximum: str - :keyword default: Required. the number of instances that will be set if metrics are not - available for evaluation. The default is only used if the current instance count is lower than - the default. + :keyword default: the number of instances that will be set if metrics are not available for + evaluation. The default is only used if the current instance count is lower than the default. + Required. :paramtype default: str """ - super(ScaleCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.minimum = minimum self.maximum = maximum self.default = default -class ScaleRule(msrest.serialization.Model): +class ScaleRule(_serialization.Model): """A rule that provide the triggers and parameters for the scaling action. All required parameters must be populated in order to send to Azure. - :ivar metric_trigger: Required. the trigger that results in a scaling action. + :ivar metric_trigger: the trigger that results in a scaling action. Required. :vartype metric_trigger: ~$(python-base-namespace).v2021_05_01_preview.models.MetricTrigger - :ivar scale_action: Required. the parameters for the scaling action. + :ivar scale_action: the parameters for the scaling action. Required. :vartype scale_action: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleAction """ _validation = { - 'metric_trigger': {'required': True}, - 'scale_action': {'required': True}, + "metric_trigger": {"required": True}, + "scale_action": {"required": True}, } _attribute_map = { - 'metric_trigger': {'key': 'metricTrigger', 'type': 'MetricTrigger'}, - 'scale_action': {'key': 'scaleAction', 'type': 'ScaleAction'}, + "metric_trigger": {"key": "metricTrigger", "type": "MetricTrigger"}, + "scale_action": {"key": "scaleAction", "type": "ScaleAction"}, } - def __init__( - self, - *, - metric_trigger: "_models.MetricTrigger", - scale_action: "_models.ScaleAction", - **kwargs - ): + def __init__(self, *, metric_trigger: "_models.MetricTrigger", scale_action: "_models.ScaleAction", **kwargs): """ - :keyword metric_trigger: Required. the trigger that results in a scaling action. + :keyword metric_trigger: the trigger that results in a scaling action. Required. :paramtype metric_trigger: ~$(python-base-namespace).v2021_05_01_preview.models.MetricTrigger - :keyword scale_action: Required. the parameters for the scaling action. + :keyword scale_action: the parameters for the scaling action. Required. :paramtype scale_action: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleAction """ - super(ScaleRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_trigger = metric_trigger self.scale_action = scale_action -class ScaleRuleMetricDimension(msrest.serialization.Model): +class ScaleRuleMetricDimension(_serialization.Model): """Specifies an auto scale rule metric dimension. All required parameters must be populated in order to send to Azure. - :ivar dimension_name: Required. Name of the dimension. + :ivar dimension_name: Name of the dimension. Required. :vartype dimension_name: str - :ivar operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. - 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. - Known values are: "Equals", "NotEquals". + :ivar operator: the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' + being equal to any of the values. 'NotEquals' being not equal to all of the values. Required. + Known values are: "Equals" and "NotEquals". :vartype operator: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleRuleMetricDimensionOperationType - :ivar values: Required. list of dimension values. For example: ["App1","App2"]. + :ivar values: list of dimension values. For example: ["App1","App2"]. Required. :vartype values: list[str] """ _validation = { - 'dimension_name': {'required': True}, - 'operator': {'required': True}, - 'values': {'required': True}, + "dimension_name": {"required": True}, + "operator": {"required": True}, + "values": {"required": True}, } _attribute_map = { - 'dimension_name': {'key': 'DimensionName', 'type': 'str'}, - 'operator': {'key': 'Operator', 'type': 'str'}, - 'values': {'key': 'Values', 'type': '[str]'}, + "dimension_name": {"key": "DimensionName", "type": "str"}, + "operator": {"key": "Operator", "type": "str"}, + "values": {"key": "Values", "type": "[str]"}, } def __init__( @@ -1815,23 +1742,23 @@ def __init__( **kwargs ): """ - :keyword dimension_name: Required. Name of the dimension. + :keyword dimension_name: Name of the dimension. Required. :paramtype dimension_name: str - :keyword operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are - supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the - values. Known values are: "Equals", "NotEquals". + :keyword operator: the dimension operator. Only 'Equals' and 'NotEquals' are supported. + 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. + Required. Known values are: "Equals" and "NotEquals". :paramtype operator: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleRuleMetricDimensionOperationType - :keyword values: Required. list of dimension values. For example: ["App1","App2"]. + :keyword values: list of dimension values. For example: ["App1","App2"]. Required. :paramtype values: list[str] """ - super(ScaleRuleMetricDimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.dimension_name = dimension_name self.operator = operator self.values = values -class SubscriptionDiagnosticSettingsResource(Resource): +class SubscriptionDiagnosticSettingsResource(Resource): # pylint: disable=too-many-instance-attributes """The subscription diagnostic setting resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1870,24 +1797,24 @@ class SubscriptionDiagnosticSettingsResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "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'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'event_hub_name': {'key': 'properties.eventHubName', 'type': 'str'}, - 'logs': {'key': 'properties.logs', 'type': '[SubscriptionLogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, - 'marketplace_partner_id': {'key': 'properties.marketplacePartnerId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, + "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, + "logs": {"key": "properties.logs", "type": "[SubscriptionLogSettings]"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, + "marketplace_partner_id": {"key": "properties.marketplacePartnerId", "type": "str"}, } def __init__( @@ -1925,7 +1852,7 @@ def __init__( you would like to send Diagnostic Logs. :paramtype marketplace_partner_id: str """ - super(SubscriptionDiagnosticSettingsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id @@ -1936,7 +1863,7 @@ def __init__( self.marketplace_partner_id = marketplace_partner_id -class SubscriptionDiagnosticSettingsResourceCollection(msrest.serialization.Model): +class SubscriptionDiagnosticSettingsResourceCollection(_serialization.Model): """Represents a collection of subscription diagnostic settings resources. :ivar value: The collection of subscription diagnostic settings resources. @@ -1945,25 +1872,20 @@ class SubscriptionDiagnosticSettingsResourceCollection(msrest.serialization.Mode """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SubscriptionDiagnosticSettingsResource]'}, + "value": {"key": "value", "type": "[SubscriptionDiagnosticSettingsResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.SubscriptionDiagnosticSettingsResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SubscriptionDiagnosticSettingsResource"]] = None, **kwargs): """ :keyword value: The collection of subscription diagnostic settings resources. :paramtype value: list[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource] """ - super(SubscriptionDiagnosticSettingsResourceCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class SubscriptionLogSettings(msrest.serialization.Model): +class SubscriptionLogSettings(_serialization.Model): """Part of Subscription diagnostic setting. Specifies the settings for a particular log. All required parameters must be populated in order to send to Azure. @@ -1974,27 +1896,22 @@ class SubscriptionLogSettings(msrest.serialization.Model): :ivar category_group: Name of a Subscription Diagnostic Log category group for a resource type this setting is applied to. :vartype category_group: str - :ivar enabled: Required. a value indicating whether this log is enabled. + :ivar enabled: a value indicating whether this log is enabled. Required. :vartype enabled: bool """ _validation = { - 'enabled': {'required': True}, + "enabled": {"required": True}, } _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'category_group': {'key': 'categoryGroup', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "category": {"key": "category", "type": "str"}, + "category_group": {"key": "categoryGroup", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, } def __init__( - self, - *, - enabled: bool, - category: Optional[str] = None, - category_group: Optional[str] = None, - **kwargs + self, *, enabled: bool, category: Optional[str] = None, category_group: Optional[str] = None, **kwargs ): """ :keyword category: Name of a Subscription Diagnostic Log category for a resource type this @@ -2003,22 +1920,22 @@ def __init__( :keyword category_group: Name of a Subscription Diagnostic Log category group for a resource type this setting is applied to. :paramtype category_group: str - :keyword enabled: Required. a value indicating whether this log is enabled. + :keyword enabled: a value indicating whether this log is enabled. Required. :paramtype enabled: bool """ - super(SubscriptionLogSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.category = category self.category_group = category_group self.enabled = enabled -class SystemData(msrest.serialization.Model): +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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). @@ -2026,7 +1943,7 @@ class SystemData(msrest.serialization.Model): :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -2034,12 +1951,12 @@ class SystemData(msrest.serialization.Model): """ _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__( @@ -2057,7 +1974,7 @@ def __init__( :keyword created_by: The identity that created the resource. :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). @@ -2065,13 +1982,13 @@ def __init__( :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -2080,7 +1997,7 @@ def __init__( self.last_modified_at = last_modified_at -class TimeWindow(msrest.serialization.Model): +class TimeWindow(_serialization.Model): """A specific date-time for the profile. All required parameters must be populated in order to send to Azure. @@ -2116,31 +2033,24 @@ class TimeWindow(msrest.serialization.Model): Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. :vartype time_zone: str - :ivar start: Required. the start time for the profile in ISO 8601 format. + :ivar start: the start time for the profile in ISO 8601 format. Required. :vartype start: ~datetime.datetime - :ivar end: Required. the end time for the profile in ISO 8601 format. + :ivar end: the end time for the profile in ISO 8601 format. Required. :vartype end: ~datetime.datetime """ _validation = { - 'start': {'required': True}, - 'end': {'required': True}, + "start": {"required": True}, + "end": {"required": True}, } _attribute_map = { - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'start': {'key': 'start', 'type': 'iso-8601'}, - 'end': {'key': 'end', 'type': 'iso-8601'}, + "time_zone": {"key": "timeZone", "type": "str"}, + "start": {"key": "start", "type": "iso-8601"}, + "end": {"key": "end", "type": "iso-8601"}, } - def __init__( - self, - *, - start: datetime.datetime, - end: datetime.datetime, - time_zone: Optional[str] = None, - **kwargs - ): + def __init__(self, *, start: datetime.datetime, end: datetime.datetime, time_zone: Optional[str] = None, **kwargs): """ :keyword time_zone: the timezone of the start and end times for the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard @@ -2173,18 +2083,18 @@ def __init__( Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. :paramtype time_zone: str - :keyword start: Required. the start time for the profile in ISO 8601 format. + :keyword start: the start time for the profile in ISO 8601 format. Required. :paramtype start: ~datetime.datetime - :keyword end: Required. the end time for the profile in ISO 8601 format. + :keyword end: the end time for the profile in ISO 8601 format. Required. :paramtype end: ~datetime.datetime """ - super(TimeWindow, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_zone = time_zone self.start = start self.end = end -class WebhookNotification(msrest.serialization.Model): +class WebhookNotification(_serialization.Model): """Webhook notification of an autoscale event. :ivar service_uri: the service address to receive the notification. @@ -2194,23 +2104,17 @@ class WebhookNotification(msrest.serialization.Model): """ _attribute_map = { - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } - def __init__( - self, - *, - service_uri: Optional[str] = None, - properties: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs): """ :keyword service_uri: the service address to receive the notification. :paramtype service_uri: str :keyword properties: a property bag of settings. This value can be empty. :paramtype properties: dict[str, str] """ - super(WebhookNotification, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_uri = service_uri self.properties = properties diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py index f3fce92da813..9423c612ef55 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py @@ -11,15 +11,14 @@ class CategoryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the diagnostic settings category. - """ + """The type of the diagnostic settings category.""" METRICS = "Metrics" LOGS = "Logs" + class ComparisonOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the operator that is used to compare the metric data and the threshold. - """ + """the operator that is used to compare the metric data and the threshold.""" EQUALS = "Equals" NOT_EQUALS = "NotEquals" @@ -28,18 +27,18 @@ class ComparisonOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class MetricStatisticType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the metric statistic type. How the metrics from multiple instances are combined. - """ + """the metric statistic type. How the metrics from multiple instances are combined.""" AVERAGE = "Average" MIN = "Min" @@ -47,14 +46,15 @@ class MetricStatisticType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SUM = "Sum" COUNT = "Count" + class PredictiveAutoscalePolicyScaleMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the predictive autoscale mode - """ + """the predictive autoscale mode.""" DISABLED = "Disabled" FORECAST_ONLY = "ForecastOnly" ENABLED = "Enabled" + class RecurrenceFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily @@ -71,31 +71,33 @@ class RecurrenceFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): MONTH = "Month" YEAR = "Year" + class ScaleDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the scale direction. Whether the scaling action increases or decreases the number of instances. - """ + """the scale direction. Whether the scaling action increases or decreases the number of instances.""" NONE = "None" INCREASE = "Increase" DECREASE = "Decrease" + class ScaleRuleMetricDimensionOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to - any of the values. 'NotEquals' being not equal to all of the values + any of the values. 'NotEquals' being not equal to all of the values. """ EQUALS = "Equals" NOT_EQUALS = "NotEquals" + class ScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the type of action that should occur when the scale rule fires. - """ + """the type of action that should occur when the scale rule fires.""" CHANGE_COUNT = "ChangeCount" PERCENT_CHANGE_COUNT = "PercentChangeCount" EXACT_COUNT = "ExactCount" SERVICE_ALLOWED_NEXT_VALUE = "ServiceAllowedNextValue" + class TimeAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """time aggregation type. How the data that is collected should be combined over time. The default value is Average. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/__init__.py index 1d276a5b9094..8ada5606afee 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/__init__.py @@ -16,13 +16,14 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AutoscaleSettingsOperations', - 'PredictiveMetricOperations', - 'DiagnosticSettingsOperations', - 'DiagnosticSettingsCategoryOperations', - 'ManagementGroupDiagnosticSettingsOperations', - 'SubscriptionDiagnosticSettingsOperations', + "AutoscaleSettingsOperations", + "PredictiveMetricOperations", + "DiagnosticSettingsOperations", + "DiagnosticSettingsCategoryOperations", + "ManagementGroupDiagnosticSettingsOperations", + "SubscriptionDiagnosticSettingsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py index 7c6fa0241412..42210c94a210 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +25,207 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - autoscale_setting_name: str, - subscription_id: str, - *, - json: Optional[_models.AutoscaleSettingResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - autoscale_setting_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - autoscale_setting_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - autoscale_setting_name: str, - *, - json: Optional[_models.AutoscaleSettingResourcePatch] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _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_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class AutoscaleSettingsOperations: """ @@ -277,42 +246,39 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.AutoscaleSettingResourceCollection]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.AutoscaleSettingResource"]: """Lists the autoscale settings for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 AutoscaleSettingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either AutoscaleSettingResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -320,15 +286,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -344,10 +306,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -358,46 +318,110 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, autoscale_setting_name: str, parameters: _models.AutoscaleSettingResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AutoscaleSettingResource: """Creates or updates an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AutoscaleSettingResource, or the result of cls(response) + :return: AutoscaleSettingResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: Union[_models.AutoscaleSettingResource, IO], + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] - _json = self._serialize.body(parameters, 'AutoscaleSettingResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AutoscaleSettingResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -406,7 +430,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -414,10 +439,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -426,55 +450,49 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - autoscale_setting_name: str, - **kwargs: Any + self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any ) -> None: """Deletes and autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -482,10 +500,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -496,45 +513,39 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - autoscale_setting_name: str, - **kwargs: Any + self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any ) -> _models.AutoscaleSettingResource: """Gets an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource, or the result of cls(response) + :return: AutoscaleSettingResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] - request = build_get_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -542,10 +553,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -553,61 +563,129 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, autoscale_setting_name: str, autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.AutoscaleSettingResource: """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. + :param autoscale_setting_resource: Parameters supplied to the operation. Required. :type autoscale_setting_resource: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Required. + :type autoscale_setting_resource: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: AutoscaleSettingResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: Union[_models.AutoscaleSettingResourcePatch, IO], + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Is either a model type + or a IO type. Required. + :type autoscale_setting_resource: + ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: AutoscaleSettingResource, or the result of cls(response) + :return: AutoscaleSettingResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] - _json = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(autoscale_setting_resource, (IO, bytes)): + _content = autoscale_setting_resource + else: + _json = self._serialize.body(autoscale_setting_resource, "AutoscaleSettingResourcePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -615,10 +693,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -626,47 +703,42 @@ def update( error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.AutoscaleSettingResourceCollection]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AutoscaleSettingResource"]: """Lists the autoscale settings for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result - of cls(response) + :return: An iterator like instance of either AutoscaleSettingResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -674,14 +746,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -697,10 +766,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -711,8 +778,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py index f7d7207ef837..d7105d0a5cef 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,79 +25,64 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - resource_uri: str, - name: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_uri: str, - **kwargs: Any -) -> HttpRequest: +def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DiagnosticSettingsCategoryOperations: """ @@ -113,42 +103,33 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get( - self, - resource_uri: str, - name: str, - **kwargs: Any - ) -> _models.DiagnosticSettingsCategoryResource: + def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResource: """Gets the diagnostic settings category for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsCategoryResource, or the result of cls(response) + :return: DiagnosticSettingsCategoryResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] - request = build_get_request( resource_uri=resource_uri, name=name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -156,10 +137,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -167,50 +147,44 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsCategoryResource', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsCategoryResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore - + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore @distributed_trace - def list( - self, - resource_uri: str, - **kwargs: Any - ) -> Iterable[_models.DiagnosticSettingsCategoryResourceCollection]: + def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.DiagnosticSettingsCategoryResource"]: """Lists the diagnostic settings categories for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticSettingsCategoryResourceCollection or - the result of cls(response) + :return: An iterator like instance of either DiagnosticSettingsCategoryResource or the result + of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -218,14 +192,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -241,10 +212,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -255,8 +224,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py index 14c72955c428..9bd253eff86f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,157 +25,117 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - resource_uri: str, - name: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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( - resource_uri: str, - name: str, - *, - json: Optional[_models.DiagnosticSettingsResource] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_uri: str, - name: str, - **kwargs: Any -) -> HttpRequest: + _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(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_uri: str, - **kwargs: Any -) -> HttpRequest: +def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DiagnosticSettingsOperations: """ @@ -191,42 +156,33 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get( - self, - resource_uri: str, - name: str, - **kwargs: Any - ) -> _models.DiagnosticSettingsResource: + def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource, or the result of cls(response) + :return: DiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] - request = build_get_request( resource_uri=resource_uri, name=name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -234,10 +190,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -245,51 +200,103 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_uri: str, name: str, parameters: _models.DiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DiagnosticSettingsResource: """Creates or updates diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_uri: str, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. 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: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_uri: str, name: str, parameters: Union[_models.DiagnosticSettingsResource, IO], **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DiagnosticSettingsResource, or the result of cls(response) + :return: DiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'DiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticSettingsResource") request = build_create_or_update_request( resource_uri=resource_uri, @@ -297,7 +304,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -305,10 +313,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -316,51 +323,44 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_uri: str, - name: str, - **kwargs: Any + self, resource_uri: str, name: str, **kwargs: Any ) -> None: """Deletes existing diagnostic settings for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_uri=resource_uri, name=name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -368,10 +368,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -382,43 +381,37 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace - def list( - self, - resource_uri: str, - **kwargs: Any - ) -> Iterable[_models.DiagnosticSettingsResourceCollection]: + def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.DiagnosticSettingsResource"]: """Gets the active diagnostic settings list for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticSettingsResourceCollection or the result - of cls(response) + :return: An iterator like instance of either DiagnosticSettingsResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -426,14 +419,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -449,10 +439,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -463,8 +451,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py index eaf80de5ad18..6f3d1149af00 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,157 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - management_group_id: str, - name: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(management_group_id: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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( - management_group_id: str, - name: str, - *, - json: Optional[_models.ManagementGroupDiagnosticSettingsResource] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(management_group_id: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - management_group_id: str, - name: str, - **kwargs: Any -) -> HttpRequest: + _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(management_group_id: str, name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), - "name": _SERIALIZER.url("name", name, 'str'), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - management_group_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_request(management_group_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings", + ) # pylint: disable=line-too-long path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ManagementGroupDiagnosticSettingsOperations: """ @@ -191,43 +168,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - management_group_id: str, - name: str, - **kwargs: Any + self, management_group_id: str, name: str, **kwargs: Any ) -> _models.ManagementGroupDiagnosticSettingsResource: """Gets the active management group diagnostic settings for the specified resource. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) + :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] - request = build_get_request( management_group_id=management_group_id, name=name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -235,10 +205,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,52 +215,117 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + + @overload + def create_or_update( + self, + management_group_id: str, + name: str, + parameters: _models.ManagementGroupDiagnosticSettingsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementGroupDiagnosticSettingsResource: + """Creates or updates management group diagnostic settings for the specified resource. + + :param management_group_id: The management group id. Required. + :type management_group_id: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: + ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ManagementGroupDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + management_group_id: str, + name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementGroupDiagnosticSettingsResource: + """Creates or updates management group diagnostic settings for the specified resource. + :param management_group_id: The management group id. Required. + :type management_group_id: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. 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: ManagementGroupDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( self, management_group_id: str, name: str, - parameters: _models.ManagementGroupDiagnosticSettingsResource, + parameters: Union[_models.ManagementGroupDiagnosticSettingsResource, IO], **kwargs: Any ) -> _models.ManagementGroupDiagnosticSettingsResource: """Creates or updates management group diagnostic settings for the specified resource. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) + :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagementGroupDiagnosticSettingsResource") request = build_create_or_update_request( management_group_id=management_group_id, @@ -299,7 +333,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -307,10 +342,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -318,51 +352,44 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - management_group_id: str, - name: str, - **kwargs: Any + self, management_group_id: str, name: str, **kwargs: Any ) -> None: """Deletes existing management group diagnostic settings for the specified resource. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( management_group_id=management_group_id, name=name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -370,10 +397,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -384,43 +410,39 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + delete.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace def list( - self, - management_group_id: str, - **kwargs: Any - ) -> Iterable[_models.ManagementGroupDiagnosticSettingsResourceCollection]: + self, management_group_id: str, **kwargs: Any + ) -> Iterable["_models.ManagementGroupDiagnosticSettingsResource"]: """Gets the active management group diagnostic settings list for the specified management group. - :param management_group_id: The management group id. + :param management_group_id: The management group id. Required. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - ManagementGroupDiagnosticSettingsResourceCollection or the result of cls(response) + :return: An iterator like instance of either ManagementGroupDiagnosticSettingsResource or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( management_group_id=management_group_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -428,14 +450,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - management_group_id=management_group_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -451,10 +470,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -465,8 +482,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py index 7b957557b8a0..d037e574b3f2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py @@ -9,9 +9,13 @@ import datetime from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -20,17 +24,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, autoscale_setting_name: str, + subscription_id: str, *, timespan: str, interval: datetime.timedelta, @@ -42,37 +49,37 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') - _params['interval'] = _SERIALIZER.query("interval", interval, 'duration') - _params['metricNamespace'] = _SERIALIZER.query("metric_namespace", metric_namespace, 'str') - _params['metricName'] = _SERIALIZER.query("metric_name", metric_name, 'str') - _params['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") + _params["interval"] = _SERIALIZER.query("interval", interval, "duration") + _params["metricNamespace"] = _SERIALIZER.query("metric_namespace", metric_namespace, "str") + _params["metricName"] = _SERIALIZER.query("metric_name", metric_name, "str") + _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PredictiveMetricOperations: """ @@ -93,7 +100,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, @@ -109,50 +115,48 @@ def get( """get predictive autoscale metric future data. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. + :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. + 'startDateTime_ISO/endDateTime_ISO'. Required. :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. + :param interval: The interval (i.e. timegrain) of the query. Required. :type interval: ~datetime.timedelta - :param metric_namespace: Metric namespace to query metric definitions for. + :param metric_namespace: Metric namespace to query metric definitions for. Required. :type metric_namespace: str :param metric_name: The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be - **'Metric%2Name1'**. + **'Metric%2Name1'**. Required. :type metric_name: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. + :param aggregation: The list of aggregation types (comma separated) to retrieve. Required. :type aggregation: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PredictiveResponse, or the result of cls(response) + :return: PredictiveResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PredictiveResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PredictiveResponse] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, - api_version=api_version, + subscription_id=self._config.subscription_id, timespan=timespan, interval=interval, metric_namespace=metric_namespace, metric_name=metric_name, aggregation=aggregation, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -160,10 +164,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -171,12 +174,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PredictiveResponse', pipeline_response) + deserialized = self._deserialize("PredictiveResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py index 60ce59e6f86d..825f35ff86a3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,157 +25,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - name: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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( - subscription_id: str, - name: str, - *, - json: Optional[_models.SubscriptionDiagnosticSettingsResource] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - subscription_id: str, - name: str, - **kwargs: Any -) -> HttpRequest: + _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(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "name": _SERIALIZER.url("name", name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SubscriptionDiagnosticSettingsOperations: """ @@ -191,40 +162,32 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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, - name: str, - **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: + def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResource: """Gets the active subscription diagnostic settings for the specified resource. - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource, or the result of cls(response) + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] - request = build_get_request( - subscription_id=self._config.subscription_id, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -232,10 +195,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -243,57 +205,109 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, name: str, parameters: _models.SubscriptionDiagnosticSettingsResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SubscriptionDiagnosticSettingsResource: """Creates or updates subscription diagnostic settings for the specified resource. - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. 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: SubscriptionDiagnosticSettingsResource, or the result of cls(response) + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update( + self, name: str, parameters: Union[_models.SubscriptionDiagnosticSettingsResource, IO], **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: + ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] - _json = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionDiagnosticSettingsResource") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -301,10 +315,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -312,48 +325,40 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - name: str, - **kwargs: Any - ) -> None: + def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Deletes existing subscription diagnostic settings for the specified resource. - :param name: The name of the diagnostic setting. + :param name: The name of the diagnostic setting. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, name=name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -361,10 +366,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -375,40 +379,35 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.SubscriptionDiagnosticSettingsResourceCollection]: + def list(self, **kwargs: Any) -> Iterable["_models.SubscriptionDiagnosticSettingsResource"]: """Gets the active subscription diagnostic settings list for the specified subscriptionId. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionDiagnosticSettingsResourceCollection - or the result of cls(response) + :return: An iterator like instance of either SubscriptionDiagnosticSettingsResource or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -416,14 +415,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -439,10 +435,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -453,8 +447,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py index d80b5f349efb..d9747582015e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + api_version = kwargs.pop("api_version", "2021-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json index ed28d78544de..3248b516ad8c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py index 3790449c1398..d118b8665881 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -22,14 +21,15 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2021_09_01.operations.ActionGroupsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -47,23 +47,18 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -72,7 +67,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py index c956c3bd2fc4..408b4a00a20e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + api_version = kwargs.pop("api_version", "2021-09-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py index e385b07e6f31..8de8f7ade1f6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2021_09_01.aio.operations.ActionGroupsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -48,23 +48,18 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -73,7 +68,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/__init__.py index 60f9d62f0ead..0e396f5d7fb0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', + "ActionGroupsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py index 25e509cd03f3..93bc036f2405 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,26 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._action_groups_operations import build_create_notifications_at_action_group_resource_level_request_initial, build_create_notifications_at_resource_group_level_request_initial, build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_get_test_notifications_at_action_group_resource_level_request, build_get_test_notifications_at_resource_group_level_request, build_get_test_notifications_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_post_test_notifications_request_initial, build_update_request -T = TypeVar('T') +from ...operations._action_groups_operations import ( + build_create_notifications_at_action_group_resource_level_request, + build_create_notifications_at_resource_group_level_request, + build_create_or_update_request, + build_delete_request, + build_enable_receiver_request, + build_get_request, + build_get_test_notifications_at_action_group_resource_level_request, + build_get_test_notifications_at_resource_group_level_request, + build_get_test_notifications_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_post_test_notifications_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ActionGroupsOperations: """ .. warning:: @@ -45,41 +68,105 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -88,7 +175,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -96,10 +184,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -108,55 +195,47 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -164,10 +243,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,52 +253,46 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -228,10 +300,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -242,52 +313,118 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2021_09_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2021_09_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -295,10 +432,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -306,41 +442,43 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore async def _post_test_notifications_initial( - self, - notification_request: _models.NotificationRequestBody, - **kwargs: Any + self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_post_test_notifications_request_initial( + request = build_post_test_notifications_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._post_test_notifications_initial.metadata['url'], + content=_content, + template_url=self._post_test_notifications_initial.metadata["url"], headers=_headers, params=_params, ) @@ -348,44 +486,103 @@ async def _post_test_notifications_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _post_test_notifications_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore - + _post_test_notifications_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore - @distributed_trace_async + @overload async def begin_post_test_notifications( self, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_post_test_notifications( + self, notification_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_post_test_notifications( + self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 @@ -398,86 +595,83 @@ async def begin_post_test_notifications( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._post_test_notifications_initial( # type: ignore notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_post_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_post_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore async def _create_notifications_at_resource_group_level_initial( - self, - resource_group_name: str, - notification_request: _models.NotificationRequestBody, - **kwargs: Any + self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_create_notifications_at_resource_group_level_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_notifications_at_resource_group_level_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_notifications_at_resource_group_level_initial.metadata['url'], + content=_content, + template_url=self._create_notifications_at_resource_group_level_initial.metadata["url"], headers=_headers, params=_params, ) @@ -485,47 +679,87 @@ async def _create_notifications_at_resource_group_level_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_notifications_at_resource_group_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _create_notifications_at_resource_group_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_notifications_at_resource_group_level( self, resource_group_name: str, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 @@ -538,89 +772,120 @@ async def begin_create_notifications_at_resource_group_level( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_notifications_at_resource_group_level( + self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_notifications_at_resource_group_level_initial( # type: ignore resource_group_name=resource_group_name, notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_create_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore async def _create_notifications_at_action_group_resource_level_initial( self, resource_group_name: str, action_group_name: str, - notification_request: _models.NotificationRequestBody, + notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_create_notifications_at_action_group_resource_level_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_notifications_at_action_group_resource_level_request( resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_notifications_at_action_group_resource_level_initial.metadata['url'], + content=_content, + template_url=self._create_notifications_at_action_group_resource_level_initial.metadata["url"], headers=_headers, params=_params, ) @@ -628,50 +893,130 @@ async def _create_notifications_at_action_group_resource_level_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_notifications_at_action_group_resource_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + _create_notifications_at_action_group_resource_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_notifications_at_action_group_resource_level( self, resource_group_name: str, action_group_name: str, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_request: Union[_models.NotificationRequestBody, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 @@ -684,20 +1029,17 @@ async def begin_create_notifications_at_action_group_resource_level( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_notifications_at_action_group_resource_level_initial( # type: ignore resource_group_name=resource_group_name, @@ -705,72 +1047,65 @@ async def begin_create_notifications_at_action_group_resource_level( notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_notifications_at_action_group_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + begin_create_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore @distributed_trace_async async def get_test_notifications( - self, - notification_id: str, - **kwargs: Any + self, notification_id: str, **kwargs: Any ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_request( - subscription_id=self._config.subscription_id, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications.metadata['url'], + template_url=self.get_test_notifications.metadata["url"], headers=_headers, params=_params, ) @@ -778,10 +1113,9 @@ async def get_test_notifications( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -789,52 +1123,46 @@ async def get_test_notifications( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore @distributed_trace_async async def get_test_notifications_at_resource_group_level( - self, - resource_group_name: str, - notification_id: str, - **kwargs: Any + self, resource_group_name: str, notification_id: str, **kwargs: Any ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_at_resource_group_level_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications_at_resource_group_level.metadata['url'], + template_url=self.get_test_notifications_at_resource_group_level.metadata["url"], headers=_headers, params=_params, ) @@ -842,10 +1170,9 @@ async def get_test_notifications_at_resource_group_level( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -853,56 +1180,49 @@ async def get_test_notifications_at_resource_group_level( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore @distributed_trace_async async def get_test_notifications_at_action_group_resource_level( - self, - resource_group_name: str, - action_group_name: str, - notification_id: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, notification_id: str, **kwargs: Any ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_at_action_group_resource_level_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications_at_action_group_resource_level.metadata['url'], + template_url=self.get_test_notifications_at_action_group_resource_level.metadata["url"], headers=_headers, params=_params, ) @@ -910,10 +1230,9 @@ async def get_test_notifications_at_action_group_resource_level( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -921,46 +1240,41 @@ async def get_test_notifications_at_action_group_resource_level( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications_at_action_group_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -968,14 +1282,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -991,10 +1302,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1005,46 +1314,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1052,15 +1357,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1076,10 +1377,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1090,47 +1389,116 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore - @distributed_trace_async + @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2021_09_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2021_09_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -1139,7 +1507,8 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -1147,10 +1516,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1161,5 +1529,4 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py index 7d4cce34b707..c2c49e9b3b64 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py @@ -28,36 +28,34 @@ from ._models_py3 import VoiceReceiver from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import ( - ReceiverStatus, -) +from ._monitor_management_client_enums import ReceiverStatus from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionDetail', - 'ActionGroupList', - 'ActionGroupPatchBody', - 'ActionGroupResource', - 'ArmRoleReceiver', - 'AutomationRunbookReceiver', - 'AzureAppPushReceiver', - 'AzureFunctionReceiver', - 'AzureResource', - 'Context', - 'EmailReceiver', - 'EnableRequest', - 'ErrorResponse', - 'EventHubReceiver', - 'ItsmReceiver', - 'LogicAppReceiver', - 'NotificationRequestBody', - 'SmsReceiver', - 'TestNotificationDetailsResponse', - 'VoiceReceiver', - 'WebhookReceiver', - 'ReceiverStatus', + "ActionDetail", + "ActionGroupList", + "ActionGroupPatchBody", + "ActionGroupResource", + "ArmRoleReceiver", + "AutomationRunbookReceiver", + "AzureAppPushReceiver", + "AzureFunctionReceiver", + "AzureResource", + "Context", + "EmailReceiver", + "EnableRequest", + "ErrorResponse", + "EventHubReceiver", + "ItsmReceiver", + "LogicAppReceiver", + "NotificationRequestBody", + "SmsReceiver", + "TestNotificationDetailsResponse", + "VoiceReceiver", + "WebhookReceiver", + "ReceiverStatus", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py index 681b968fbd0c..f416a68d80d5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_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. @@ -8,15 +9,14 @@ from typing import Dict, List, Optional, TYPE_CHECKING -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class ActionDetail(msrest.serialization.Model): +class ActionDetail(_serialization.Model): """The action detail. :ivar mechanism_type: The mechanism type. @@ -34,12 +34,12 @@ class ActionDetail(msrest.serialization.Model): """ _attribute_map = { - 'mechanism_type': {'key': 'MechanismType', 'type': 'str'}, - 'name': {'key': 'Name', 'type': 'str'}, - 'status': {'key': 'Status', 'type': 'str'}, - 'sub_state': {'key': 'SubState', 'type': 'str'}, - 'send_time': {'key': 'SendTime', 'type': 'str'}, - 'detail': {'key': 'Detail', 'type': 'str'}, + "mechanism_type": {"key": "MechanismType", "type": "str"}, + "name": {"key": "Name", "type": "str"}, + "status": {"key": "Status", "type": "str"}, + "sub_state": {"key": "SubState", "type": "str"}, + "send_time": {"key": "SendTime", "type": "str"}, + "detail": {"key": "Detail", "type": "str"}, } def __init__( @@ -67,7 +67,7 @@ def __init__( :keyword detail: The detail of the friendly error message. :paramtype detail: str """ - super(ActionDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.mechanism_type = mechanism_type self.name = name self.status = status @@ -76,7 +76,7 @@ def __init__( self.detail = detail -class ActionGroupList(msrest.serialization.Model): +class ActionGroupList(_serialization.Model): """A list of action groups. :ivar value: The list of action groups. @@ -86,16 +86,12 @@ class ActionGroupList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ActionGroupResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of action groups. @@ -103,15 +99,15 @@ def __init__( :keyword next_link: Provides the link to retrieve the next set of elements. :paramtype next_link: str """ - super(ActionGroupList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ActionGroupPatchBody(msrest.serialization.Model): +class ActionGroupPatchBody(_serialization.Model): """An action group object for the body of patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. @@ -119,30 +115,24 @@ class ActionGroupPatchBody(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - enabled: Optional[bool] = True, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. :paramtype enabled: bool """ - super(ActionGroupPatchBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.enabled = enabled -class AzureResource(msrest.serialization.Model): +class AzureResource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -155,41 +145,35 @@ class AzureResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(AzureResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -197,7 +181,7 @@ def __init__( self.tags = tags -class ActionGroupResource(AzureResource): +class ActionGroupResource(AzureResource): # pylint: disable=too-many-instance-attributes """An action group resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -210,9 +194,9 @@ class ActionGroupResource(AzureResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar group_short_name: The short name of the action group. This will be used in SMS messages. :vartype group_short_name: str @@ -253,32 +237,35 @@ class ActionGroupResource(AzureResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "group_short_name": {"max_length": 12}, } _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}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'properties.armRoleReceivers', 'type': '[ArmRoleReceiver]'}, - 'event_hub_receivers': {'key': 'properties.eventHubReceivers', 'type': '[EventHubReceiver]'}, + "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}"}, + "group_short_name": {"key": "properties.groupShortName", "type": "str"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, + "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, + "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, + "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, + "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, + "automation_runbook_receivers": { + "key": "properties.automationRunbookReceivers", + "type": "[AutomationRunbookReceiver]", + }, + "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, + "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, + "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, + "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, + "event_hub_receivers": {"key": "properties.eventHubReceivers", "type": "[EventHubReceiver]"}, } def __init__( @@ -287,7 +274,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, - enabled: Optional[bool] = True, + enabled: bool = True, email_receivers: Optional[List["_models.EmailReceiver"]] = None, sms_receivers: Optional[List["_models.SmsReceiver"]] = None, webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, @@ -302,9 +289,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword group_short_name: The short name of the action group. This will be used in SMS messages. @@ -348,7 +335,7 @@ def __init__( :paramtype event_hub_receivers: list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] """ - super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled self.email_receivers = email_receivers @@ -364,67 +351,60 @@ def __init__( self.event_hub_receivers = event_hub_receivers -class ArmRoleReceiver(msrest.serialization.Model): +class ArmRoleReceiver(_serialization.Model): """An arm role receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the arm role receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the arm role receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar role_id: Required. The arm role id. + :ivar role_id: The arm role id. Required. :vartype role_id: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'role_id': {'required': True}, + "name": {"required": True}, + "role_id": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } - def __init__( - self, - *, - name: str, - role_id: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs): """ - :keyword name: Required. The name of the arm role receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the arm role receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword role_id: Required. The arm role id. + :keyword role_id: The arm role id. Required. :paramtype role_id: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(ArmRoleReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.role_id = role_id self.use_common_alert_schema = use_common_alert_schema -class AutomationRunbookReceiver(msrest.serialization.Model): +class AutomationRunbookReceiver(_serialization.Model): """The Azure Automation Runbook notification receiver. All required parameters must be populated in order to send to Azure. - :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook - and authenticate to Azure resource. + :ivar automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :vartype automation_account_id: str - :ivar runbook_name: Required. The name for this runbook. + :ivar runbook_name: The name for this runbook. Required. :vartype runbook_name: str - :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. :vartype webhook_resource_id: str - :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. :vartype is_global_runbook: bool :ivar name: Indicates name of the webhook. :vartype name: str @@ -435,20 +415,20 @@ class AutomationRunbookReceiver(msrest.serialization.Model): """ _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, + "automation_account_id": {"required": True}, + "runbook_name": {"required": True}, + "webhook_resource_id": {"required": True}, + "is_global_runbook": {"required": True}, } _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "automation_account_id": {"key": "automationAccountId", "type": "str"}, + "runbook_name": {"key": "runbookName", "type": "str"}, + "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, + "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( @@ -460,18 +440,18 @@ def __init__( is_global_runbook: bool, name: Optional[str] = None, service_uri: Optional[str] = None, - use_common_alert_schema: Optional[bool] = False, + use_common_alert_schema: bool = False, **kwargs ): """ - :keyword automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. + :keyword automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :paramtype automation_account_id: str - :keyword runbook_name: Required. The name for this runbook. + :keyword runbook_name: The name for this runbook. Required. :paramtype runbook_name: str - :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. :paramtype webhook_resource_id: str - :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. :paramtype is_global_runbook: bool :keyword name: Indicates name of the webhook. :paramtype name: str @@ -480,7 +460,7 @@ def __init__( :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(AutomationRunbookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name self.webhook_resource_id = webhook_resource_id @@ -490,78 +470,72 @@ def __init__( self.use_common_alert_schema = use_common_alert_schema -class AzureAppPushReceiver(msrest.serialization.Model): +class AzureAppPushReceiver(_serialization.Model): """The Azure mobile App push notification receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :vartype name: str - :ivar email_address: Required. The email address registered for the Azure mobile app. + :ivar email_address: The email address registered for the Azure mobile app. Required. :vartype email_address: str """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, + "name": {"required": True}, + "email_address": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, **kwargs): """ - :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address registered for the Azure mobile app. + :keyword email_address: The email address registered for the Azure mobile app. Required. :paramtype email_address: str """ - super(AzureAppPushReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address -class AzureFunctionReceiver(msrest.serialization.Model): +class AzureFunctionReceiver(_serialization.Model): """An azure function receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the azure function receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the azure function receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar function_app_resource_id: Required. The azure resource id of the function app. + :ivar function_app_resource_id: The azure resource id of the function app. Required. :vartype function_app_resource_id: str - :ivar function_name: Required. The function name in the function app. + :ivar function_name: The function name in the function app. Required. :vartype function_name: str - :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :ivar http_trigger_url: The http trigger url where http request sent to. Required. :vartype http_trigger_url: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'function_app_resource_id': {'required': True}, - 'function_name': {'required': True}, - 'http_trigger_url': {'required': True}, + "name": {"required": True}, + "function_app_resource_id": {"required": True}, + "function_name": {"required": True}, + "http_trigger_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, - 'function_name': {'key': 'functionName', 'type': 'str'}, - 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, + "function_name": {"key": "functionName", "type": "str"}, + "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( @@ -571,23 +545,23 @@ def __init__( function_app_resource_id: str, function_name: str, http_trigger_url: str, - use_common_alert_schema: Optional[bool] = False, + use_common_alert_schema: bool = False, **kwargs ): """ - :keyword name: Required. The name of the azure function receiver. Names must be unique across - all receivers within an action group. + :keyword name: The name of the azure function receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword function_app_resource_id: Required. The azure resource id of the function app. + :keyword function_app_resource_id: The azure resource id of the function app. Required. :paramtype function_app_resource_id: str - :keyword function_name: Required. The function name in the function app. + :keyword function_name: The function name in the function app. Required. :paramtype function_name: str - :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :keyword http_trigger_url: The http trigger url where http request sent to. Required. :paramtype http_trigger_url: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(AzureFunctionReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.function_app_resource_id = function_app_resource_id self.function_name = function_name @@ -595,7 +569,7 @@ def __init__( self.use_common_alert_schema = use_common_alert_schema -class Context(msrest.serialization.Model): +class Context(_serialization.Model): """The context info. :ivar notification_source: The source of the notification request. @@ -605,116 +579,98 @@ class Context(msrest.serialization.Model): """ _attribute_map = { - 'notification_source': {'key': 'notificationSource', 'type': 'str'}, - 'context_type': {'key': 'contextType', 'type': 'str'}, + "notification_source": {"key": "notificationSource", "type": "str"}, + "context_type": {"key": "contextType", "type": "str"}, } - def __init__( - self, - *, - notification_source: Optional[str] = None, - context_type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs): """ :keyword notification_source: The source of the notification request. :paramtype notification_source: str :keyword context_type: The context id type. :paramtype context_type: str """ - super(Context, self).__init__(**kwargs) + super().__init__(**kwargs) self.notification_source = notification_source self.context_type = context_type -class EmailReceiver(msrest.serialization.Model): +class EmailReceiver(_serialization.Model): """An email receiver. Variables are only 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 name: Required. The name of the email receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the email receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar email_address: Required. The email address of this receiver. + :ivar email_address: The email address of this receiver. Required. :vartype email_address: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - "Disabled". + and "Disabled". :vartype status: str or ~$(python-base-namespace).v2021_09_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "email_address": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs): """ - :keyword name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the email receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address of this receiver. + :keyword email_address: The email address of this receiver. Required. :paramtype email_address: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(EmailReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address self.use_common_alert_schema = use_common_alert_schema self.status = None -class EnableRequest(msrest.serialization.Model): +class EnableRequest(_serialization.Model): """Describes a receiver that should be resubscribed. All required parameters must be populated in order to send to Azure. - :ivar receiver_name: Required. The name of the receiver to resubscribe. + :ivar receiver_name: The name of the receiver to resubscribe. Required. :vartype receiver_name: str """ _validation = { - 'receiver_name': {'required': True}, + "receiver_name": {"required": True}, } _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, + "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__( - self, - *, - receiver_name: str, - **kwargs - ): + def __init__(self, *, receiver_name: str, **kwargs): """ - :keyword receiver_name: Required. The name of the receiver to resubscribe. + :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str """ - super(EnableRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.receiver_name = receiver_name -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -724,62 +680,56 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class EventHubReceiver(msrest.serialization.Model): +class EventHubReceiver(_serialization.Model): """An Event hub receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Event hub receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the Event hub receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar event_hub_name_space: Required. The Event Hub namespace. + :ivar event_hub_name_space: The Event Hub namespace. Required. :vartype event_hub_name_space: str - :ivar event_hub_name: Required. The name of the specific Event Hub queue. + :ivar event_hub_name: The name of the specific Event Hub queue. Required. :vartype event_hub_name: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool :ivar tenant_id: The tenant Id for the subscription containing this event hub. :vartype tenant_id: str - :ivar subscription_id: Required. The Id for the subscription containing this event hub. + :ivar subscription_id: The Id for the subscription containing this event hub. Required. :vartype subscription_id: str """ _validation = { - 'name': {'required': True}, - 'event_hub_name_space': {'required': True}, - 'event_hub_name': {'required': True}, - 'subscription_id': {'required': True}, + "name": {"required": True}, + "event_hub_name_space": {"required": True}, + "event_hub_name": {"required": True}, + "subscription_id": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'event_hub_name_space': {'key': 'eventHubNameSpace', 'type': 'str'}, - 'event_hub_name': {'key': 'eventHubName', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "event_hub_name_space": {"key": "eventHubNameSpace", "type": "str"}, + "event_hub_name": {"key": "eventHubName", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, } def __init__( @@ -789,26 +739,26 @@ def __init__( event_hub_name_space: str, event_hub_name: str, subscription_id: str, - use_common_alert_schema: Optional[bool] = False, + use_common_alert_schema: bool = False, tenant_id: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the Event hub receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the Event hub receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword event_hub_name_space: Required. The Event Hub namespace. + :keyword event_hub_name_space: The Event Hub namespace. Required. :paramtype event_hub_name_space: str - :keyword event_hub_name: Required. The name of the specific Event Hub queue. + :keyword event_hub_name: The name of the specific Event Hub queue. Required. :paramtype event_hub_name: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool :keyword tenant_id: The tenant Id for the subscription containing this event hub. :paramtype tenant_id: str - :keyword subscription_id: Required. The Id for the subscription containing this event hub. + :keyword subscription_id: The Id for the subscription containing this event hub. Required. :paramtype subscription_id: str """ - super(EventHubReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.event_hub_name_space = event_hub_name_space self.event_hub_name = event_hub_name @@ -817,70 +767,65 @@ def __init__( self.subscription_id = subscription_id -class ItsmReceiver(msrest.serialization.Model): +class ItsmReceiver(_serialization.Model): """An Itsm receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar workspace_id: Required. OMS LA instance identifier. + :ivar workspace_id: OMS LA instance identifier. Required. :vartype workspace_id: str - :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined - in above workspace. + :ivar connection_id: Unique identification of ITSM connection among multiple defined in above + workspace. Required. :vartype connection_id: str - :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :vartype ticket_configuration: str - :ivar region: Required. Region in which workspace resides. Supported + :ivar region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :vartype region: str """ _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, + "name": {"required": True}, + "workspace_id": {"required": True}, + "connection_id": {"required": True}, + "ticket_configuration": {"required": True}, + "region": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "connection_id": {"key": "connectionId", "type": "str"}, + "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, + "region": {"key": "region", "type": "str"}, } def __init__( - self, - *, - name: str, - workspace_id: str, - connection_id: str, - ticket_configuration: str, - region: str, - **kwargs + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs ): """ - :keyword name: Required. The name of the Itsm receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword workspace_id: Required. OMS LA instance identifier. + :keyword workspace_id: OMS LA instance identifier. Required. :paramtype workspace_id: str - :keyword connection_id: Required. Unique identification of ITSM connection among multiple - defined in above workspace. + :keyword connection_id: Unique identification of ITSM connection among multiple defined in + above workspace. Required. :paramtype connection_id: str - :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :paramtype ticket_configuration: str - :keyword region: Required. Region in which workspace resides. Supported + :keyword region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :paramtype region: str """ - super(ItsmReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.workspace_id = workspace_id self.connection_id = connection_id @@ -888,68 +833,62 @@ def __init__( self.region = region -class LogicAppReceiver(msrest.serialization.Model): +class LogicAppReceiver(_serialization.Model): """A logic app receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar resource_id: Required. The azure resource id of the logic app receiver. + :ivar resource_id: The azure resource id of the logic app receiver. Required. :vartype resource_id: str - :ivar callback_url: Required. The callback url where http request sent to. + :ivar callback_url: The callback url where http request sent to. Required. :vartype callback_url: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'resource_id': {'required': True}, - 'callback_url': {'required': True}, + "name": {"required": True}, + "resource_id": {"required": True}, + "callback_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "callback_url": {"key": "callbackUrl", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( - self, - *, - name: str, - resource_id: str, - callback_url: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs + self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs ): """ - :keyword name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword resource_id: Required. The azure resource id of the logic app receiver. + :keyword resource_id: The azure resource id of the logic app receiver. Required. :paramtype resource_id: str - :keyword callback_url: Required. The callback url where http request sent to. + :keyword callback_url: The callback url where http request sent to. Required. :paramtype callback_url: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(LogicAppReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.resource_id = resource_id self.callback_url = callback_url self.use_common_alert_schema = use_common_alert_schema -class NotificationRequestBody(msrest.serialization.Model): +class NotificationRequestBody(_serialization.Model): # pylint: disable=too-many-instance-attributes """The request body which contain contact detail metadata. All required parameters must be populated in order to send to Azure. - :ivar alert_type: Required. The name of the supported alert type. + :ivar alert_type: The name of the supported alert type. Required. :vartype alert_type: str :ivar email_receivers: The list of email receivers that are part of this action group. :vartype email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] @@ -985,22 +924,22 @@ class NotificationRequestBody(msrest.serialization.Model): """ _validation = { - 'alert_type': {'required': True, 'max_length': 30, 'min_length': 0}, + "alert_type": {"required": True, "max_length": 30}, } _attribute_map = { - 'alert_type': {'key': 'alertType', 'type': 'str'}, - 'email_receivers': {'key': 'emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'armRoleReceivers', 'type': '[ArmRoleReceiver]'}, - 'event_hub_receivers': {'key': 'eventHubReceivers', 'type': '[EventHubReceiver]'}, + "alert_type": {"key": "alertType", "type": "str"}, + "email_receivers": {"key": "emailReceivers", "type": "[EmailReceiver]"}, + "sms_receivers": {"key": "smsReceivers", "type": "[SmsReceiver]"}, + "webhook_receivers": {"key": "webhookReceivers", "type": "[WebhookReceiver]"}, + "itsm_receivers": {"key": "itsmReceivers", "type": "[ItsmReceiver]"}, + "azure_app_push_receivers": {"key": "azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, + "automation_runbook_receivers": {"key": "automationRunbookReceivers", "type": "[AutomationRunbookReceiver]"}, + "voice_receivers": {"key": "voiceReceivers", "type": "[VoiceReceiver]"}, + "logic_app_receivers": {"key": "logicAppReceivers", "type": "[LogicAppReceiver]"}, + "azure_function_receivers": {"key": "azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, + "arm_role_receivers": {"key": "armRoleReceivers", "type": "[ArmRoleReceiver]"}, + "event_hub_receivers": {"key": "eventHubReceivers", "type": "[EventHubReceiver]"}, } def __init__( @@ -1021,7 +960,7 @@ def __init__( **kwargs ): """ - :keyword alert_type: Required. The name of the supported alert type. + :keyword alert_type: The name of the supported alert type. Required. :paramtype alert_type: str :keyword email_receivers: The list of email receivers that are part of this action group. :paramtype email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] @@ -1059,7 +998,7 @@ def __init__( :paramtype event_hub_receivers: list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] """ - super(NotificationRequestBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.alert_type = alert_type self.email_receivers = email_receivers self.sms_receivers = sms_receivers @@ -1074,71 +1013,64 @@ def __init__( self.event_hub_receivers = event_hub_receivers -class SmsReceiver(msrest.serialization.Model): +class SmsReceiver(_serialization.Model): """An SMS receiver. Variables are only 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 name: Required. The name of the SMS receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the SMS receiver. + :ivar country_code: The country code of the SMS receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the SMS receiver. + :ivar phone_number: The phone number of the SMS receiver. Required. :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and "Disabled". :vartype status: str or ~$(python-base-namespace).v2021_09_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the SMS receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the SMS receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the SMS receiver. + :keyword country_code: The country code of the SMS receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the SMS receiver. + :keyword phone_number: The phone number of the SMS receiver. Required. :paramtype phone_number: str """ - super(SmsReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number self.status = None -class TestNotificationDetailsResponse(msrest.serialization.Model): +class TestNotificationDetailsResponse(_serialization.Model): """The details of the test notification results. All required parameters must be populated in order to send to Azure. :ivar context: The context info. :vartype context: ~$(python-base-namespace).v2021_09_01.models.Context - :ivar state: Required. The overall state. + :ivar state: The overall state. Required. :vartype state: str :ivar completed_time: The completed time. :vartype completed_time: str @@ -1149,15 +1081,15 @@ class TestNotificationDetailsResponse(msrest.serialization.Model): """ _validation = { - 'state': {'required': True}, + "state": {"required": True}, } _attribute_map = { - 'context': {'key': 'context', 'type': 'Context'}, - 'state': {'key': 'state', 'type': 'str'}, - 'completed_time': {'key': 'completedTime', 'type': 'str'}, - 'created_time': {'key': 'createdTime', 'type': 'str'}, - 'action_details': {'key': 'actionDetails', 'type': '[ActionDetail]'}, + "context": {"key": "context", "type": "Context"}, + "state": {"key": "state", "type": "str"}, + "completed_time": {"key": "completedTime", "type": "str"}, + "created_time": {"key": "createdTime", "type": "str"}, + "action_details": {"key": "actionDetails", "type": "[ActionDetail]"}, } def __init__( @@ -1173,7 +1105,7 @@ def __init__( """ :keyword context: The context info. :paramtype context: ~$(python-base-namespace).v2021_09_01.models.Context - :keyword state: Required. The overall state. + :keyword state: The overall state. Required. :paramtype state: str :keyword completed_time: The completed time. :paramtype completed_time: str @@ -1182,7 +1114,7 @@ def __init__( :keyword action_details: The list of action detail. :paramtype action_details: list[~$(python-base-namespace).v2021_09_01.models.ActionDetail] """ - super(TestNotificationDetailsResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.context = context self.state = state self.completed_time = completed_time @@ -1190,64 +1122,57 @@ def __init__( self.action_details = action_details -class VoiceReceiver(msrest.serialization.Model): +class VoiceReceiver(_serialization.Model): """A voice receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the voice receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the voice receiver. + :ivar country_code: The country code of the voice receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the voice receiver. + :ivar phone_number: The phone number of the voice receiver. Required. :vartype phone_number: str """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the voice receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the voice receiver. + :keyword country_code: The country code of the voice receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the voice receiver. + :keyword phone_number: The phone number of the voice receiver. Required. :paramtype phone_number: str """ - super(VoiceReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number -class WebhookReceiver(msrest.serialization.Model): +class WebhookReceiver(_serialization.Model): """A webhook receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the webhook receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar service_uri: Required. The URI where webhooks should be sent. + :ivar service_uri: The URI where webhooks should be sent. Required. :vartype service_uri: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool @@ -1262,18 +1187,18 @@ class WebhookReceiver(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, + "name": {"required": True}, + "service_uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'use_aad_auth': {'key': 'useAadAuth', 'type': 'bool'}, - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'identifier_uri': {'key': 'identifierUri', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "use_aad_auth": {"key": "useAadAuth", "type": "bool"}, + "object_id": {"key": "objectId", "type": "str"}, + "identifier_uri": {"key": "identifierUri", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } def __init__( @@ -1281,18 +1206,18 @@ def __init__( *, name: str, service_uri: str, - use_common_alert_schema: Optional[bool] = False, - use_aad_auth: Optional[bool] = False, + use_common_alert_schema: bool = False, + use_aad_auth: bool = False, object_id: Optional[str] = None, identifier_uri: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the webhook receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword service_uri: Required. The URI where webhooks should be sent. + :keyword service_uri: The URI where webhooks should be sent. Required. :paramtype service_uri: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool @@ -1305,7 +1230,7 @@ def __init__( :keyword tenant_id: Indicates the tenant id for aad auth. :paramtype tenant_id: str """ - super(WebhookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.service_uri = service_uri self.use_common_alert_schema = use_common_alert_schema diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/__init__.py index 60f9d62f0ead..0e396f5d7fb0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', + "ActionGroupsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py index bb90a1dcd030..90fb74a60e5b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,528 +27,438 @@ 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 -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.ActionGroupResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - action_group_name: str, - *, - json: Optional[_models.ActionGroupPatchBody] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_post_test_notifications_request_initial( - subscription_id: str, - *, - json: Optional[_models.NotificationRequestBody] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_post_test_notifications_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_create_notifications_at_resource_group_level_request_initial( - subscription_id: str, - resource_group_name: str, - *, - json: Optional[_models.NotificationRequestBody] = None, - content: Any = None, - **kwargs: Any + +def build_create_notifications_at_resource_group_level_request( + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_create_notifications_at_action_group_resource_level_request_initial( - subscription_id: str, - resource_group_name: str, - action_group_name: str, - *, - json: Optional[_models.NotificationRequestBody] = None, - content: Any = None, - **kwargs: Any + +def build_create_notifications_at_action_group_resource_level_request( + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_test_notifications_request( - subscription_id: str, - notification_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_test_notifications_request(notification_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_test_notifications_at_resource_group_level_request( - subscription_id: str, - resource_group_name: str, - notification_id: str, - **kwargs: Any + resource_group_name: str, notification_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_test_notifications_at_action_group_resource_level_request( - subscription_id: str, - resource_group_name: str, - action_group_name: str, - notification_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, notification_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_id_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_enable_receiver_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.EnableRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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 ActionGroupsOperations: """ @@ -564,41 +479,105 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -607,7 +586,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -615,10 +595,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -627,55 +606,47 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -683,10 +654,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -694,52 +664,46 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -747,10 +711,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -761,52 +724,118 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2021_09_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2021_09_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -814,10 +843,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -825,41 +853,43 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore def _post_test_notifications_initial( - self, - notification_request: _models.NotificationRequestBody, - **kwargs: Any + self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_post_test_notifications_request_initial( + request = build_post_test_notifications_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._post_test_notifications_initial.metadata['url'], + content=_content, + template_url=self._post_test_notifications_initial.metadata["url"], headers=_headers, params=_params, ) @@ -867,44 +897,48 @@ def _post_test_notifications_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _post_test_notifications_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore - + _post_test_notifications_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore - @distributed_trace + @overload def begin_post_test_notifications( self, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -917,86 +951,138 @@ def begin_post_test_notifications( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_post_test_notifications( + self, notification_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_post_test_notifications( + self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._post_test_notifications_initial( # type: ignore notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_post_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_post_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore def _create_notifications_at_resource_group_level_initial( - self, - resource_group_name: str, - notification_request: _models.NotificationRequestBody, - **kwargs: Any + self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_create_notifications_at_resource_group_level_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_notifications_at_resource_group_level_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_notifications_at_resource_group_level_initial.metadata['url'], + content=_content, + template_url=self._create_notifications_at_resource_group_level_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1004,47 +1090,52 @@ def _create_notifications_at_resource_group_level_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_notifications_at_resource_group_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore - + _create_notifications_at_resource_group_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore - @distributed_trace + @overload def begin_create_notifications_at_resource_group_level( self, resource_group_name: str, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1057,89 +1148,155 @@ def begin_create_notifications_at_resource_group_level( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_notifications_at_resource_group_level( + self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_notifications_at_resource_group_level_initial( # type: ignore resource_group_name=resource_group_name, notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_create_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore def _create_notifications_at_action_group_resource_level_initial( self, resource_group_name: str, action_group_name: str, - notification_request: _models.NotificationRequestBody, + notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_create_notifications_at_action_group_resource_level_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_notifications_at_action_group_resource_level_request( resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_notifications_at_action_group_resource_level_initial.metadata['url'], + content=_content, + template_url=self._create_notifications_at_action_group_resource_level_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1147,50 +1304,130 @@ def _create_notifications_at_action_group_resource_level_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_notifications_at_action_group_resource_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore - + _create_notifications_at_action_group_resource_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore - @distributed_trace + @overload def begin_create_notifications_at_action_group_resource_level( self, resource_group_name: str, action_group_name: str, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_request: Union[_models.NotificationRequestBody, IO], + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 @@ -1203,20 +1440,17 @@ def begin_create_notifications_at_action_group_resource_level( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_notifications_at_action_group_resource_level_initial( # type: ignore resource_group_name=resource_group_name, @@ -1224,72 +1458,63 @@ def begin_create_notifications_at_action_group_resource_level( notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_notifications_at_action_group_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + begin_create_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore @distributed_trace - def get_test_notifications( - self, - notification_id: str, - **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: + def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_request( - subscription_id=self._config.subscription_id, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications.metadata['url'], + template_url=self.get_test_notifications.metadata["url"], headers=_headers, params=_params, ) @@ -1297,10 +1522,9 @@ def get_test_notifications( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1308,52 +1532,46 @@ def get_test_notifications( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore @distributed_trace def get_test_notifications_at_resource_group_level( - self, - resource_group_name: str, - notification_id: str, - **kwargs: Any + self, resource_group_name: str, notification_id: str, **kwargs: Any ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_at_resource_group_level_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications_at_resource_group_level.metadata['url'], + template_url=self.get_test_notifications_at_resource_group_level.metadata["url"], headers=_headers, params=_params, ) @@ -1361,10 +1579,9 @@ def get_test_notifications_at_resource_group_level( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1372,56 +1589,49 @@ def get_test_notifications_at_resource_group_level( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore @distributed_trace def get_test_notifications_at_action_group_resource_level( - self, - resource_group_name: str, - action_group_name: str, - notification_id: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, notification_id: str, **kwargs: Any ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_at_action_group_resource_level_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications_at_action_group_resource_level.metadata['url'], + template_url=self.get_test_notifications_at_action_group_resource_level.metadata["url"], headers=_headers, params=_params, ) @@ -1429,10 +1639,9 @@ def get_test_notifications_at_action_group_resource_level( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1440,46 +1649,41 @@ def get_test_notifications_at_action_group_resource_level( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications_at_action_group_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -1487,14 +1691,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1510,10 +1711,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1524,46 +1723,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1571,15 +1766,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1595,10 +1786,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1609,47 +1798,116 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore - @distributed_trace + @overload def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2021_09_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2021_09_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -1658,7 +1916,8 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -1666,10 +1925,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1680,5 +1938,4 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_configuration.py index 406177440408..2f986d7d4cf2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-09-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_metadata.json index 82c79f95fc19..c341aa76d894 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_monitor_management_client.py index 163bda97a892..fc88d269f4dc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_monitor_management_client.py @@ -9,20 +9,24 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import DataCollectionEndpointsOperations, DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations +from .operations import ( + DataCollectionEndpointsOperations, + DataCollectionRuleAssociationsOperations, + DataCollectionRulesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar data_collection_endpoints: DataCollectionEndpointsOperations operations @@ -34,9 +38,9 @@ class MonitorManagementClient: :ivar data_collection_rules: DataCollectionRulesOperations operations :vartype data_collection_rules: $(python-base-namespace).v2022_02_01_preview.operations.DataCollectionRulesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -52,7 +56,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -69,12 +75,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -83,7 +84,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_configuration.py index 8f3d74250c48..7fc853a5afcf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-09-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_monitor_management_client.py index b6a3c2c01653..66c5f63c37bc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_monitor_management_client.py @@ -9,20 +9,24 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration -from .operations import DataCollectionEndpointsOperations, DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations +from .operations import ( + DataCollectionEndpointsOperations, + DataCollectionRuleAssociationsOperations, + DataCollectionRulesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar data_collection_endpoints: DataCollectionEndpointsOperations operations @@ -34,9 +38,9 @@ class MonitorManagementClient: :ivar data_collection_rules: DataCollectionRulesOperations operations :vartype data_collection_rules: $(python-base-namespace).v2022_02_01_preview.aio.operations.DataCollectionRulesOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -52,7 +56,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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)} @@ -69,12 +75,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -83,7 +84,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/__init__.py index eea5749564d8..9d11e549f9e4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/__init__.py @@ -13,10 +13,11 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DataCollectionEndpointsOperations', - 'DataCollectionRuleAssociationsOperations', - 'DataCollectionRulesOperations', + "DataCollectionEndpointsOperations", + "DataCollectionRuleAssociationsOperations", + "DataCollectionRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_endpoints_operations.py index 8728c695d93c..54530a7308a4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_endpoints_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_endpoints_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._data_collection_endpoints_operations import build_create_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._data_collection_endpoints_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DataCollectionEndpointsOperations: """ .. warning:: @@ -43,44 +59,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionEndpointResourceListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataCollectionEndpointResource"]: """Lists all data collection endpoints in the specified resource group. Lists all data collection endpoints in the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 DataCollectionEndpointResourceListResult or the - result of cls(response) + :return: An iterator like instance of either DataCollectionEndpointResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -88,15 +101,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -112,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -126,45 +133,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionEndpointResourceListResult]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionEndpointResource"]: """Lists all data collection endpoints in the specified subscription. Lists all data collection endpoints in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResourceListResult or the - result of cls(response) + :return: An iterator like instance of either DataCollectionEndpointResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -172,14 +173,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -195,10 +193,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -209,51 +205,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any ) -> _models.DataCollectionEndpointResource: """Returns the specified data collection endpoint. Returns the specified data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource, or the result of cls(response) + :return: DataCollectionEndpointResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -261,10 +250,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -272,22 +260,23 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, data_collection_endpoint_name: str, body: Optional[_models.DataCollectionEndpointResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionEndpointResource: """Creates or updates a data collection endpoint. @@ -295,42 +284,112 @@ async def create( Creates or updates a data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionEndpointResource, or the result of cls(response) + :return: DataCollectionEndpointResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Creates or updates a data collection endpoint. + + Creates or updates a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[Union[_models.DataCollectionEndpointResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Creates or updates a data collection endpoint. + + Creates or updates a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionEndpointResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionEndpointResource") + else: + _json = None request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -338,10 +397,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -350,25 +408,26 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, data_collection_endpoint_name: str, body: Optional[_models.ResourceForUpdate] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionEndpointResource: """Updates part of a data collection endpoint. @@ -376,42 +435,111 @@ async def update( Updates part of a data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Updates part of a data collection endpoint. + + Updates part of a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionEndpointResource, or the result of cls(response) + :return: DataCollectionEndpointResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[Union[_models.ResourceForUpdate, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Updates part of a data collection endpoint. + + Updates part of a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] - if body is not None: - _json = self._serialize.body(body, 'ResourceForUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "ResourceForUpdate") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -419,10 +547,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -430,55 +557,49 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any ) -> None: """Deletes a data collection endpoint. Deletes a data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -486,10 +607,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -500,5 +620,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rule_associations_operations.py index e8c12f5e2fb3..0ffdf1040f79 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rule_associations_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._data_collection_rule_associations_operations import build_create_request, build_delete_request, build_get_request, build_list_by_data_collection_endpoint_request, build_list_by_resource_request, build_list_by_rule_request -T = TypeVar('T') +from ...operations._data_collection_rule_associations_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_data_collection_endpoint_request, + build_list_by_resource_request, + build_list_by_rule_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DataCollectionRuleAssociationsOperations: """ .. warning:: @@ -43,43 +59,39 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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_resource( - self, - resource_uri: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_uri: str, **kwargs: Any + ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified resource. Lists associations for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list_by_resource.metadata['url'], + template_url=self.list_by_resource.metadata["url"], headers=_headers, params=_params, ) @@ -87,21 +99,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,54 +133,49 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore + list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore @distributed_trace def list_by_rule( - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_rule_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_rule.metadata['url'], + template_url=self.list_by_rule.metadata["url"], headers=_headers, params=_params, ) @@ -179,23 +183,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_rule_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -204,10 +205,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -218,54 +217,49 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore + list_by_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore @distributed_trace def list_by_data_collection_endpoint( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified data collection endpoint. Lists associations for the specified data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_data_collection_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_data_collection_endpoint.metadata['url'], + template_url=self.list_by_data_collection_endpoint.metadata["url"], headers=_headers, params=_params, ) @@ -273,23 +267,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_data_collection_endpoint_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -298,10 +289,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -312,50 +301,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_collection_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations"} # type: ignore + list_by_data_collection_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations"} # type: ignore @distributed_trace_async async def get( - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Returns the specified association. Returns the specified association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) + :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] - request = build_get_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -363,10 +344,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -374,57 +354,125 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_uri: str, association_name: str, body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Creates or updates an association. Creates or updates an association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_uri: str, + association_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: + """Creates or updates an association. + + Creates or updates an association. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param association_name: The name of the association. The name is case insensitive. Required. + :type association_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_uri: str, + association_name: str, + body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: + """Creates or updates an association. + + Creates or updates an association. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param association_name: The name of the association. The name is case insensitive. Required. + :type association_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: + ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) + :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") + else: + _json = None request = build_create_request( resource_uri=resource_uri, @@ -432,7 +480,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -440,10 +489,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -452,56 +500,49 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + create.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> None: """Deletes an association. Deletes an association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -509,10 +550,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -523,5 +563,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rules_operations.py index ca72d4c85f45..c2c068b46ed7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rules_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._data_collection_rules_operations import build_create_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._data_collection_rules_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DataCollectionRulesOperations: """ .. warning:: @@ -43,44 +59,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionRuleResourceListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataCollectionRuleResource"]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 DataCollectionRuleResourceListResult or the result - of cls(response) + :return: An iterator like instance of either DataCollectionRuleResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -88,15 +101,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -112,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -126,45 +133,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DataCollectionRuleResourceListResult]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionRuleResource"]: """Lists all data collection rules in the specified subscription. Lists all data collection rules in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result - of cls(response) + :return: An iterator like instance of either DataCollectionRuleResource or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -172,14 +173,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -195,10 +193,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -209,51 +205,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any ) -> _models.DataCollectionRuleResource: """Returns the specified data collection rule. Returns the specified data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -261,10 +250,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -272,22 +260,23 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, data_collection_rule_name: str, body: Optional[_models.DataCollectionRuleResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleResource: """Creates or updates a data collection rule. @@ -295,42 +284,112 @@ async def create( Creates or updates a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Creates or updates a data collection rule. + + Creates or updates a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Creates or updates a data collection rule. + + Creates or updates a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionRuleResource") + else: + _json = None request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -338,10 +397,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -350,25 +408,26 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, data_collection_rule_name: str, body: Optional[_models.ResourceForUpdate] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleResource: """Updates part of a data collection rule. @@ -376,42 +435,111 @@ async def update( Updates part of a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Updates part of a data collection rule. + + Updates part of a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[Union[_models.ResourceForUpdate, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Updates part of a data collection rule. + + Updates part of a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - if body is not None: - _json = self._serialize.body(body, 'ResourceForUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "ResourceForUpdate") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -419,10 +547,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -430,55 +557,49 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any ) -> None: """Deletes a data collection rule. Deletes a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -486,10 +607,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -500,5 +620,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/__init__.py index 4ba134ae668a..5290d69732bf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/__init__.py @@ -56,96 +56,94 @@ from ._models_py3 import SystemData from ._models_py3 import WindowsEventLogDataSource - -from ._monitor_management_client_enums import ( - CreatedByType, - KnownColumnDefinitionType, - KnownDataCollectionEndpointProvisioningState, - KnownDataCollectionEndpointResourceKind, - KnownDataCollectionRuleAssociationProvisioningState, - KnownDataCollectionRuleProvisioningState, - KnownDataCollectionRuleResourceKind, - KnownDataFlowStreams, - KnownExtensionDataSourceStreams, - KnownLogFileTextSettingsRecordStartTimestampFormat, - KnownLogFilesDataSourceFormat, - KnownPerfCounterDataSourceStreams, - KnownPublicNetworkAccessOptions, - KnownSyslogDataSourceFacilityNames, - KnownSyslogDataSourceLogLevels, - KnownSyslogDataSourceStreams, - KnownWindowsEventLogDataSourceStreams, -) +from ._monitor_management_client_enums import CreatedByType +from ._monitor_management_client_enums import KnownColumnDefinitionType +from ._monitor_management_client_enums import KnownDataCollectionEndpointProvisioningState +from ._monitor_management_client_enums import KnownDataCollectionEndpointResourceKind +from ._monitor_management_client_enums import KnownDataCollectionRuleAssociationProvisioningState +from ._monitor_management_client_enums import KnownDataCollectionRuleProvisioningState +from ._monitor_management_client_enums import KnownDataCollectionRuleResourceKind +from ._monitor_management_client_enums import KnownDataFlowStreams +from ._monitor_management_client_enums import KnownExtensionDataSourceStreams +from ._monitor_management_client_enums import KnownLogFileTextSettingsRecordStartTimestampFormat +from ._monitor_management_client_enums import KnownLogFilesDataSourceFormat +from ._monitor_management_client_enums import KnownPerfCounterDataSourceStreams +from ._monitor_management_client_enums import KnownPublicNetworkAccessOptions +from ._monitor_management_client_enums import KnownSyslogDataSourceFacilityNames +from ._monitor_management_client_enums import KnownSyslogDataSourceLogLevels +from ._monitor_management_client_enums import KnownSyslogDataSourceStreams +from ._monitor_management_client_enums import KnownWindowsEventLogDataSourceStreams from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AzureMonitorMetricsDestination', - 'ColumnDefinition', - 'ConfigurationAccessEndpointSpec', - 'DataCollectionEndpoint', - 'DataCollectionEndpointConfigurationAccess', - 'DataCollectionEndpointLogsIngestion', - 'DataCollectionEndpointNetworkAcls', - 'DataCollectionEndpointResource', - 'DataCollectionEndpointResourceListResult', - 'DataCollectionEndpointResourceProperties', - 'DataCollectionEndpointResourceSystemData', - 'DataCollectionRule', - 'DataCollectionRuleAssociation', - 'DataCollectionRuleAssociationMetadata', - 'DataCollectionRuleAssociationProxyOnlyResource', - 'DataCollectionRuleAssociationProxyOnlyResourceListResult', - 'DataCollectionRuleAssociationProxyOnlyResourceProperties', - 'DataCollectionRuleAssociationProxyOnlyResourceSystemData', - 'DataCollectionRuleDataSources', - 'DataCollectionRuleDestinations', - 'DataCollectionRuleMetadata', - 'DataCollectionRuleResource', - 'DataCollectionRuleResourceListResult', - 'DataCollectionRuleResourceProperties', - 'DataCollectionRuleResourceSystemData', - 'DataFlow', - 'DataSourcesSpec', - 'DestinationsSpec', - 'DestinationsSpecAzureMonitorMetrics', - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponseCommonV2', - 'ExtensionDataSource', - 'IisLogsDataSource', - 'LogAnalyticsDestination', - 'LogFileSettings', - 'LogFileSettingsText', - 'LogFileTextSettings', - 'LogFilesDataSource', - 'LogFilesDataSourceSettings', - 'LogsIngestionEndpointSpec', - 'Metadata', - 'NetworkRuleSet', - 'PerfCounterDataSource', - 'ResourceForUpdate', - 'StreamDeclaration', - 'SyslogDataSource', - 'SystemData', - 'WindowsEventLogDataSource', - 'CreatedByType', - 'KnownColumnDefinitionType', - 'KnownDataCollectionEndpointProvisioningState', - 'KnownDataCollectionEndpointResourceKind', - 'KnownDataCollectionRuleAssociationProvisioningState', - 'KnownDataCollectionRuleProvisioningState', - 'KnownDataCollectionRuleResourceKind', - 'KnownDataFlowStreams', - 'KnownExtensionDataSourceStreams', - 'KnownLogFileTextSettingsRecordStartTimestampFormat', - 'KnownLogFilesDataSourceFormat', - 'KnownPerfCounterDataSourceStreams', - 'KnownPublicNetworkAccessOptions', - 'KnownSyslogDataSourceFacilityNames', - 'KnownSyslogDataSourceLogLevels', - 'KnownSyslogDataSourceStreams', - 'KnownWindowsEventLogDataSourceStreams', + "AzureMonitorMetricsDestination", + "ColumnDefinition", + "ConfigurationAccessEndpointSpec", + "DataCollectionEndpoint", + "DataCollectionEndpointConfigurationAccess", + "DataCollectionEndpointLogsIngestion", + "DataCollectionEndpointNetworkAcls", + "DataCollectionEndpointResource", + "DataCollectionEndpointResourceListResult", + "DataCollectionEndpointResourceProperties", + "DataCollectionEndpointResourceSystemData", + "DataCollectionRule", + "DataCollectionRuleAssociation", + "DataCollectionRuleAssociationMetadata", + "DataCollectionRuleAssociationProxyOnlyResource", + "DataCollectionRuleAssociationProxyOnlyResourceListResult", + "DataCollectionRuleAssociationProxyOnlyResourceProperties", + "DataCollectionRuleAssociationProxyOnlyResourceSystemData", + "DataCollectionRuleDataSources", + "DataCollectionRuleDestinations", + "DataCollectionRuleMetadata", + "DataCollectionRuleResource", + "DataCollectionRuleResourceListResult", + "DataCollectionRuleResourceProperties", + "DataCollectionRuleResourceSystemData", + "DataFlow", + "DataSourcesSpec", + "DestinationsSpec", + "DestinationsSpecAzureMonitorMetrics", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponseCommonV2", + "ExtensionDataSource", + "IisLogsDataSource", + "LogAnalyticsDestination", + "LogFileSettings", + "LogFileSettingsText", + "LogFileTextSettings", + "LogFilesDataSource", + "LogFilesDataSourceSettings", + "LogsIngestionEndpointSpec", + "Metadata", + "NetworkRuleSet", + "PerfCounterDataSource", + "ResourceForUpdate", + "StreamDeclaration", + "SyslogDataSource", + "SystemData", + "WindowsEventLogDataSource", + "CreatedByType", + "KnownColumnDefinitionType", + "KnownDataCollectionEndpointProvisioningState", + "KnownDataCollectionEndpointResourceKind", + "KnownDataCollectionRuleAssociationProvisioningState", + "KnownDataCollectionRuleProvisioningState", + "KnownDataCollectionRuleResourceKind", + "KnownDataFlowStreams", + "KnownExtensionDataSourceStreams", + "KnownLogFileTextSettingsRecordStartTimestampFormat", + "KnownLogFilesDataSourceFormat", + "KnownPerfCounterDataSourceStreams", + "KnownPublicNetworkAccessOptions", + "KnownSyslogDataSourceFacilityNames", + "KnownSyslogDataSourceLogLevels", + "KnownSyslogDataSourceStreams", + "KnownWindowsEventLogDataSourceStreams", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_models_py3.py index 3ec57246510a..2005a20b773e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_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,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AzureMonitorMetricsDestination(msrest.serialization.Model): +class AzureMonitorMetricsDestination(_serialization.Model): """Azure Monitor Metrics destination. :ivar name: A friendly name for the destination. @@ -27,39 +33,34 @@ class AzureMonitorMetricsDestination(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. :paramtype name: str """ - super(AzureMonitorMetricsDestination, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class ColumnDefinition(msrest.serialization.Model): +class ColumnDefinition(_serialization.Model): """Definition of custom data column. :ivar name: The name of the column. :vartype name: str :ivar type: The type of the column data. Known values are: "string", "int", "long", "real", - "boolean", "datetime", "dynamic". + "boolean", "datetime", and "dynamic". :vartype type: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownColumnDefinitionType """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -73,16 +74,16 @@ def __init__( :keyword name: The name of the column. :paramtype name: str :keyword type: The type of the column data. Known values are: "string", "int", "long", "real", - "boolean", "datetime", "dynamic". + "boolean", "datetime", and "dynamic". :paramtype type: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownColumnDefinitionType """ - super(ColumnDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class ConfigurationAccessEndpointSpec(msrest.serialization.Model): +class ConfigurationAccessEndpointSpec(_serialization.Model): """Definition of the endpoint used for accessing configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -92,24 +93,20 @@ class ConfigurationAccessEndpointSpec(msrest.serialization.Model): """ _validation = { - 'endpoint': {'readonly': True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ConfigurationAccessEndpointSpec, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.endpoint = None -class DataCollectionEndpoint(msrest.serialization.Model): +class DataCollectionEndpoint(_serialization.Model): """Definition of data collection endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -129,22 +126,22 @@ class DataCollectionEndpoint(msrest.serialization.Model): :vartype network_acls: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionEndpointProvisioningState """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'configuration_access': {'key': 'configurationAccess', 'type': 'DataCollectionEndpointConfigurationAccess'}, - 'logs_ingestion': {'key': 'logsIngestion', 'type': 'DataCollectionEndpointLogsIngestion'}, - 'network_acls': {'key': 'networkAcls', 'type': 'DataCollectionEndpointNetworkAcls'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "immutable_id": {"key": "immutableId", "type": "str"}, + "configuration_access": {"key": "configurationAccess", "type": "DataCollectionEndpointConfigurationAccess"}, + "logs_ingestion": {"key": "logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, + "network_acls": {"key": "networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -173,7 +170,7 @@ def __init__( :paramtype network_acls: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls """ - super(DataCollectionEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.immutable_id = immutable_id self.configuration_access = configuration_access @@ -192,23 +189,19 @@ class DataCollectionEndpointConfigurationAccess(ConfigurationAccessEndpointSpec) """ _validation = { - 'endpoint': {'readonly': True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DataCollectionEndpointConfigurationAccess, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class LogsIngestionEndpointSpec(msrest.serialization.Model): +class LogsIngestionEndpointSpec(_serialization.Model): """Definition of the endpoint used for ingesting logs. Variables are only populated by the server, and will be ignored when sending a request. @@ -218,20 +211,16 @@ class LogsIngestionEndpointSpec(msrest.serialization.Model): """ _validation = { - 'endpoint': {'readonly': True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LogsIngestionEndpointSpec, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.endpoint = None @@ -245,48 +234,41 @@ class DataCollectionEndpointLogsIngestion(LogsIngestionEndpointSpec): """ _validation = { - 'endpoint': {'readonly': True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'endpoint': {'key': 'endpoint', 'type': 'str'}, + "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DataCollectionEndpointLogsIngestion, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Definition of the network rules. :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownPublicNetworkAccessOptions """ _attribute_map = { - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, } def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, - **kwargs + self, *, public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, **kwargs ): """ :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownPublicNetworkAccessOptions """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_network_access = public_network_access @@ -294,42 +276,39 @@ class DataCollectionEndpointNetworkAcls(NetworkRuleSet): """Network access control rules for the endpoints. :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownPublicNetworkAccessOptions """ _attribute_map = { - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, } def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, - **kwargs + self, *, public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, **kwargs ): """ :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownPublicNetworkAccessOptions """ - super(DataCollectionEndpointNetworkAcls, self).__init__(public_network_access=public_network_access, **kwargs) + super().__init__(public_network_access=public_network_access, **kwargs) -class DataCollectionEndpointResource(msrest.serialization.Model): +class DataCollectionEndpointResource(_serialization.Model): # pylint: disable=too-many-instance-attributes """Definition of ARM tracked top level 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 location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Known values are: "Linux", "Windows". + :ivar kind: The kind of the resource. Known values are: "Linux" and "Windows". :vartype kind: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionEndpointResourceKind :ivar id: Fully qualified ID of the resource. @@ -358,36 +337,39 @@ class DataCollectionEndpointResource(msrest.serialization.Model): :vartype network_acls: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionEndpointProvisioningState """ _validation = { - 'location': {'required': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "location": {"required": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'DataCollectionEndpointResourceSystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'immutable_id': {'key': 'properties.immutableId', 'type': 'str'}, - 'configuration_access': {'key': 'properties.configurationAccess', 'type': 'DataCollectionEndpointConfigurationAccess'}, - 'logs_ingestion': {'key': 'properties.logsIngestion', 'type': 'DataCollectionEndpointLogsIngestion'}, - 'network_acls': {'key': 'properties.networkAcls', 'type': 'DataCollectionEndpointNetworkAcls'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "kind": {"key": "kind", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "system_data": {"key": "systemData", "type": "DataCollectionEndpointResourceSystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "immutable_id": {"key": "properties.immutableId", "type": "str"}, + "configuration_access": { + "key": "properties.configurationAccess", + "type": "DataCollectionEndpointConfigurationAccess", + }, + "logs_ingestion": {"key": "properties.logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, + "network_acls": {"key": "properties.networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -404,11 +386,11 @@ def __init__( **kwargs ): """ - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Known values are: "Linux", "Windows". + :keyword kind: The kind of the resource. Known values are: "Linux" and "Windows". :paramtype kind: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionEndpointResourceKind :keyword description: Description of the data collection endpoint. @@ -426,7 +408,7 @@ def __init__( :paramtype network_acls: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls """ - super(DataCollectionEndpointResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.kind = kind @@ -443,12 +425,12 @@ def __init__( self.provisioning_state = None -class DataCollectionEndpointResourceListResult(msrest.serialization.Model): +class DataCollectionEndpointResourceListResult(_serialization.Model): """A pageable list of resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. A list of resources. + :ivar value: A list of resources. Required. :vartype value: list[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource] :ivar next_link: The URL to use for getting the next set of results. @@ -456,29 +438,25 @@ class DataCollectionEndpointResourceListResult(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCollectionEndpointResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataCollectionEndpointResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: List["_models.DataCollectionEndpointResource"], - next_link: Optional[str] = None, - **kwargs + self, *, value: List["_models.DataCollectionEndpointResource"], next_link: Optional[str] = None, **kwargs ): """ - :keyword value: Required. A list of resources. + :keyword value: A list of resources. Required. :paramtype value: list[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(DataCollectionEndpointResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -503,22 +481,22 @@ class DataCollectionEndpointResourceProperties(DataCollectionEndpoint): :vartype network_acls: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionEndpointProvisioningState """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'configuration_access': {'key': 'configurationAccess', 'type': 'DataCollectionEndpointConfigurationAccess'}, - 'logs_ingestion': {'key': 'logsIngestion', 'type': 'DataCollectionEndpointLogsIngestion'}, - 'network_acls': {'key': 'networkAcls', 'type': 'DataCollectionEndpointNetworkAcls'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "immutable_id": {"key": "immutableId", "type": "str"}, + "configuration_access": {"key": "configurationAccess", "type": "DataCollectionEndpointConfigurationAccess"}, + "logs_ingestion": {"key": "logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, + "network_acls": {"key": "networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -547,16 +525,23 @@ def __init__( :paramtype network_acls: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls """ - super(DataCollectionEndpointResourceProperties, self).__init__(description=description, immutable_id=immutable_id, configuration_access=configuration_access, logs_ingestion=logs_ingestion, network_acls=network_acls, **kwargs) + super().__init__( + description=description, + immutable_id=immutable_id, + configuration_access=configuration_access, + logs_ingestion=logs_ingestion, + network_acls=network_acls, + **kwargs + ) -class SystemData(msrest.serialization.Model): +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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). @@ -564,7 +549,7 @@ class SystemData(msrest.serialization.Model): :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -572,12 +557,12 @@ class SystemData(msrest.serialization.Model): """ _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__( @@ -595,7 +580,7 @@ def __init__( :keyword created_by: The identity that created the resource. :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). @@ -603,13 +588,13 @@ def __init__( :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -624,7 +609,7 @@ class DataCollectionEndpointResourceSystemData(SystemData): :ivar created_by: The identity that created the resource. :vartype created_by: str :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). @@ -632,7 +617,7 @@ class DataCollectionEndpointResourceSystemData(SystemData): :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -640,12 +625,12 @@ class DataCollectionEndpointResourceSystemData(SystemData): """ _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__( @@ -663,7 +648,7 @@ def __init__( :keyword created_by: The identity that created the resource. :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). @@ -671,16 +656,24 @@ def __init__( :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(DataCollectionEndpointResourceSystemData, self).__init__(created_by=created_by, created_by_type=created_by_type, created_at=created_at, last_modified_by=last_modified_by, last_modified_by_type=last_modified_by_type, last_modified_at=last_modified_at, **kwargs) + super().__init__( + created_by=created_by, + created_by_type=created_by_type, + created_at=created_at, + last_modified_by=last_modified_by, + last_modified_by_type=last_modified_by_type, + last_modified_at=last_modified_at, + **kwargs + ) -class DataCollectionRule(msrest.serialization.Model): +class DataCollectionRule(_serialization.Model): """Definition of what monitoring data to collect and where that data should be sent. Variables are only populated by the server, and will be ignored when sending a request. @@ -709,27 +702,27 @@ class DataCollectionRule(msrest.serialization.Model): :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2022_02_01_preview.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleProvisioningState """ _validation = { - 'immutable_id': {'readonly': True}, - 'metadata': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "immutable_id": {"readonly": True}, + "metadata": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'data_collection_endpoint_id': {'key': 'dataCollectionEndpointId', 'type': 'str'}, - 'metadata': {'key': 'metadata', 'type': 'DataCollectionRuleMetadata'}, - 'stream_declarations': {'key': 'streamDeclarations', 'type': '{StreamDeclaration}'}, - 'data_sources': {'key': 'dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "immutable_id": {"key": "immutableId", "type": "str"}, + "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, + "metadata": {"key": "metadata", "type": "DataCollectionRuleMetadata"}, + "stream_declarations": {"key": "streamDeclarations", "type": "{StreamDeclaration}"}, + "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, + "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, + "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -763,7 +756,7 @@ def __init__( :keyword data_flows: The specification of data flows. :paramtype data_flows: list[~$(python-base-namespace).v2022_02_01_preview.models.DataFlow] """ - super(DataCollectionRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.immutable_id = None self.data_collection_endpoint_id = data_collection_endpoint_id @@ -775,7 +768,7 @@ def __init__( self.provisioning_state = None -class DataCollectionRuleAssociation(msrest.serialization.Model): +class DataCollectionRuleAssociation(_serialization.Model): """Definition of association of a data collection rule with a monitored Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -789,7 +782,7 @@ class DataCollectionRuleAssociation(msrest.serialization.Model): be associated. :vartype data_collection_endpoint_id: str :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState :ivar metadata: Metadata about the resource. @@ -798,16 +791,16 @@ class DataCollectionRuleAssociation(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'metadata': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "metadata": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'dataCollectionRuleId', 'type': 'str'}, - 'data_collection_endpoint_id': {'key': 'dataCollectionEndpointId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'metadata': {'key': 'metadata', 'type': 'DataCollectionRuleAssociationMetadata'}, + "description": {"key": "description", "type": "str"}, + "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, + "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "metadata": {"key": "metadata", "type": "DataCollectionRuleAssociationMetadata"}, } def __init__( @@ -828,7 +821,7 @@ def __init__( to be associated. :paramtype data_collection_endpoint_id: str """ - super(DataCollectionRuleAssociation, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.data_collection_rule_id = data_collection_rule_id self.data_collection_endpoint_id = data_collection_endpoint_id @@ -836,7 +829,7 @@ def __init__( self.metadata = None -class Metadata(msrest.serialization.Model): +class Metadata(_serialization.Model): """Metadata about the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -846,20 +839,16 @@ class Metadata(msrest.serialization.Model): """ _validation = { - 'provisioned_by': {'readonly': True}, + "provisioned_by": {"readonly": True}, } _attribute_map = { - 'provisioned_by': {'key': 'provisionedBy', 'type': 'str'}, + "provisioned_by": {"key": "provisionedBy", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Metadata, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provisioned_by = None @@ -873,23 +862,19 @@ class DataCollectionRuleAssociationMetadata(Metadata): """ _validation = { - 'provisioned_by': {'readonly': True}, + "provisioned_by": {"readonly": True}, } _attribute_map = { - 'provisioned_by': {'key': 'provisionedBy', 'type': 'str'}, + "provisioned_by": {"key": "provisionedBy", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DataCollectionRuleAssociationMetadata, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model): +class DataCollectionRuleAssociationProxyOnlyResource(_serialization.Model): """Definition of generic ARM proxy resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -914,7 +899,7 @@ class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model) be associated. :vartype data_collection_endpoint_id: str :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState :ivar metadata: Metadata about the resource. @@ -923,26 +908,26 @@ class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model) """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'metadata': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "metadata": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'DataCollectionRuleAssociationProxyOnlyResourceSystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'properties.dataCollectionRuleId', 'type': 'str'}, - 'data_collection_endpoint_id': {'key': 'properties.dataCollectionEndpointId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'DataCollectionRuleAssociationMetadata'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "system_data": {"key": "systemData", "type": "DataCollectionRuleAssociationProxyOnlyResourceSystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "data_collection_rule_id": {"key": "properties.dataCollectionRuleId", "type": "str"}, + "data_collection_endpoint_id": {"key": "properties.dataCollectionEndpointId", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "DataCollectionRuleAssociationMetadata"}, } def __init__( @@ -963,7 +948,7 @@ def __init__( to be associated. :paramtype data_collection_endpoint_id: str """ - super(DataCollectionRuleAssociationProxyOnlyResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -976,12 +961,12 @@ def __init__( self.metadata = None -class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serialization.Model): +class DataCollectionRuleAssociationProxyOnlyResourceListResult(_serialization.Model): """A pageable list of resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. A list of resources. + :ivar value: A list of resources. Required. :vartype value: list[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] :ivar next_link: The URL to use for getting the next set of results. @@ -989,12 +974,12 @@ class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serializat """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCollectionRuleAssociationProxyOnlyResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataCollectionRuleAssociationProxyOnlyResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -1005,13 +990,13 @@ def __init__( **kwargs ): """ - :keyword value: Required. A list of resources. + :keyword value: A list of resources. Required. :paramtype value: list[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(DataCollectionRuleAssociationProxyOnlyResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1030,7 +1015,7 @@ class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRul be associated. :vartype data_collection_endpoint_id: str :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState :ivar metadata: Metadata about the resource. @@ -1039,16 +1024,16 @@ class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRul """ _validation = { - 'provisioning_state': {'readonly': True}, - 'metadata': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "metadata": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'dataCollectionRuleId', 'type': 'str'}, - 'data_collection_endpoint_id': {'key': 'dataCollectionEndpointId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'metadata': {'key': 'metadata', 'type': 'DataCollectionRuleAssociationMetadata'}, + "description": {"key": "description", "type": "str"}, + "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, + "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "metadata": {"key": "metadata", "type": "DataCollectionRuleAssociationMetadata"}, } def __init__( @@ -1069,7 +1054,12 @@ def __init__( to be associated. :paramtype data_collection_endpoint_id: str """ - super(DataCollectionRuleAssociationProxyOnlyResourceProperties, self).__init__(description=description, data_collection_rule_id=data_collection_rule_id, data_collection_endpoint_id=data_collection_endpoint_id, **kwargs) + super().__init__( + description=description, + data_collection_rule_id=data_collection_rule_id, + data_collection_endpoint_id=data_collection_endpoint_id, + **kwargs + ) class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): @@ -1078,7 +1068,7 @@ class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): :ivar created_by: The identity that created the resource. :vartype created_by: str :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). @@ -1086,7 +1076,7 @@ class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -1094,12 +1084,12 @@ class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): """ _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__( @@ -1117,7 +1107,7 @@ def __init__( :keyword created_by: The identity that created the resource. :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). @@ -1125,16 +1115,24 @@ def __init__( :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(DataCollectionRuleAssociationProxyOnlyResourceSystemData, self).__init__(created_by=created_by, created_by_type=created_by_type, created_at=created_at, last_modified_by=last_modified_by, last_modified_by_type=last_modified_by_type, last_modified_at=last_modified_at, **kwargs) + super().__init__( + created_by=created_by, + created_by_type=created_by_type, + created_at=created_at, + last_modified_by=last_modified_by, + last_modified_by_type=last_modified_by_type, + last_modified_at=last_modified_at, + **kwargs + ) -class DataSourcesSpec(msrest.serialization.Model): +class DataSourcesSpec(_serialization.Model): """Specification of data sources that will be collected. :ivar performance_counters: The list of performance counter data source configurations. @@ -1156,12 +1154,12 @@ class DataSourcesSpec(msrest.serialization.Model): """ _attribute_map = { - 'performance_counters': {'key': 'performanceCounters', 'type': '[PerfCounterDataSource]'}, - 'windows_event_logs': {'key': 'windowsEventLogs', 'type': '[WindowsEventLogDataSource]'}, - 'syslog': {'key': 'syslog', 'type': '[SyslogDataSource]'}, - 'extensions': {'key': 'extensions', 'type': '[ExtensionDataSource]'}, - 'log_files': {'key': 'logFiles', 'type': '[LogFilesDataSource]'}, - 'iis_logs': {'key': 'iisLogs', 'type': '[IisLogsDataSource]'}, + "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, + "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, + "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, + "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, + "log_files": {"key": "logFiles", "type": "[LogFilesDataSource]"}, + "iis_logs": {"key": "iisLogs", "type": "[IisLogsDataSource]"}, } def __init__( @@ -1194,7 +1192,7 @@ def __init__( :paramtype iis_logs: list[~$(python-base-namespace).v2022_02_01_preview.models.IisLogsDataSource] """ - super(DataSourcesSpec, self).__init__(**kwargs) + super().__init__(**kwargs) self.performance_counters = performance_counters self.windows_event_logs = windows_event_logs self.syslog = syslog @@ -1204,34 +1202,34 @@ def __init__( class DataCollectionRuleDataSources(DataSourcesSpec): - """The specification of data sources. -This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. + """The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~$(python-base-namespace).v2022_02_01_preview.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~$(python-base-namespace).v2022_02_01_preview.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~$(python-base-namespace).v2022_02_01_preview.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: - list[~$(python-base-namespace).v2022_02_01_preview.models.ExtensionDataSource] - :ivar log_files: The list of Log files source configurations. - :vartype log_files: - list[~$(python-base-namespace).v2022_02_01_preview.models.LogFilesDataSource] - :ivar iis_logs: The list of IIS logs source configurations. - :vartype iis_logs: list[~$(python-base-namespace).v2022_02_01_preview.models.IisLogsDataSource] + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: + list[~$(python-base-namespace).v2022_02_01_preview.models.PerfCounterDataSource] + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: + list[~$(python-base-namespace).v2022_02_01_preview.models.WindowsEventLogDataSource] + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2022_02_01_preview.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: + list[~$(python-base-namespace).v2022_02_01_preview.models.ExtensionDataSource] + :ivar log_files: The list of Log files source configurations. + :vartype log_files: + list[~$(python-base-namespace).v2022_02_01_preview.models.LogFilesDataSource] + :ivar iis_logs: The list of IIS logs source configurations. + :vartype iis_logs: list[~$(python-base-namespace).v2022_02_01_preview.models.IisLogsDataSource] """ _attribute_map = { - 'performance_counters': {'key': 'performanceCounters', 'type': '[PerfCounterDataSource]'}, - 'windows_event_logs': {'key': 'windowsEventLogs', 'type': '[WindowsEventLogDataSource]'}, - 'syslog': {'key': 'syslog', 'type': '[SyslogDataSource]'}, - 'extensions': {'key': 'extensions', 'type': '[ExtensionDataSource]'}, - 'log_files': {'key': 'logFiles', 'type': '[LogFilesDataSource]'}, - 'iis_logs': {'key': 'iisLogs', 'type': '[IisLogsDataSource]'}, + "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, + "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, + "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, + "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, + "log_files": {"key": "logFiles", "type": "[LogFilesDataSource]"}, + "iis_logs": {"key": "iisLogs", "type": "[IisLogsDataSource]"}, } def __init__( @@ -1264,10 +1262,18 @@ def __init__( :paramtype iis_logs: list[~$(python-base-namespace).v2022_02_01_preview.models.IisLogsDataSource] """ - super(DataCollectionRuleDataSources, self).__init__(performance_counters=performance_counters, windows_event_logs=windows_event_logs, syslog=syslog, extensions=extensions, log_files=log_files, iis_logs=iis_logs, **kwargs) + super().__init__( + performance_counters=performance_counters, + windows_event_logs=windows_event_logs, + syslog=syslog, + extensions=extensions, + log_files=log_files, + iis_logs=iis_logs, + **kwargs + ) -class DestinationsSpec(msrest.serialization.Model): +class DestinationsSpec(_serialization.Model): """Specification of destinations that can be used in data flows. :ivar log_analytics: List of Log Analytics destinations. @@ -1279,8 +1285,8 @@ class DestinationsSpec(msrest.serialization.Model): """ _attribute_map = { - 'log_analytics': {'key': 'logAnalytics', 'type': '[LogAnalyticsDestination]'}, - 'azure_monitor_metrics': {'key': 'azureMonitorMetrics', 'type': 'DestinationsSpecAzureMonitorMetrics'}, + "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, + "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, } def __init__( @@ -1298,7 +1304,7 @@ def __init__( :paramtype azure_monitor_metrics: ~$(python-base-namespace).v2022_02_01_preview.models.DestinationsSpecAzureMonitorMetrics """ - super(DestinationsSpec, self).__init__(**kwargs) + super().__init__(**kwargs) self.log_analytics = log_analytics self.azure_monitor_metrics = azure_monitor_metrics @@ -1315,8 +1321,8 @@ class DataCollectionRuleDestinations(DestinationsSpec): """ _attribute_map = { - 'log_analytics': {'key': 'logAnalytics', 'type': '[LogAnalyticsDestination]'}, - 'azure_monitor_metrics': {'key': 'azureMonitorMetrics', 'type': 'DestinationsSpecAzureMonitorMetrics'}, + "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, + "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, } def __init__( @@ -1334,7 +1340,7 @@ def __init__( :paramtype azure_monitor_metrics: ~$(python-base-namespace).v2022_02_01_preview.models.DestinationsSpecAzureMonitorMetrics """ - super(DataCollectionRuleDestinations, self).__init__(log_analytics=log_analytics, azure_monitor_metrics=azure_monitor_metrics, **kwargs) + super().__init__(log_analytics=log_analytics, azure_monitor_metrics=azure_monitor_metrics, **kwargs) class DataCollectionRuleMetadata(Metadata): @@ -1347,34 +1353,30 @@ class DataCollectionRuleMetadata(Metadata): """ _validation = { - 'provisioned_by': {'readonly': True}, + "provisioned_by": {"readonly": True}, } _attribute_map = { - 'provisioned_by': {'key': 'provisionedBy', 'type': 'str'}, + "provisioned_by": {"key": "provisionedBy", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DataCollectionRuleMetadata, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class DataCollectionRuleResource(msrest.serialization.Model): +class DataCollectionRuleResource(_serialization.Model): # pylint: disable=too-many-instance-attributes """Definition of ARM tracked top level 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 location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Known values are: "Linux", "Windows". + :ivar kind: The kind of the resource. Known values are: "Linux" and "Windows". :vartype kind: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleResourceKind :ivar id: Fully qualified ID of the resource. @@ -1412,41 +1414,41 @@ class DataCollectionRuleResource(msrest.serialization.Model): :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2022_02_01_preview.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleProvisioningState """ _validation = { - 'location': {'required': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'immutable_id': {'readonly': True}, - 'metadata': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "location": {"required": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "system_data": {"readonly": True}, + "immutable_id": {"readonly": True}, + "metadata": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'DataCollectionRuleResourceSystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'immutable_id': {'key': 'properties.immutableId', 'type': 'str'}, - 'data_collection_endpoint_id': {'key': 'properties.dataCollectionEndpointId', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': 'DataCollectionRuleMetadata'}, - 'stream_declarations': {'key': 'properties.streamDeclarations', 'type': '{StreamDeclaration}'}, - 'data_sources': {'key': 'properties.dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'properties.destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'properties.dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "kind": {"key": "kind", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "system_data": {"key": "systemData", "type": "DataCollectionRuleResourceSystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "immutable_id": {"key": "properties.immutableId", "type": "str"}, + "data_collection_endpoint_id": {"key": "properties.dataCollectionEndpointId", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "DataCollectionRuleMetadata"}, + "stream_declarations": {"key": "properties.streamDeclarations", "type": "{StreamDeclaration}"}, + "data_sources": {"key": "properties.dataSources", "type": "DataCollectionRuleDataSources"}, + "destinations": {"key": "properties.destinations", "type": "DataCollectionRuleDestinations"}, + "data_flows": {"key": "properties.dataFlows", "type": "[DataFlow]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -1464,11 +1466,11 @@ def __init__( **kwargs ): """ - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Known values are: "Linux", "Windows". + :keyword kind: The kind of the resource. Known values are: "Linux" and "Windows". :paramtype kind: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleResourceKind :keyword description: Description of the data collection rule. @@ -1490,7 +1492,7 @@ def __init__( :keyword data_flows: The specification of data flows. :paramtype data_flows: list[~$(python-base-namespace).v2022_02_01_preview.models.DataFlow] """ - super(DataCollectionRuleResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.kind = kind @@ -1510,12 +1512,12 @@ def __init__( self.provisioning_state = None -class DataCollectionRuleResourceListResult(msrest.serialization.Model): +class DataCollectionRuleResourceListResult(_serialization.Model): """A pageable list of resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. A list of resources. + :ivar value: A list of resources. Required. :vartype value: list[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource] :ivar next_link: The URL to use for getting the next set of results. @@ -1523,29 +1525,23 @@ class DataCollectionRuleResourceListResult(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCollectionRuleResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataCollectionRuleResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["_models.DataCollectionRuleResource"], - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs): """ - :keyword value: Required. A list of resources. + :keyword value: A list of resources. Required. :paramtype value: list[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ - super(DataCollectionRuleResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1579,27 +1575,27 @@ class DataCollectionRuleResourceProperties(DataCollectionRule): :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2022_02_01_preview.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". + "Updating", "Deleting", "Succeeded", and "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleProvisioningState """ _validation = { - 'immutable_id': {'readonly': True}, - 'metadata': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "immutable_id": {"readonly": True}, + "metadata": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'data_collection_endpoint_id': {'key': 'dataCollectionEndpointId', 'type': 'str'}, - 'metadata': {'key': 'metadata', 'type': 'DataCollectionRuleMetadata'}, - 'stream_declarations': {'key': 'streamDeclarations', 'type': '{StreamDeclaration}'}, - 'data_sources': {'key': 'dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "immutable_id": {"key": "immutableId", "type": "str"}, + "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, + "metadata": {"key": "metadata", "type": "DataCollectionRuleMetadata"}, + "stream_declarations": {"key": "streamDeclarations", "type": "{StreamDeclaration}"}, + "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, + "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, + "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( @@ -1633,7 +1629,15 @@ def __init__( :keyword data_flows: The specification of data flows. :paramtype data_flows: list[~$(python-base-namespace).v2022_02_01_preview.models.DataFlow] """ - super(DataCollectionRuleResourceProperties, self).__init__(description=description, data_collection_endpoint_id=data_collection_endpoint_id, stream_declarations=stream_declarations, data_sources=data_sources, destinations=destinations, data_flows=data_flows, **kwargs) + super().__init__( + description=description, + data_collection_endpoint_id=data_collection_endpoint_id, + stream_declarations=stream_declarations, + data_sources=data_sources, + destinations=destinations, + data_flows=data_flows, + **kwargs + ) class DataCollectionRuleResourceSystemData(SystemData): @@ -1642,7 +1646,7 @@ class DataCollectionRuleResourceSystemData(SystemData): :ivar created_by: The identity that created the resource. :vartype created_by: str :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). @@ -1650,7 +1654,7 @@ class DataCollectionRuleResourceSystemData(SystemData): :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -1658,12 +1662,12 @@ class DataCollectionRuleResourceSystemData(SystemData): """ _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__( @@ -1681,7 +1685,7 @@ def __init__( :keyword created_by: The identity that created the resource. :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). @@ -1689,16 +1693,24 @@ def __init__( :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(DataCollectionRuleResourceSystemData, self).__init__(created_by=created_by, created_by_type=created_by_type, created_at=created_at, last_modified_by=last_modified_by, last_modified_by_type=last_modified_by_type, last_modified_at=last_modified_at, **kwargs) + super().__init__( + created_by=created_by, + created_by_type=created_by_type, + created_at=created_at, + last_modified_by=last_modified_by, + last_modified_by_type=last_modified_by_type, + last_modified_at=last_modified_at, + **kwargs + ) -class DataFlow(msrest.serialization.Model): +class DataFlow(_serialization.Model): """Definition of which streams are sent to which destinations. :ivar streams: List of streams for this data flow. @@ -1714,10 +1726,10 @@ class DataFlow(msrest.serialization.Model): """ _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'destinations': {'key': 'destinations', 'type': '[str]'}, - 'transform_kql': {'key': 'transformKql', 'type': 'str'}, - 'output_stream': {'key': 'outputStream', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "destinations": {"key": "destinations", "type": "[str]"}, + "transform_kql": {"key": "transformKql", "type": "str"}, + "output_stream": {"key": "outputStream", "type": "str"}, } def __init__( @@ -1741,7 +1753,7 @@ def __init__( changes data to a different stream. :paramtype output_stream: str """ - super(DataFlow, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.destinations = destinations self.transform_kql = transform_kql @@ -1758,25 +1770,20 @@ class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. :paramtype name: str """ - super(DestinationsSpecAzureMonitorMetrics, self).__init__(name=name, **kwargs) + super().__init__(name=name, **kwargs) -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -1784,31 +1791,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -1827,28 +1830,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -1856,7 +1855,7 @@ def __init__( self.additional_info = None -class ErrorResponseCommonV2(msrest.serialization.Model): +class ErrorResponseCommonV2(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. @@ -1864,57 +1863,52 @@ class ErrorResponseCommonV2(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~$(python-base-namespace).v2022_02_01_preview.models.ErrorDetail """ - super(ErrorResponseCommonV2, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ExtensionDataSource(msrest.serialization.Model): +class ExtensionDataSource(_serialization.Model): """Definition of which data will be collected from a separate VM extension that integrates with the Azure Monitor Agent. -Collected from either Windows and Linux machines, depending on which extension is defined. + Collected from either Windows and Linux machines, depending on which extension is defined. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to Azure. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2022_02_01_preview.models.KnownExtensionDataSourceStreams] - :ivar extension_name: Required. The name of the VM extension. - :vartype extension_name: str - :ivar extension_settings: The extension settings. The format is specific for particular - extension. - :vartype extension_settings: any - :ivar input_data_sources: The list of data sources this extension needs data from. - :vartype input_data_sources: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2022_02_01_preview.models.KnownExtensionDataSourceStreams] + :ivar extension_name: The name of the VM extension. Required. + :vartype extension_name: str + :ivar extension_settings: The extension settings. The format is specific for particular + extension. + :vartype extension_settings: JSON + :ivar input_data_sources: The list of data sources this extension needs data from. + :vartype input_data_sources: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _validation = { - 'extension_name': {'required': True}, + "extension_name": {"required": True}, } _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'extension_name': {'key': 'extensionName', 'type': 'str'}, - 'extension_settings': {'key': 'extensionSettings', 'type': 'object'}, - 'input_data_sources': {'key': 'inputDataSources', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "extension_name": {"key": "extensionName", "type": "str"}, + "extension_settings": {"key": "extensionSettings", "type": "object"}, + "input_data_sources": {"key": "inputDataSources", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -1922,7 +1916,7 @@ def __init__( *, extension_name: str, streams: Optional[List[Union[str, "_models.KnownExtensionDataSourceStreams"]]] = None, - extension_settings: Optional[Any] = None, + extension_settings: Optional[JSON] = None, input_data_sources: Optional[List[str]] = None, name: Optional[str] = None, **kwargs @@ -1933,11 +1927,11 @@ def __init__( Analytics the data will be sent to. :paramtype streams: list[str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownExtensionDataSourceStreams] - :keyword extension_name: Required. The name of the VM extension. + :keyword extension_name: The name of the VM extension. Required. :paramtype extension_name: str :keyword extension_settings: The extension settings. The format is specific for particular extension. - :paramtype extension_settings: any + :paramtype extension_settings: JSON :keyword input_data_sources: The list of data sources this extension needs data from. :paramtype input_data_sources: list[str] :keyword name: A friendly name for the data source. @@ -1945,7 +1939,7 @@ def __init__( collection rule. :paramtype name: str """ - super(ExtensionDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.extension_name = extension_name self.extension_settings = extension_settings @@ -1953,12 +1947,12 @@ def __init__( self.name = name -class IisLogsDataSource(msrest.serialization.Model): +class IisLogsDataSource(_serialization.Model): """Enables IIS logs to be collected by this data collection rule. All required parameters must be populated in order to send to Azure. - :ivar streams: Required. IIS streams. + :ivar streams: IIS streams. Required. :vartype streams: list[str] :ivar log_directories: Absolute paths file location. :vartype log_directories: list[str] @@ -1969,25 +1963,20 @@ class IisLogsDataSource(msrest.serialization.Model): """ _validation = { - 'streams': {'required': True}, + "streams": {"required": True}, } _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'log_directories': {'key': 'logDirectories', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "log_directories": {"key": "logDirectories", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( - self, - *, - streams: List[str], - log_directories: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs + self, *, streams: List[str], log_directories: Optional[List[str]] = None, name: Optional[str] = None, **kwargs ): """ - :keyword streams: Required. IIS streams. + :keyword streams: IIS streams. Required. :paramtype streams: list[str] :keyword log_directories: Absolute paths file location. :paramtype log_directories: list[str] @@ -1996,13 +1985,13 @@ def __init__( collection rule. :paramtype name: str """ - super(IisLogsDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.log_directories = log_directories self.name = name -class LogAnalyticsDestination(msrest.serialization.Model): +class LogAnalyticsDestination(_serialization.Model): """Log Analytics destination. Variables are only populated by the server, and will be ignored when sending a request. @@ -2018,22 +2007,16 @@ class LogAnalyticsDestination(msrest.serialization.Model): """ _validation = { - 'workspace_id': {'readonly': True}, + "workspace_id": {"readonly": True}, } _attribute_map = { - 'workspace_resource_id': {'key': 'workspaceResourceId', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "workspace_resource_id": {"key": "workspaceResourceId", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - workspace_resource_id: Optional[str] = None, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, workspace_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs): """ :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. :paramtype workspace_resource_id: str @@ -2042,23 +2025,23 @@ def __init__( collection rule. :paramtype name: str """ - super(LogAnalyticsDestination, self).__init__(**kwargs) + super().__init__(**kwargs) self.workspace_resource_id = workspace_resource_id self.workspace_id = None self.name = name -class LogFilesDataSource(msrest.serialization.Model): +class LogFilesDataSource(_serialization.Model): """Definition of which custom log files will be collected by this data collection rule. All required parameters must be populated in order to send to Azure. - :ivar streams: Required. List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data source. + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data source. Required. :vartype streams: list[str] - :ivar file_patterns: Required. File Patterns where the log files are located. + :ivar file_patterns: File Patterns where the log files are located. Required. :vartype file_patterns: list[str] - :ivar format: Required. The data format of the log files. Known values are: "text". + :ivar format: The data format of the log files. Required. "text" :vartype format: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownLogFilesDataSourceFormat :ivar settings: The log files specific settings. @@ -2071,17 +2054,17 @@ class LogFilesDataSource(msrest.serialization.Model): """ _validation = { - 'streams': {'required': True}, - 'file_patterns': {'required': True}, - 'format': {'required': True}, + "streams": {"required": True}, + "file_patterns": {"required": True}, + "format": {"required": True}, } _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'file_patterns': {'key': 'filePatterns', 'type': '[str]'}, - 'format': {'key': 'format', 'type': 'str'}, - 'settings': {'key': 'settings', 'type': 'LogFilesDataSourceSettings'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "file_patterns": {"key": "filePatterns", "type": "[str]"}, + "format": {"key": "format", "type": "str"}, + "settings": {"key": "settings", "type": "LogFilesDataSourceSettings"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -2095,12 +2078,12 @@ def __init__( **kwargs ): """ - :keyword streams: Required. List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data source. + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data source. Required. :paramtype streams: list[str] - :keyword file_patterns: Required. File Patterns where the log files are located. + :keyword file_patterns: File Patterns where the log files are located. Required. :paramtype file_patterns: list[str] - :keyword format: Required. The data format of the log files. Known values are: "text". + :keyword format: The data format of the log files. Required. "text" :paramtype format: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownLogFilesDataSourceFormat :keyword settings: The log files specific settings. @@ -2111,7 +2094,7 @@ def __init__( collection rule. :paramtype name: str """ - super(LogFilesDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.file_patterns = file_patterns self.format = format @@ -2119,7 +2102,7 @@ def __init__( self.name = name -class LogFileSettings(msrest.serialization.Model): +class LogFileSettings(_serialization.Model): """Settings for different log file formats. :ivar text: Text settings. @@ -2127,20 +2110,15 @@ class LogFileSettings(msrest.serialization.Model): """ _attribute_map = { - 'text': {'key': 'text', 'type': 'LogFileSettingsText'}, + "text": {"key": "text", "type": "LogFileSettingsText"}, } - def __init__( - self, - *, - text: Optional["_models.LogFileSettingsText"] = None, - **kwargs - ): + def __init__(self, *, text: Optional["_models.LogFileSettingsText"] = None, **kwargs): """ :keyword text: Text settings. :paramtype text: ~$(python-base-namespace).v2022_02_01_preview.models.LogFileSettingsText """ - super(LogFileSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.text = text @@ -2152,41 +2130,36 @@ class LogFilesDataSourceSettings(LogFileSettings): """ _attribute_map = { - 'text': {'key': 'text', 'type': 'LogFileSettingsText'}, + "text": {"key": "text", "type": "LogFileSettingsText"}, } - def __init__( - self, - *, - text: Optional["_models.LogFileSettingsText"] = None, - **kwargs - ): + def __init__(self, *, text: Optional["_models.LogFileSettingsText"] = None, **kwargs): """ :keyword text: Text settings. :paramtype text: ~$(python-base-namespace).v2022_02_01_preview.models.LogFileSettingsText """ - super(LogFilesDataSourceSettings, self).__init__(text=text, **kwargs) + super().__init__(text=text, **kwargs) -class LogFileTextSettings(msrest.serialization.Model): +class LogFileTextSettings(_serialization.Model): """Settings for text log files. All required parameters must be populated in order to send to Azure. - :ivar record_start_timestamp_format: Required. One of the supported timestamp formats. Known + :ivar record_start_timestamp_format: One of the supported timestamp formats. Required. Known values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", - "yyyy-MM-ddTHH:mm:ssK". + and "yyyy-MM-ddTHH:mm:ssK". :vartype record_start_timestamp_format: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownLogFileTextSettingsRecordStartTimestampFormat """ _validation = { - 'record_start_timestamp_format': {'required': True}, + "record_start_timestamp_format": {"required": True}, } _attribute_map = { - 'record_start_timestamp_format': {'key': 'recordStartTimestampFormat', 'type': 'str'}, + "record_start_timestamp_format": {"key": "recordStartTimestampFormat", "type": "str"}, } def __init__( @@ -2196,14 +2169,14 @@ def __init__( **kwargs ): """ - :keyword record_start_timestamp_format: Required. One of the supported timestamp formats. Known + :keyword record_start_timestamp_format: One of the supported timestamp formats. Required. Known values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", - "yyyy-MM-ddTHH:mm:ssK". + and "yyyy-MM-ddTHH:mm:ssK". :paramtype record_start_timestamp_format: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownLogFileTextSettingsRecordStartTimestampFormat """ - super(LogFileTextSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.record_start_timestamp_format = record_start_timestamp_format @@ -2212,20 +2185,20 @@ class LogFileSettingsText(LogFileTextSettings): All required parameters must be populated in order to send to Azure. - :ivar record_start_timestamp_format: Required. One of the supported timestamp formats. Known + :ivar record_start_timestamp_format: One of the supported timestamp formats. Required. Known values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", - "yyyy-MM-ddTHH:mm:ssK". + and "yyyy-MM-ddTHH:mm:ssK". :vartype record_start_timestamp_format: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownLogFileTextSettingsRecordStartTimestampFormat """ _validation = { - 'record_start_timestamp_format': {'required': True}, + "record_start_timestamp_format": {"required": True}, } _attribute_map = { - 'record_start_timestamp_format': {'key': 'recordStartTimestampFormat', 'type': 'str'}, + "record_start_timestamp_format": {"key": "recordStartTimestampFormat", "type": "str"}, } def __init__( @@ -2235,44 +2208,44 @@ def __init__( **kwargs ): """ - :keyword record_start_timestamp_format: Required. One of the supported timestamp formats. Known + :keyword record_start_timestamp_format: One of the supported timestamp formats. Required. Known values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", - "yyyy-MM-ddTHH:mm:ssK". + and "yyyy-MM-ddTHH:mm:ssK". :paramtype record_start_timestamp_format: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownLogFileTextSettingsRecordStartTimestampFormat """ - super(LogFileSettingsText, self).__init__(record_start_timestamp_format=record_start_timestamp_format, **kwargs) + super().__init__(record_start_timestamp_format=record_start_timestamp_format, **kwargs) -class PerfCounterDataSource(msrest.serialization.Model): +class PerfCounterDataSource(_serialization.Model): """Definition of which performance counters will be collected and how they will be collected by this data collection rule. -Collected from both Windows and Linux machines where the counter is present. + Collected from both Windows and Linux machines where the counter is present. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2022_02_01_preview.models.KnownPerfCounterDataSourceStreams] - :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :vartype sampling_frequency_in_seconds: int - :ivar counter_specifiers: A list of specifier names of the performance counters you want to - collect. - Use a wildcard (*) to collect a counter for all instances. - To get a list of performance counters on Windows, run the command 'typeperf'. - :vartype counter_specifiers: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2022_02_01_preview.models.KnownPerfCounterDataSourceStreams] + :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter + measurements (samples). + :vartype sampling_frequency_in_seconds: int + :ivar counter_specifiers: A list of specifier names of the performance counters you want to + collect. + Use a wildcard (*) to collect a counter for all instances. + To get a list of performance counters on Windows, run the command 'typeperf'. + :vartype counter_specifiers: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'sampling_frequency_in_seconds': {'key': 'samplingFrequencyInSeconds', 'type': 'int'}, - 'counter_specifiers': {'key': 'counterSpecifiers', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "sampling_frequency_in_seconds": {"key": "samplingFrequencyInSeconds", "type": "int"}, + "counter_specifiers": {"key": "counterSpecifiers", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -2303,39 +2276,34 @@ def __init__( collection rule. :paramtype name: str """ - super(PerfCounterDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.sampling_frequency_in_seconds = sampling_frequency_in_seconds self.counter_specifiers = counter_specifiers self.name = name -class ResourceForUpdate(msrest.serialization.Model): +class ResourceForUpdate(_serialization.Model): """Definition of ARM tracked top level resource properties for update operation. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :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 - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceForUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class StreamDeclaration(msrest.serialization.Model): +class StreamDeclaration(_serialization.Model): """Declaration of a custom stream. :ivar columns: List of columns used by data in this stream. @@ -2343,49 +2311,44 @@ class StreamDeclaration(msrest.serialization.Model): """ _attribute_map = { - 'columns': {'key': 'columns', 'type': '[ColumnDefinition]'}, + "columns": {"key": "columns", "type": "[ColumnDefinition]"}, } - def __init__( - self, - *, - columns: Optional[List["_models.ColumnDefinition"]] = None, - **kwargs - ): + def __init__(self, *, columns: Optional[List["_models.ColumnDefinition"]] = None, **kwargs): """ :keyword columns: List of columns used by data in this stream. :paramtype columns: list[~$(python-base-namespace).v2022_02_01_preview.models.ColumnDefinition] """ - super(StreamDeclaration, self).__init__(**kwargs) + super().__init__(**kwargs) self.columns = columns -class SyslogDataSource(msrest.serialization.Model): +class SyslogDataSource(_serialization.Model): """Definition of which syslog data will be collected and how it will be collected. -Only collected from Linux machines. + Only collected from Linux machines. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2022_02_01_preview.models.KnownSyslogDataSourceStreams] - :ivar facility_names: The list of facility names. - :vartype facility_names: list[str or - ~$(python-base-namespace).v2022_02_01_preview.models.KnownSyslogDataSourceFacilityNames] - :ivar log_levels: The log levels to collect. - :vartype log_levels: list[str or - ~$(python-base-namespace).v2022_02_01_preview.models.KnownSyslogDataSourceLogLevels] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2022_02_01_preview.models.KnownSyslogDataSourceStreams] + :ivar facility_names: The list of facility names. + :vartype facility_names: list[str or + ~$(python-base-namespace).v2022_02_01_preview.models.KnownSyslogDataSourceFacilityNames] + :ivar log_levels: The log levels to collect. + :vartype log_levels: list[str or + ~$(python-base-namespace).v2022_02_01_preview.models.KnownSyslogDataSourceLogLevels] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'facility_names': {'key': 'facilityNames', 'type': '[str]'}, - 'log_levels': {'key': 'logLevels', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "facility_names": {"key": "facilityNames", "type": "[str]"}, + "log_levels": {"key": "logLevels", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -2414,34 +2377,34 @@ def __init__( collection rule. :paramtype name: str """ - super(SyslogDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.facility_names = facility_names self.log_levels = log_levels self.name = name -class WindowsEventLogDataSource(msrest.serialization.Model): +class WindowsEventLogDataSource(_serialization.Model): """Definition of which Windows Event Log events will be collected and how they will be collected. -Only collected from Windows machines. + Only collected from Windows machines. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2022_02_01_preview.models.KnownWindowsEventLogDataSourceStreams] - :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. - :vartype x_path_queries: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2022_02_01_preview.models.KnownWindowsEventLogDataSourceStreams] + :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. + :vartype x_path_queries: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'x_path_queries': {'key': 'xPathQueries', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "streams": {"key": "streams", "type": "[str]"}, + "x_path_queries": {"key": "xPathQueries", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -2465,7 +2428,7 @@ def __init__( collection rule. :paramtype name: str """ - super(WindowsEventLogDataSource, self).__init__(**kwargs) + super().__init__(**kwargs) self.streams = streams self.x_path_queries = x_path_queries self.name = name diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_monitor_management_client_enums.py index 3aef5b96e81e..0ae017838570 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_monitor_management_client_enums.py @@ -11,17 +11,16 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class KnownColumnDefinitionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the column data. - """ + """The type of the column data.""" STRING = "string" INT = "int" @@ -31,9 +30,9 @@ class KnownColumnDefinitionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): DATETIME = "datetime" DYNAMIC = "dynamic" + class KnownDataCollectionEndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state. This property is READ-ONLY. - """ + """The resource provisioning state. This property is READ-ONLY.""" CREATING = "Creating" UPDATING = "Updating" @@ -41,16 +40,16 @@ class KnownDataCollectionEndpointProvisioningState(str, Enum, metaclass=CaseInse SUCCEEDED = "Succeeded" FAILED = "Failed" + class KnownDataCollectionEndpointResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the resource. - """ + """The kind of the resource.""" LINUX = "Linux" WINDOWS = "Windows" + class KnownDataCollectionRuleAssociationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state. - """ + """The resource provisioning state.""" CREATING = "Creating" UPDATING = "Updating" @@ -58,9 +57,9 @@ class KnownDataCollectionRuleAssociationProvisioningState(str, Enum, metaclass=C SUCCEEDED = "Succeeded" FAILED = "Failed" + class KnownDataCollectionRuleProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state. - """ + """The resource provisioning state.""" CREATING = "Creating" UPDATING = "Updating" @@ -68,14 +67,16 @@ class KnownDataCollectionRuleProvisioningState(str, Enum, metaclass=CaseInsensit SUCCEEDED = "Succeeded" FAILED = "Failed" + class KnownDataCollectionRuleResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the resource. - """ + """The kind of the resource.""" LINUX = "Linux" WINDOWS = "Windows" + class KnownDataFlowStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownDataFlowStreams.""" MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -83,7 +84,9 @@ class KnownDataFlowStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" + class KnownExtensionDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownExtensionDataSourceStreams.""" MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -91,15 +94,15 @@ class KnownExtensionDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMe MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" + class KnownLogFilesDataSourceFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The data format of the log files - """ + """The data format of the log files.""" TEXT = "text" + class KnownLogFileTextSettingsRecordStartTimestampFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """One of the supported timestamp formats - """ + """One of the supported timestamp formats.""" ISO8601 = "ISO 8601" YYYY_MM_DD_HH_MM_SS = "YYYY-MM-DD HH:MM:SS" @@ -111,11 +114,14 @@ class KnownLogFileTextSettingsRecordStartTimestampFormat(str, Enum, metaclass=Ca DD_MMM_YYYY_HH_MM_SS_ZZZ = "dd/MMM/yyyy:HH:mm:ss zzz" YYYY_MM_DD_THH_MM_SS_K = "yyyy-MM-ddTHH:mm:ssK" + class KnownPerfCounterDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownPerfCounterDataSourceStreams.""" MICROSOFT_PERF = "Microsoft-Perf" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" + class KnownPublicNetworkAccessOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The configuration to set whether network access from public internet to the endpoints are allowed. @@ -124,7 +130,9 @@ class KnownPublicNetworkAccessOptions(str, Enum, metaclass=CaseInsensitiveEnumMe ENABLED = "Enabled" DISABLED = "Disabled" + class KnownSyslogDataSourceFacilityNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownSyslogDataSourceFacilityNames.""" AUTH = "auth" AUTHPRIV = "authpriv" @@ -148,7 +156,9 @@ class KnownSyslogDataSourceFacilityNames(str, Enum, metaclass=CaseInsensitiveEnu LOCAL7 = "local7" ASTERISK = "*" + class KnownSyslogDataSourceLogLevels(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownSyslogDataSourceLogLevels.""" DEBUG = "Debug" INFO = "Info" @@ -160,11 +170,15 @@ class KnownSyslogDataSourceLogLevels(str, Enum, metaclass=CaseInsensitiveEnumMet EMERGENCY = "Emergency" ASTERISK = "*" + class KnownSyslogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownSyslogDataSourceStreams.""" MICROSOFT_SYSLOG = "Microsoft-Syslog" + class KnownWindowsEventLogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KnownWindowsEventLogDataSourceStreams.""" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" MICROSOFT_EVENT = "Microsoft-Event" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/__init__.py index eea5749564d8..9d11e549f9e4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/__init__.py @@ -13,10 +13,11 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DataCollectionEndpointsOperations', - 'DataCollectionRuleAssociationsOperations', - 'DataCollectionRulesOperations', + "DataCollectionEndpointsOperations", + "DataCollectionRuleAssociationsOperations", + "DataCollectionRulesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_endpoints_operations.py index d861321fb7e0..cf69dba656ab 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_endpoints_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_endpoints_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +25,217 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any + resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionEndpointName": _SERIALIZER.url( + "data_collection_endpoint_name", data_collection_endpoint_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - subscription_id: str, - resource_group_name: str, - data_collection_endpoint_name: str, - *, - json: Optional[_models.DataCollectionEndpointResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionEndpointName": _SERIALIZER.url( + "data_collection_endpoint_name", data_collection_endpoint_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_update_request( - subscription_id: str, - resource_group_name: str, - data_collection_endpoint_name: str, - *, - json: Optional[_models.ResourceForUpdate] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionEndpointName": _SERIALIZER.url( + "data_collection_endpoint_name", data_collection_endpoint_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_delete_request( - subscription_id: str, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any + resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionEndpointName": _SERIALIZER.url( + "data_collection_endpoint_name", data_collection_endpoint_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + class DataCollectionEndpointsOperations: """ @@ -277,44 +256,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.DataCollectionEndpointResourceListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.DataCollectionEndpointResource"]: """Lists all data collection endpoints in the specified resource group. Lists all data collection endpoints in the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 DataCollectionEndpointResourceListResult or the - result of cls(response) + :return: An iterator like instance of either DataCollectionEndpointResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -322,15 +298,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -346,10 +318,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -360,45 +330,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.DataCollectionEndpointResourceListResult]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionEndpointResource"]: """Lists all data collection endpoints in the specified subscription. Lists all data collection endpoints in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResourceListResult or the - result of cls(response) + :return: An iterator like instance of either DataCollectionEndpointResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -406,14 +370,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -429,10 +390,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -443,51 +402,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any ) -> _models.DataCollectionEndpointResource: """Returns the specified data collection endpoint. Returns the specified data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource, or the result of cls(response) + :return: DataCollectionEndpointResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -495,10 +447,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -506,22 +457,54 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, data_collection_endpoint_name: str, body: Optional[_models.DataCollectionEndpointResource] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Creates or updates a data collection endpoint. + + Creates or updates a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Default value is None. + :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionEndpointResource: """Creates or updates a data collection endpoint. @@ -529,42 +512,81 @@ def create( Creates or updates a data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[Union[_models.DataCollectionEndpointResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Creates or updates a data collection endpoint. + + Creates or updates a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionEndpointResource, or the result of cls(response) + :return: DataCollectionEndpointResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionEndpointResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionEndpointResource") + else: + _json = None request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -572,10 +594,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -584,25 +605,26 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, data_collection_endpoint_name: str, body: Optional[_models.ResourceForUpdate] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionEndpointResource: """Updates part of a data collection endpoint. @@ -610,42 +632,111 @@ def update( Updates part of a data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Updates part of a data collection endpoint. + + Updates part of a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionEndpointResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional[Union[_models.ResourceForUpdate, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionEndpointResource: + """Updates part of a data collection endpoint. + + Updates part of a data collection endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_endpoint_name: The name of the data collection endpoint. The name is + case insensitive. Required. + :type data_collection_endpoint_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionEndpointResource, or the result of cls(response) + :return: DataCollectionEndpointResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] - if body is not None: - _json = self._serialize.body(body, 'ResourceForUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "ResourceForUpdate") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -653,10 +744,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -664,55 +754,49 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any ) -> None: """Deletes a data collection endpoint. Deletes a data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -720,10 +804,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -734,5 +817,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rule_associations_operations.py index 0bed24410bfa..2f08f2e5e95d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rule_associations_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,231 +25,191 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_resource_request( - resource_uri: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations") path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_rule_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_data_collection_endpoint_request( - subscription_id: str, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any + resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionEndpointName": _SERIALIZER.url( + "data_collection_endpoint_name", data_collection_endpoint_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( - resource_uri: str, - association_name: str, - **kwargs: Any -) -> HttpRequest: +def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_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_request( - resource_uri: str, - association_name: str, - *, - json: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - resource_uri: str, - association_name: str, - **kwargs: Any -) -> HttpRequest: + _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(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, 'str'), + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DataCollectionRuleAssociationsOperations: """ @@ -265,43 +230,39 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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_resource( - self, - resource_uri: str, - **kwargs: Any - ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_uri: str, **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified resource. Lists associations for the specified resource. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list_by_resource.metadata['url'], + template_url=self.list_by_resource.metadata["url"], headers=_headers, params=_params, ) @@ -309,21 +270,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -332,10 +292,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -346,54 +304,49 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore + list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore @distributed_trace def list_by_rule( - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any - ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_rule_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_rule.metadata['url'], + template_url=self.list_by_rule.metadata["url"], headers=_headers, params=_params, ) @@ -401,23 +354,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_rule_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -426,10 +376,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -440,54 +388,49 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore + list_by_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore @distributed_trace def list_by_data_collection_endpoint( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - **kwargs: Any - ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: + self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: """Lists associations for the specified data collection endpoint. Lists associations for the specified data collection endpoint. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. + case insensitive. Required. :type data_collection_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or + the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_data_collection_endpoint_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_data_collection_endpoint.metadata['url'], + template_url=self.list_by_data_collection_endpoint.metadata["url"], headers=_headers, params=_params, ) @@ -495,23 +438,20 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_data_collection_endpoint_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) + deserialized = self._deserialize( + "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -520,10 +460,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -534,50 +472,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_data_collection_endpoint.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations"} # type: ignore + list_by_data_collection_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations"} # type: ignore @distributed_trace def get( - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Returns the specified association. Returns the specified association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) + :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] - request = build_get_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -585,10 +515,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -596,57 +525,125 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - - @distributed_trace + @overload def create( self, resource_uri: str, association_name: str, body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Creates or updates an association. Creates or updates an association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) + :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create( + self, + resource_uri: str, + association_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: + """Creates or updates an association. + + Creates or updates an association. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param association_name: The name of the association. The name is case insensitive. Required. + :type association_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_uri: str, + association_name: str, + body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: + """Creates or updates an association. + + Creates or updates an association. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param association_name: The name of the association. The name is case insensitive. Required. + :type association_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: + ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) + :rtype: + ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") + else: + _json = None request = build_create_request( resource_uri=resource_uri, @@ -654,7 +651,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -662,10 +660,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -674,56 +671,49 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + create.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_uri: str, - association_name: str, - **kwargs: Any + self, resource_uri: str, association_name: str, **kwargs: Any ) -> None: """Deletes an association. Deletes an association. - :param resource_uri: The identifier of the resource. + :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. + :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_uri=resource_uri, association_name=association_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -731,10 +721,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -745,5 +734,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore - + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rules_operations.py index 82ab3b1b8442..5868f25bc5b8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rules_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,243 +25,209 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - *, - json: Optional[_models.DataCollectionRuleResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_update_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - *, - json: Optional[_models.ResourceForUpdate] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_delete_request( - subscription_id: str, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + class DataCollectionRulesOperations: """ @@ -277,44 +248,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(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_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.DataCollectionRuleResourceListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleResource"]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 DataCollectionRuleResourceListResult or the result - of cls(response) + :return: An iterator like instance of either DataCollectionRuleResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -322,15 +290,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -346,10 +310,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -360,45 +322,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.DataCollectionRuleResourceListResult]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionRuleResource"]: """Lists all data collection rules in the specified subscription. Lists all data collection rules in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result - of cls(response) + :return: An iterator like instance of either DataCollectionRuleResource or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -406,14 +362,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -429,10 +382,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -443,51 +394,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any ) -> _models.DataCollectionRuleResource: """Returns the specified data collection rule. Returns the specified data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -495,10 +439,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -506,22 +449,23 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, data_collection_rule_name: str, body: Optional[_models.DataCollectionRuleResource] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleResource: """Creates or updates a data collection rule. @@ -529,42 +473,112 @@ def create( Creates or updates a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Creates or updates a data collection rule. + + Creates or updates a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Creates or updates a data collection rule. + + Creates or updates a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - if body is not None: - _json = self._serialize.body(body, 'DataCollectionRuleResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "DataCollectionRuleResource") + else: + _json = None request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -572,10 +586,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -584,25 +597,26 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, data_collection_rule_name: str, body: Optional[_models.ResourceForUpdate] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataCollectionRuleResource: """Updates part of a data collection rule. @@ -610,42 +624,111 @@ def update( Updates part of a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: DataCollectionRuleResource, or the result of cls(response) + :return: DataCollectionRuleResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Updates part of a data collection rule. + + Updates part of a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + data_collection_rule_name: str, + body: Optional[Union[_models.ResourceForUpdate, IO]] = None, + **kwargs: Any + ) -> _models.DataCollectionRuleResource: + """Updates part of a data collection rule. + + Updates part of a data collection rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param data_collection_rule_name: The name of the data collection rule. The name is case + insensitive. Required. + :type data_collection_rule_name: str + :param body: The payload. Is either a model type or a IO type. Default value is None. + :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: DataCollectionRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] - if body is not None: - _json = self._serialize.body(body, 'ResourceForUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "ResourceForUpdate") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -653,10 +736,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -664,55 +746,49 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - data_collection_rule_name: str, - **kwargs: Any + self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any ) -> None: """Deletes a data collection rule. Deletes a data collection rule. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. + insensitive. Required. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -720,10 +796,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -734,5 +809,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py index 352bde243cfd..6510a97f9b50 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-04-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + api_version = kwargs.pop("api_version", "2022-04-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json index 5de5231ff8ca..6e8a63a85edf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py index 5bc9559c063d..7caa7070567a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -22,14 +21,15 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2022_04_01.operations.ActionGroupsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -47,23 +47,18 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -72,7 +67,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py index 5233148746fd..077f9e2dcc34 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-04-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(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-04-01") # type: str + api_version = kwargs.pop("api_version", "2022-04-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py index 11e0698e4977..9c614f848585 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2022_04_01.aio.operations.ActionGroupsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -48,23 +48,18 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -73,7 +68,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py index 60f9d62f0ead..0e396f5d7fb0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', + "ActionGroupsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_action_groups_operations.py index 5e5f094900a1..7ff2d81cc8e6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_action_groups_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,24 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._action_groups_operations import build_create_notifications_at_resource_group_level_request_initial, build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_get_test_notifications_at_resource_group_level_request, build_get_test_notifications_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_post_test_notifications_request_initial, build_update_request -T = TypeVar('T') +from ...operations._action_groups_operations import ( + build_create_notifications_at_resource_group_level_request, + build_create_or_update_request, + build_delete_request, + build_enable_receiver_request, + build_get_request, + build_get_test_notifications_at_resource_group_level_request, + build_get_test_notifications_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_post_test_notifications_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ActionGroupsOperations: """ .. warning:: @@ -45,41 +66,105 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -88,7 +173,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -96,10 +182,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -108,55 +193,47 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -164,10 +241,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,52 +251,46 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -228,10 +298,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -242,52 +311,118 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2022_04_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2022_04_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -295,10 +430,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -306,41 +440,43 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore async def _post_test_notifications_initial( - self, - notification_request: _models.NotificationRequestBody, - **kwargs: Any + self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_post_test_notifications_request_initial( + request = build_post_test_notifications_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._post_test_notifications_initial.metadata['url'], + content=_content, + template_url=self._post_test_notifications_initial.metadata["url"], headers=_headers, params=_params, ) @@ -348,44 +484,48 @@ async def _post_test_notifications_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _post_test_notifications_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _post_test_notifications_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore - - @distributed_trace_async + @overload async def begin_post_test_notifications( self, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -398,86 +538,138 @@ async def begin_post_test_notifications( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_post_test_notifications( + self, notification_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_post_test_notifications( + self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._post_test_notifications_initial( # type: ignore notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_post_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_post_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore async def _create_notifications_at_resource_group_level_initial( - self, - resource_group_name: str, - notification_request: _models.NotificationRequestBody, - **kwargs: Any + self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_create_notifications_at_resource_group_level_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_notifications_at_resource_group_level_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_notifications_at_resource_group_level_initial.metadata['url'], + content=_content, + template_url=self._create_notifications_at_resource_group_level_initial.metadata["url"], headers=_headers, params=_params, ) @@ -485,47 +677,87 @@ async def _create_notifications_at_resource_group_level_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_notifications_at_resource_group_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore - + _create_notifications_at_resource_group_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore - @distributed_trace_async + @overload async def begin_create_notifications_at_resource_group_level( self, resource_group_name: str, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 @@ -538,92 +770,113 @@ async def begin_create_notifications_at_resource_group_level( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_notifications_at_resource_group_level( + self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_notifications_at_resource_group_level_initial( # type: ignore resource_group_name=resource_group_name, notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_create_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore @distributed_trace_async async def get_test_notifications( - self, - notification_id: str, - **kwargs: Any + self, notification_id: str, **kwargs: Any ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_request( - subscription_id=self._config.subscription_id, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications.metadata['url'], + template_url=self.get_test_notifications.metadata["url"], headers=_headers, params=_params, ) @@ -631,10 +884,9 @@ async def get_test_notifications( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -642,52 +894,46 @@ async def get_test_notifications( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore @distributed_trace_async async def get_test_notifications_at_resource_group_level( - self, - resource_group_name: str, - notification_id: str, - **kwargs: Any + self, resource_group_name: str, notification_id: str, **kwargs: Any ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_at_resource_group_level_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications_at_resource_group_level.metadata['url'], + template_url=self.get_test_notifications_at_resource_group_level.metadata["url"], headers=_headers, params=_params, ) @@ -695,10 +941,9 @@ async def get_test_notifications_at_resource_group_level( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -706,46 +951,41 @@ async def get_test_notifications_at_resource_group_level( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_04_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_04_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -753,14 +993,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -776,10 +1013,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -790,46 +1025,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_04_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_04_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -837,15 +1068,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -861,10 +1088,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -875,47 +1100,116 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore - @distributed_trace_async + @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2022_04_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2022_04_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -924,7 +1218,8 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -932,10 +1227,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -946,5 +1240,4 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/__init__.py index 7d4cce34b707..c2c49e9b3b64 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/__init__.py @@ -28,36 +28,34 @@ from ._models_py3 import VoiceReceiver from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import ( - ReceiverStatus, -) +from ._monitor_management_client_enums import ReceiverStatus from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionDetail', - 'ActionGroupList', - 'ActionGroupPatchBody', - 'ActionGroupResource', - 'ArmRoleReceiver', - 'AutomationRunbookReceiver', - 'AzureAppPushReceiver', - 'AzureFunctionReceiver', - 'AzureResource', - 'Context', - 'EmailReceiver', - 'EnableRequest', - 'ErrorResponse', - 'EventHubReceiver', - 'ItsmReceiver', - 'LogicAppReceiver', - 'NotificationRequestBody', - 'SmsReceiver', - 'TestNotificationDetailsResponse', - 'VoiceReceiver', - 'WebhookReceiver', - 'ReceiverStatus', + "ActionDetail", + "ActionGroupList", + "ActionGroupPatchBody", + "ActionGroupResource", + "ArmRoleReceiver", + "AutomationRunbookReceiver", + "AzureAppPushReceiver", + "AzureFunctionReceiver", + "AzureResource", + "Context", + "EmailReceiver", + "EnableRequest", + "ErrorResponse", + "EventHubReceiver", + "ItsmReceiver", + "LogicAppReceiver", + "NotificationRequestBody", + "SmsReceiver", + "TestNotificationDetailsResponse", + "VoiceReceiver", + "WebhookReceiver", + "ReceiverStatus", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_models_py3.py index 3a38c32b0fe1..0445731b0312 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_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. @@ -8,15 +9,14 @@ from typing import Dict, List, Optional, TYPE_CHECKING -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class ActionDetail(msrest.serialization.Model): +class ActionDetail(_serialization.Model): """The action detail. :ivar mechanism_type: The mechanism type. @@ -34,12 +34,12 @@ class ActionDetail(msrest.serialization.Model): """ _attribute_map = { - 'mechanism_type': {'key': 'MechanismType', 'type': 'str'}, - 'name': {'key': 'Name', 'type': 'str'}, - 'status': {'key': 'Status', 'type': 'str'}, - 'sub_state': {'key': 'SubState', 'type': 'str'}, - 'send_time': {'key': 'SendTime', 'type': 'str'}, - 'detail': {'key': 'Detail', 'type': 'str'}, + "mechanism_type": {"key": "MechanismType", "type": "str"}, + "name": {"key": "Name", "type": "str"}, + "status": {"key": "Status", "type": "str"}, + "sub_state": {"key": "SubState", "type": "str"}, + "send_time": {"key": "SendTime", "type": "str"}, + "detail": {"key": "Detail", "type": "str"}, } def __init__( @@ -67,7 +67,7 @@ def __init__( :keyword detail: The detail of the friendly error message. :paramtype detail: str """ - super(ActionDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.mechanism_type = mechanism_type self.name = name self.status = status @@ -76,7 +76,7 @@ def __init__( self.detail = detail -class ActionGroupList(msrest.serialization.Model): +class ActionGroupList(_serialization.Model): """A list of action groups. :ivar value: The list of action groups. @@ -86,16 +86,12 @@ class ActionGroupList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ActionGroupResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of action groups. @@ -103,15 +99,15 @@ def __init__( :keyword next_link: Provides the link to retrieve the next set of elements. :paramtype next_link: str """ - super(ActionGroupList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ActionGroupPatchBody(msrest.serialization.Model): +class ActionGroupPatchBody(_serialization.Model): """An action group object for the body of patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. @@ -119,30 +115,24 @@ class ActionGroupPatchBody(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - enabled: Optional[bool] = True, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. :paramtype enabled: bool """ - super(ActionGroupPatchBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.enabled = enabled -class AzureResource(msrest.serialization.Model): +class AzureResource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -155,41 +145,35 @@ class AzureResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(AzureResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -197,7 +181,7 @@ def __init__( self.tags = tags -class ActionGroupResource(AzureResource): +class ActionGroupResource(AzureResource): # pylint: disable=too-many-instance-attributes """An action group resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -210,9 +194,9 @@ class ActionGroupResource(AzureResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar group_short_name: The short name of the action group. This will be used in SMS messages. :vartype group_short_name: str @@ -253,32 +237,35 @@ class ActionGroupResource(AzureResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "group_short_name": {"max_length": 12}, } _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}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'properties.armRoleReceivers', 'type': '[ArmRoleReceiver]'}, - 'event_hub_receivers': {'key': 'properties.eventHubReceivers', 'type': '[EventHubReceiver]'}, + "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}"}, + "group_short_name": {"key": "properties.groupShortName", "type": "str"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, + "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, + "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, + "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, + "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, + "automation_runbook_receivers": { + "key": "properties.automationRunbookReceivers", + "type": "[AutomationRunbookReceiver]", + }, + "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, + "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, + "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, + "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, + "event_hub_receivers": {"key": "properties.eventHubReceivers", "type": "[EventHubReceiver]"}, } def __init__( @@ -287,7 +274,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, - enabled: Optional[bool] = True, + enabled: bool = True, email_receivers: Optional[List["_models.EmailReceiver"]] = None, sms_receivers: Optional[List["_models.SmsReceiver"]] = None, webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, @@ -302,9 +289,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword group_short_name: The short name of the action group. This will be used in SMS messages. @@ -348,7 +335,7 @@ def __init__( :paramtype event_hub_receivers: list[~$(python-base-namespace).v2022_04_01.models.EventHubReceiver] """ - super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled self.email_receivers = email_receivers @@ -364,67 +351,60 @@ def __init__( self.event_hub_receivers = event_hub_receivers -class ArmRoleReceiver(msrest.serialization.Model): +class ArmRoleReceiver(_serialization.Model): """An arm role receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the arm role receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the arm role receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar role_id: Required. The arm role id. + :ivar role_id: The arm role id. Required. :vartype role_id: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'role_id': {'required': True}, + "name": {"required": True}, + "role_id": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } - def __init__( - self, - *, - name: str, - role_id: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs): """ - :keyword name: Required. The name of the arm role receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the arm role receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword role_id: Required. The arm role id. + :keyword role_id: The arm role id. Required. :paramtype role_id: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(ArmRoleReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.role_id = role_id self.use_common_alert_schema = use_common_alert_schema -class AutomationRunbookReceiver(msrest.serialization.Model): +class AutomationRunbookReceiver(_serialization.Model): """The Azure Automation Runbook notification receiver. All required parameters must be populated in order to send to Azure. - :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook - and authenticate to Azure resource. + :ivar automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :vartype automation_account_id: str - :ivar runbook_name: Required. The name for this runbook. + :ivar runbook_name: The name for this runbook. Required. :vartype runbook_name: str - :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. :vartype webhook_resource_id: str - :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. :vartype is_global_runbook: bool :ivar name: Indicates name of the webhook. :vartype name: str @@ -435,20 +415,20 @@ class AutomationRunbookReceiver(msrest.serialization.Model): """ _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, + "automation_account_id": {"required": True}, + "runbook_name": {"required": True}, + "webhook_resource_id": {"required": True}, + "is_global_runbook": {"required": True}, } _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "automation_account_id": {"key": "automationAccountId", "type": "str"}, + "runbook_name": {"key": "runbookName", "type": "str"}, + "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, + "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( @@ -460,18 +440,18 @@ def __init__( is_global_runbook: bool, name: Optional[str] = None, service_uri: Optional[str] = None, - use_common_alert_schema: Optional[bool] = False, + use_common_alert_schema: bool = False, **kwargs ): """ - :keyword automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. + :keyword automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :paramtype automation_account_id: str - :keyword runbook_name: Required. The name for this runbook. + :keyword runbook_name: The name for this runbook. Required. :paramtype runbook_name: str - :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. :paramtype webhook_resource_id: str - :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. :paramtype is_global_runbook: bool :keyword name: Indicates name of the webhook. :paramtype name: str @@ -480,7 +460,7 @@ def __init__( :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(AutomationRunbookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name self.webhook_resource_id = webhook_resource_id @@ -490,78 +470,72 @@ def __init__( self.use_common_alert_schema = use_common_alert_schema -class AzureAppPushReceiver(msrest.serialization.Model): +class AzureAppPushReceiver(_serialization.Model): """The Azure mobile App push notification receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :vartype name: str - :ivar email_address: Required. The email address registered for the Azure mobile app. + :ivar email_address: The email address registered for the Azure mobile app. Required. :vartype email_address: str """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, + "name": {"required": True}, + "email_address": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, **kwargs): """ - :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address registered for the Azure mobile app. + :keyword email_address: The email address registered for the Azure mobile app. Required. :paramtype email_address: str """ - super(AzureAppPushReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address -class AzureFunctionReceiver(msrest.serialization.Model): +class AzureFunctionReceiver(_serialization.Model): """An azure function receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the azure function receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the azure function receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar function_app_resource_id: Required. The azure resource id of the function app. + :ivar function_app_resource_id: The azure resource id of the function app. Required. :vartype function_app_resource_id: str - :ivar function_name: Required. The function name in the function app. + :ivar function_name: The function name in the function app. Required. :vartype function_name: str - :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :ivar http_trigger_url: The http trigger url where http request sent to. Required. :vartype http_trigger_url: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'function_app_resource_id': {'required': True}, - 'function_name': {'required': True}, - 'http_trigger_url': {'required': True}, + "name": {"required": True}, + "function_app_resource_id": {"required": True}, + "function_name": {"required": True}, + "http_trigger_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, - 'function_name': {'key': 'functionName', 'type': 'str'}, - 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, + "function_name": {"key": "functionName", "type": "str"}, + "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( @@ -571,23 +545,23 @@ def __init__( function_app_resource_id: str, function_name: str, http_trigger_url: str, - use_common_alert_schema: Optional[bool] = False, + use_common_alert_schema: bool = False, **kwargs ): """ - :keyword name: Required. The name of the azure function receiver. Names must be unique across - all receivers within an action group. + :keyword name: The name of the azure function receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword function_app_resource_id: Required. The azure resource id of the function app. + :keyword function_app_resource_id: The azure resource id of the function app. Required. :paramtype function_app_resource_id: str - :keyword function_name: Required. The function name in the function app. + :keyword function_name: The function name in the function app. Required. :paramtype function_name: str - :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :keyword http_trigger_url: The http trigger url where http request sent to. Required. :paramtype http_trigger_url: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(AzureFunctionReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.function_app_resource_id = function_app_resource_id self.function_name = function_name @@ -595,7 +569,7 @@ def __init__( self.use_common_alert_schema = use_common_alert_schema -class Context(msrest.serialization.Model): +class Context(_serialization.Model): """The context info. :ivar notification_source: The source of the notification request. @@ -605,116 +579,98 @@ class Context(msrest.serialization.Model): """ _attribute_map = { - 'notification_source': {'key': 'notificationSource', 'type': 'str'}, - 'context_type': {'key': 'contextType', 'type': 'str'}, + "notification_source": {"key": "notificationSource", "type": "str"}, + "context_type": {"key": "contextType", "type": "str"}, } - def __init__( - self, - *, - notification_source: Optional[str] = None, - context_type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs): """ :keyword notification_source: The source of the notification request. :paramtype notification_source: str :keyword context_type: The context id type. :paramtype context_type: str """ - super(Context, self).__init__(**kwargs) + super().__init__(**kwargs) self.notification_source = notification_source self.context_type = context_type -class EmailReceiver(msrest.serialization.Model): +class EmailReceiver(_serialization.Model): """An email receiver. Variables are only 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 name: Required. The name of the email receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the email receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar email_address: Required. The email address of this receiver. + :ivar email_address: The email address of this receiver. Required. :vartype email_address: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - "Disabled". + and "Disabled". :vartype status: str or ~$(python-base-namespace).v2022_04_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "email_address": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs): """ - :keyword name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the email receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address of this receiver. + :keyword email_address: The email address of this receiver. Required. :paramtype email_address: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(EmailReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address self.use_common_alert_schema = use_common_alert_schema self.status = None -class EnableRequest(msrest.serialization.Model): +class EnableRequest(_serialization.Model): """Describes a receiver that should be resubscribed. All required parameters must be populated in order to send to Azure. - :ivar receiver_name: Required. The name of the receiver to resubscribe. + :ivar receiver_name: The name of the receiver to resubscribe. Required. :vartype receiver_name: str """ _validation = { - 'receiver_name': {'required': True}, + "receiver_name": {"required": True}, } _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, + "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__( - self, - *, - receiver_name: str, - **kwargs - ): + def __init__(self, *, receiver_name: str, **kwargs): """ - :keyword receiver_name: Required. The name of the receiver to resubscribe. + :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str """ - super(EnableRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.receiver_name = receiver_name -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -724,62 +680,56 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class EventHubReceiver(msrest.serialization.Model): +class EventHubReceiver(_serialization.Model): """An Event hub receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Event hub receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the Event hub receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar event_hub_name_space: Required. The Event Hub namespace. + :ivar event_hub_name_space: The Event Hub namespace. Required. :vartype event_hub_name_space: str - :ivar event_hub_name: Required. The name of the specific Event Hub queue. + :ivar event_hub_name: The name of the specific Event Hub queue. Required. :vartype event_hub_name: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool :ivar tenant_id: The tenant Id for the subscription containing this event hub. :vartype tenant_id: str - :ivar subscription_id: Required. The Id for the subscription containing this event hub. + :ivar subscription_id: The Id for the subscription containing this event hub. Required. :vartype subscription_id: str """ _validation = { - 'name': {'required': True}, - 'event_hub_name_space': {'required': True}, - 'event_hub_name': {'required': True}, - 'subscription_id': {'required': True}, + "name": {"required": True}, + "event_hub_name_space": {"required": True}, + "event_hub_name": {"required": True}, + "subscription_id": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'event_hub_name_space': {'key': 'eventHubNameSpace', 'type': 'str'}, - 'event_hub_name': {'key': 'eventHubName', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "event_hub_name_space": {"key": "eventHubNameSpace", "type": "str"}, + "event_hub_name": {"key": "eventHubName", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, } def __init__( @@ -789,26 +739,26 @@ def __init__( event_hub_name_space: str, event_hub_name: str, subscription_id: str, - use_common_alert_schema: Optional[bool] = False, + use_common_alert_schema: bool = False, tenant_id: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the Event hub receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the Event hub receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword event_hub_name_space: Required. The Event Hub namespace. + :keyword event_hub_name_space: The Event Hub namespace. Required. :paramtype event_hub_name_space: str - :keyword event_hub_name: Required. The name of the specific Event Hub queue. + :keyword event_hub_name: The name of the specific Event Hub queue. Required. :paramtype event_hub_name: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool :keyword tenant_id: The tenant Id for the subscription containing this event hub. :paramtype tenant_id: str - :keyword subscription_id: Required. The Id for the subscription containing this event hub. + :keyword subscription_id: The Id for the subscription containing this event hub. Required. :paramtype subscription_id: str """ - super(EventHubReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.event_hub_name_space = event_hub_name_space self.event_hub_name = event_hub_name @@ -817,70 +767,65 @@ def __init__( self.subscription_id = subscription_id -class ItsmReceiver(msrest.serialization.Model): +class ItsmReceiver(_serialization.Model): """An Itsm receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar workspace_id: Required. OMS LA instance identifier. + :ivar workspace_id: OMS LA instance identifier. Required. :vartype workspace_id: str - :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined - in above workspace. + :ivar connection_id: Unique identification of ITSM connection among multiple defined in above + workspace. Required. :vartype connection_id: str - :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :vartype ticket_configuration: str - :ivar region: Required. Region in which workspace resides. Supported + :ivar region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :vartype region: str """ _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, + "name": {"required": True}, + "workspace_id": {"required": True}, + "connection_id": {"required": True}, + "ticket_configuration": {"required": True}, + "region": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "connection_id": {"key": "connectionId", "type": "str"}, + "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, + "region": {"key": "region", "type": "str"}, } def __init__( - self, - *, - name: str, - workspace_id: str, - connection_id: str, - ticket_configuration: str, - region: str, - **kwargs + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs ): """ - :keyword name: Required. The name of the Itsm receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword workspace_id: Required. OMS LA instance identifier. + :keyword workspace_id: OMS LA instance identifier. Required. :paramtype workspace_id: str - :keyword connection_id: Required. Unique identification of ITSM connection among multiple - defined in above workspace. + :keyword connection_id: Unique identification of ITSM connection among multiple defined in + above workspace. Required. :paramtype connection_id: str - :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :paramtype ticket_configuration: str - :keyword region: Required. Region in which workspace resides. Supported + :keyword region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :paramtype region: str """ - super(ItsmReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.workspace_id = workspace_id self.connection_id = connection_id @@ -888,68 +833,62 @@ def __init__( self.region = region -class LogicAppReceiver(msrest.serialization.Model): +class LogicAppReceiver(_serialization.Model): """A logic app receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar resource_id: Required. The azure resource id of the logic app receiver. + :ivar resource_id: The azure resource id of the logic app receiver. Required. :vartype resource_id: str - :ivar callback_url: Required. The callback url where http request sent to. + :ivar callback_url: The callback url where http request sent to. Required. :vartype callback_url: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'resource_id': {'required': True}, - 'callback_url': {'required': True}, + "name": {"required": True}, + "resource_id": {"required": True}, + "callback_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "callback_url": {"key": "callbackUrl", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( - self, - *, - name: str, - resource_id: str, - callback_url: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs + self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs ): """ - :keyword name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword resource_id: Required. The azure resource id of the logic app receiver. + :keyword resource_id: The azure resource id of the logic app receiver. Required. :paramtype resource_id: str - :keyword callback_url: Required. The callback url where http request sent to. + :keyword callback_url: The callback url where http request sent to. Required. :paramtype callback_url: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(LogicAppReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.resource_id = resource_id self.callback_url = callback_url self.use_common_alert_schema = use_common_alert_schema -class NotificationRequestBody(msrest.serialization.Model): +class NotificationRequestBody(_serialization.Model): # pylint: disable=too-many-instance-attributes """The request body which contain contact detail metadata. All required parameters must be populated in order to send to Azure. - :ivar alert_type: Required. The name of the supported alert type. + :ivar alert_type: The name of the supported alert type. Required. :vartype alert_type: str :ivar email_receivers: The list of email receivers that are part of this action group. :vartype email_receivers: list[~$(python-base-namespace).v2022_04_01.models.EmailReceiver] @@ -985,22 +924,22 @@ class NotificationRequestBody(msrest.serialization.Model): """ _validation = { - 'alert_type': {'required': True, 'max_length': 30, 'min_length': 0}, + "alert_type": {"required": True, "max_length": 30}, } _attribute_map = { - 'alert_type': {'key': 'alertType', 'type': 'str'}, - 'email_receivers': {'key': 'emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'armRoleReceivers', 'type': '[ArmRoleReceiver]'}, - 'event_hub_receivers': {'key': 'eventHubReceivers', 'type': '[EventHubReceiver]'}, + "alert_type": {"key": "alertType", "type": "str"}, + "email_receivers": {"key": "emailReceivers", "type": "[EmailReceiver]"}, + "sms_receivers": {"key": "smsReceivers", "type": "[SmsReceiver]"}, + "webhook_receivers": {"key": "webhookReceivers", "type": "[WebhookReceiver]"}, + "itsm_receivers": {"key": "itsmReceivers", "type": "[ItsmReceiver]"}, + "azure_app_push_receivers": {"key": "azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, + "automation_runbook_receivers": {"key": "automationRunbookReceivers", "type": "[AutomationRunbookReceiver]"}, + "voice_receivers": {"key": "voiceReceivers", "type": "[VoiceReceiver]"}, + "logic_app_receivers": {"key": "logicAppReceivers", "type": "[LogicAppReceiver]"}, + "azure_function_receivers": {"key": "azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, + "arm_role_receivers": {"key": "armRoleReceivers", "type": "[ArmRoleReceiver]"}, + "event_hub_receivers": {"key": "eventHubReceivers", "type": "[EventHubReceiver]"}, } def __init__( @@ -1021,7 +960,7 @@ def __init__( **kwargs ): """ - :keyword alert_type: Required. The name of the supported alert type. + :keyword alert_type: The name of the supported alert type. Required. :paramtype alert_type: str :keyword email_receivers: The list of email receivers that are part of this action group. :paramtype email_receivers: list[~$(python-base-namespace).v2022_04_01.models.EmailReceiver] @@ -1059,7 +998,7 @@ def __init__( :paramtype event_hub_receivers: list[~$(python-base-namespace).v2022_04_01.models.EventHubReceiver] """ - super(NotificationRequestBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.alert_type = alert_type self.email_receivers = email_receivers self.sms_receivers = sms_receivers @@ -1074,71 +1013,64 @@ def __init__( self.event_hub_receivers = event_hub_receivers -class SmsReceiver(msrest.serialization.Model): +class SmsReceiver(_serialization.Model): """An SMS receiver. Variables are only 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 name: Required. The name of the SMS receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the SMS receiver. + :ivar country_code: The country code of the SMS receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the SMS receiver. + :ivar phone_number: The phone number of the SMS receiver. Required. :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and "Disabled". :vartype status: str or ~$(python-base-namespace).v2022_04_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the SMS receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the SMS receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the SMS receiver. + :keyword country_code: The country code of the SMS receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the SMS receiver. + :keyword phone_number: The phone number of the SMS receiver. Required. :paramtype phone_number: str """ - super(SmsReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number self.status = None -class TestNotificationDetailsResponse(msrest.serialization.Model): +class TestNotificationDetailsResponse(_serialization.Model): """The details of the test notification results. All required parameters must be populated in order to send to Azure. :ivar context: The context info. :vartype context: ~$(python-base-namespace).v2022_04_01.models.Context - :ivar state: Required. The overall state. + :ivar state: The overall state. Required. :vartype state: str :ivar completed_time: The completed time. :vartype completed_time: str @@ -1149,15 +1081,15 @@ class TestNotificationDetailsResponse(msrest.serialization.Model): """ _validation = { - 'state': {'required': True}, + "state": {"required": True}, } _attribute_map = { - 'context': {'key': 'context', 'type': 'Context'}, - 'state': {'key': 'state', 'type': 'str'}, - 'completed_time': {'key': 'completedTime', 'type': 'str'}, - 'created_time': {'key': 'createdTime', 'type': 'str'}, - 'action_details': {'key': 'actionDetails', 'type': '[ActionDetail]'}, + "context": {"key": "context", "type": "Context"}, + "state": {"key": "state", "type": "str"}, + "completed_time": {"key": "completedTime", "type": "str"}, + "created_time": {"key": "createdTime", "type": "str"}, + "action_details": {"key": "actionDetails", "type": "[ActionDetail]"}, } def __init__( @@ -1173,7 +1105,7 @@ def __init__( """ :keyword context: The context info. :paramtype context: ~$(python-base-namespace).v2022_04_01.models.Context - :keyword state: Required. The overall state. + :keyword state: The overall state. Required. :paramtype state: str :keyword completed_time: The completed time. :paramtype completed_time: str @@ -1182,7 +1114,7 @@ def __init__( :keyword action_details: The list of action detail. :paramtype action_details: list[~$(python-base-namespace).v2022_04_01.models.ActionDetail] """ - super(TestNotificationDetailsResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.context = context self.state = state self.completed_time = completed_time @@ -1190,64 +1122,57 @@ def __init__( self.action_details = action_details -class VoiceReceiver(msrest.serialization.Model): +class VoiceReceiver(_serialization.Model): """A voice receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the voice receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the voice receiver. + :ivar country_code: The country code of the voice receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the voice receiver. + :ivar phone_number: The phone number of the voice receiver. Required. :vartype phone_number: str """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the voice receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the voice receiver. + :keyword country_code: The country code of the voice receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the voice receiver. + :keyword phone_number: The phone number of the voice receiver. Required. :paramtype phone_number: str """ - super(VoiceReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number -class WebhookReceiver(msrest.serialization.Model): +class WebhookReceiver(_serialization.Model): """A webhook receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the webhook receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar service_uri: Required. The URI where webhooks should be sent. + :ivar service_uri: The URI where webhooks should be sent. Required. :vartype service_uri: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool @@ -1262,18 +1187,18 @@ class WebhookReceiver(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, + "name": {"required": True}, + "service_uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'use_aad_auth': {'key': 'useAadAuth', 'type': 'bool'}, - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'identifier_uri': {'key': 'identifierUri', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "use_aad_auth": {"key": "useAadAuth", "type": "bool"}, + "object_id": {"key": "objectId", "type": "str"}, + "identifier_uri": {"key": "identifierUri", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } def __init__( @@ -1281,18 +1206,18 @@ def __init__( *, name: str, service_uri: str, - use_common_alert_schema: Optional[bool] = False, - use_aad_auth: Optional[bool] = False, + use_common_alert_schema: bool = False, + use_aad_auth: bool = False, object_id: Optional[str] = None, identifier_uri: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the webhook receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword service_uri: Required. The URI where webhooks should be sent. + :keyword service_uri: The URI where webhooks should be sent. Required. :paramtype service_uri: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool @@ -1305,7 +1230,7 @@ def __init__( :keyword tenant_id: Indicates the tenant id for aad auth. :paramtype tenant_id: str """ - super(WebhookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.service_uri = service_uri self.use_common_alert_schema = use_common_alert_schema diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/__init__.py index 60f9d62f0ead..0e396f5d7fb0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', + "ActionGroupsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_action_groups_operations.py index 9ea13c25a685..5e9c6d9b7fcb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_action_groups_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,444 +27,368 @@ 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 -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.ActionGroupResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - action_group_name: str, - *, - json: Optional[_models.ActionGroupPatchBody] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_post_test_notifications_request_initial( - subscription_id: str, - *, - json: Optional[_models.NotificationRequestBody] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_post_test_notifications_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_create_notifications_at_resource_group_level_request_initial( - subscription_id: str, - resource_group_name: str, - *, - json: Optional[_models.NotificationRequestBody] = None, - content: Any = None, - **kwargs: Any +def build_create_notifications_at_resource_group_level_request( + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_test_notifications_request( - subscription_id: str, - notification_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_test_notifications_request(notification_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_test_notifications_at_resource_group_level_request( - subscription_id: str, - resource_group_name: str, - notification_id: str, - **kwargs: Any + resource_group_name: str, notification_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_id_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_enable_receiver_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.EnableRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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 ActionGroupsOperations: """ @@ -480,41 +409,105 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -523,7 +516,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -531,10 +525,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -543,55 +536,47 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -599,10 +584,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -610,52 +594,46 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -663,10 +641,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -677,52 +654,118 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2022_04_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2022_04_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -730,10 +773,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -741,41 +783,43 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore def _post_test_notifications_initial( - self, - notification_request: _models.NotificationRequestBody, - **kwargs: Any + self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_post_test_notifications_request_initial( + request = build_post_test_notifications_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._post_test_notifications_initial.metadata['url'], + content=_content, + template_url=self._post_test_notifications_initial.metadata["url"], headers=_headers, params=_params, ) @@ -783,44 +827,103 @@ def _post_test_notifications_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _post_test_notifications_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _post_test_notifications_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore - - @distributed_trace + @overload def begin_post_test_notifications( self, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_post_test_notifications( + self, notification_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_post_test_notifications( + self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 @@ -833,86 +936,83 @@ def begin_post_test_notifications( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._post_test_notifications_initial( # type: ignore notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_post_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_post_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore def _create_notifications_at_resource_group_level_initial( - self, - resource_group_name: str, - notification_request: _models.NotificationRequestBody, - **kwargs: Any + self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_create_notifications_at_resource_group_level_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_notifications_at_resource_group_level_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_notifications_at_resource_group_level_initial.metadata['url'], + content=_content, + template_url=self._create_notifications_at_resource_group_level_initial.metadata["url"], headers=_headers, params=_params, ) @@ -920,47 +1020,52 @@ def _create_notifications_at_resource_group_level_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_notifications_at_resource_group_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _create_notifications_at_resource_group_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore - - @distributed_trace + @overload def begin_create_notifications_at_resource_group_level( self, resource_group_name: str, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -973,92 +1078,146 @@ def begin_create_notifications_at_resource_group_level( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_notifications_at_resource_group_level( + self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_notifications_at_resource_group_level_initial( # type: ignore resource_group_name=resource_group_name, notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_create_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore @distributed_trace - def get_test_notifications( - self, - notification_id: str, - **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: + def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_request( - subscription_id=self._config.subscription_id, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications.metadata['url'], + template_url=self.get_test_notifications.metadata["url"], headers=_headers, params=_params, ) @@ -1066,10 +1225,9 @@ def get_test_notifications( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1077,52 +1235,46 @@ def get_test_notifications( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore @distributed_trace def get_test_notifications_at_resource_group_level( - self, - resource_group_name: str, - notification_id: str, - **kwargs: Any + self, resource_group_name: str, notification_id: str, **kwargs: Any ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_at_resource_group_level_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications_at_resource_group_level.metadata['url'], + template_url=self.get_test_notifications_at_resource_group_level.metadata["url"], headers=_headers, params=_params, ) @@ -1130,10 +1282,9 @@ def get_test_notifications_at_resource_group_level( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1141,46 +1292,41 @@ def get_test_notifications_at_resource_group_level( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_04_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_04_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -1188,14 +1334,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1211,10 +1354,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1225,46 +1366,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_04_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_04_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1272,15 +1409,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1296,10 +1429,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1310,47 +1441,116 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore - @distributed_trace + @overload def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2022_04_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2022_04_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -1359,7 +1559,8 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -1367,10 +1568,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1381,5 +1581,4 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/__init__.py index 7389161517c6..8ba4823444a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_configuration.py index 91a604b890ba..9ce789c9c981 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-06-01") # type: str + api_version = kwargs.pop("api_version", "2022-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + 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') + 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_metadata.json index a7c22b74128a..d6963144f2b6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._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\": [\"MonitorManagementClientConfiguration\"], \"..._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 ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. 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 ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_monitor_management_client.py index 334d6b5aeb3c..1bb22a9b401d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -22,14 +21,15 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2022_06_01.operations.ActionGroupsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -47,23 +47,18 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + 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 @@ -72,7 +67,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py index f4674910a502..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/__init__.py index ee931f53dd58..8638dc69d869 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['MonitorManagementClient'] + +__all__ = ["MonitorManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_configuration.py index 8401bd015ff7..432effa58c39 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_configuration.py @@ -25,23 +25,18 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-06-01") # type: str + api_version = kwargs.pop("api_version", "2022-06-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( 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-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py index f19eacc58157..ef0415ce7660 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -22,15 +21,16 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient: + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2022_06_01.aio.operations.ActionGroupsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -48,23 +48,18 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration( + 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.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + 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 @@ -73,7 +68,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/__init__.py index 60f9d62f0ead..0e396f5d7fb0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', + "ActionGroupsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_action_groups_operations.py index 244e18f49441..a8fcc8fa63f0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_action_groups_operations.py @@ -6,10 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse 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, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,26 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._action_groups_operations import build_create_notifications_at_action_group_resource_level_request_initial, build_create_notifications_at_resource_group_level_request_initial, build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_get_test_notifications_at_action_group_resource_level_request, build_get_test_notifications_at_resource_group_level_request, build_get_test_notifications_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_post_test_notifications_request_initial, build_update_request -T = TypeVar('T') +from ...operations._action_groups_operations import ( + build_create_notifications_at_action_group_resource_level_request, + build_create_notifications_at_resource_group_level_request, + build_create_or_update_request, + build_delete_request, + build_enable_receiver_request, + build_get_request, + build_get_test_notifications_at_action_group_resource_level_request, + build_get_test_notifications_at_resource_group_level_request, + build_get_test_notifications_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_post_test_notifications_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ActionGroupsOperations: """ .. warning:: @@ -45,41 +68,105 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.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 + @overload async def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -88,7 +175,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -96,10 +184,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -108,55 +195,47 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -164,10 +243,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,52 +253,46 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -228,10 +300,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -242,52 +313,118 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2022_06_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2022_06_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -295,10 +432,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -306,41 +442,43 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore async def _post_test_notifications_initial( - self, - notification_request: _models.NotificationRequestBody, - **kwargs: Any + self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_post_test_notifications_request_initial( + request = build_post_test_notifications_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._post_test_notifications_initial.metadata['url'], + content=_content, + template_url=self._post_test_notifications_initial.metadata["url"], headers=_headers, params=_params, ) @@ -348,44 +486,103 @@ async def _post_test_notifications_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _post_test_notifications_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore - + _post_test_notifications_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore - @distributed_trace_async + @overload async def begin_post_test_notifications( self, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_post_test_notifications( + self, notification_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_post_test_notifications( + self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 @@ -398,86 +595,83 @@ async def begin_post_test_notifications( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._post_test_notifications_initial( # type: ignore notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_post_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_post_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore async def _create_notifications_at_resource_group_level_initial( - self, - resource_group_name: str, - notification_request: _models.NotificationRequestBody, - **kwargs: Any + self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_create_notifications_at_resource_group_level_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_notifications_at_resource_group_level_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_notifications_at_resource_group_level_initial.metadata['url'], + content=_content, + template_url=self._create_notifications_at_resource_group_level_initial.metadata["url"], headers=_headers, params=_params, ) @@ -485,47 +679,87 @@ async def _create_notifications_at_resource_group_level_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_notifications_at_resource_group_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _create_notifications_at_resource_group_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_notifications_at_resource_group_level( self, resource_group_name: str, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 @@ -538,89 +772,120 @@ async def begin_create_notifications_at_resource_group_level( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_notifications_at_resource_group_level( + self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_notifications_at_resource_group_level_initial( # type: ignore resource_group_name=resource_group_name, notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_create_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore async def _create_notifications_at_action_group_resource_level_initial( self, resource_group_name: str, action_group_name: str, - notification_request: _models.NotificationRequestBody, + notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_create_notifications_at_action_group_resource_level_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_notifications_at_action_group_resource_level_request( resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_notifications_at_action_group_resource_level_initial.metadata['url'], + content=_content, + template_url=self._create_notifications_at_action_group_resource_level_initial.metadata["url"], headers=_headers, params=_params, ) @@ -628,50 +893,130 @@ async def _create_notifications_at_action_group_resource_level_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_notifications_at_action_group_resource_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + _create_notifications_at_action_group_resource_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_notifications_at_action_group_resource_level( self, resource_group_name: str, action_group_name: str, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_request: Union[_models.NotificationRequestBody, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 @@ -684,20 +1029,17 @@ async def begin_create_notifications_at_action_group_resource_level( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_notifications_at_action_group_resource_level_initial( # type: ignore resource_group_name=resource_group_name, @@ -705,72 +1047,65 @@ async def begin_create_notifications_at_action_group_resource_level( notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_notifications_at_action_group_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + begin_create_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore @distributed_trace_async async def get_test_notifications( - self, - notification_id: str, - **kwargs: Any + self, notification_id: str, **kwargs: Any ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_request( - subscription_id=self._config.subscription_id, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications.metadata['url'], + template_url=self.get_test_notifications.metadata["url"], headers=_headers, params=_params, ) @@ -778,10 +1113,9 @@ async def get_test_notifications( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -789,52 +1123,46 @@ async def get_test_notifications( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore @distributed_trace_async async def get_test_notifications_at_resource_group_level( - self, - resource_group_name: str, - notification_id: str, - **kwargs: Any + self, resource_group_name: str, notification_id: str, **kwargs: Any ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_at_resource_group_level_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications_at_resource_group_level.metadata['url'], + template_url=self.get_test_notifications_at_resource_group_level.metadata["url"], headers=_headers, params=_params, ) @@ -842,10 +1170,9 @@ async def get_test_notifications_at_resource_group_level( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -853,56 +1180,49 @@ async def get_test_notifications_at_resource_group_level( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore @distributed_trace_async async def get_test_notifications_at_action_group_resource_level( - self, - resource_group_name: str, - action_group_name: str, - notification_id: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, notification_id: str, **kwargs: Any ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_at_action_group_resource_level_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications_at_action_group_resource_level.metadata['url'], + template_url=self.get_test_notifications_at_action_group_resource_level.metadata["url"], headers=_headers, params=_params, ) @@ -910,10 +1230,9 @@ async def get_test_notifications_at_action_group_resource_level( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -921,46 +1240,41 @@ async def get_test_notifications_at_action_group_resource_level( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications_at_action_group_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_06_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_06_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -968,14 +1282,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -991,10 +1302,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1005,46 +1314,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_06_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_06_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1052,15 +1357,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1076,10 +1377,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1090,47 +1389,116 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore - @distributed_trace_async + @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2022_06_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2022_06_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -1139,7 +1507,8 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -1147,10 +1516,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1161,5 +1529,4 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/__init__.py index 7d4cce34b707..c2c49e9b3b64 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/__init__.py @@ -28,36 +28,34 @@ from ._models_py3 import VoiceReceiver from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import ( - ReceiverStatus, -) +from ._monitor_management_client_enums import ReceiverStatus from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionDetail', - 'ActionGroupList', - 'ActionGroupPatchBody', - 'ActionGroupResource', - 'ArmRoleReceiver', - 'AutomationRunbookReceiver', - 'AzureAppPushReceiver', - 'AzureFunctionReceiver', - 'AzureResource', - 'Context', - 'EmailReceiver', - 'EnableRequest', - 'ErrorResponse', - 'EventHubReceiver', - 'ItsmReceiver', - 'LogicAppReceiver', - 'NotificationRequestBody', - 'SmsReceiver', - 'TestNotificationDetailsResponse', - 'VoiceReceiver', - 'WebhookReceiver', - 'ReceiverStatus', + "ActionDetail", + "ActionGroupList", + "ActionGroupPatchBody", + "ActionGroupResource", + "ArmRoleReceiver", + "AutomationRunbookReceiver", + "AzureAppPushReceiver", + "AzureFunctionReceiver", + "AzureResource", + "Context", + "EmailReceiver", + "EnableRequest", + "ErrorResponse", + "EventHubReceiver", + "ItsmReceiver", + "LogicAppReceiver", + "NotificationRequestBody", + "SmsReceiver", + "TestNotificationDetailsResponse", + "VoiceReceiver", + "WebhookReceiver", + "ReceiverStatus", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_models_py3.py index a2ead431a985..59f7125c7ef6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_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. @@ -8,15 +9,14 @@ from typing import Dict, List, Optional, TYPE_CHECKING -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class ActionDetail(msrest.serialization.Model): +class ActionDetail(_serialization.Model): """The action detail. :ivar mechanism_type: The mechanism type. @@ -34,12 +34,12 @@ class ActionDetail(msrest.serialization.Model): """ _attribute_map = { - 'mechanism_type': {'key': 'MechanismType', 'type': 'str'}, - 'name': {'key': 'Name', 'type': 'str'}, - 'status': {'key': 'Status', 'type': 'str'}, - 'sub_state': {'key': 'SubState', 'type': 'str'}, - 'send_time': {'key': 'SendTime', 'type': 'str'}, - 'detail': {'key': 'Detail', 'type': 'str'}, + "mechanism_type": {"key": "MechanismType", "type": "str"}, + "name": {"key": "Name", "type": "str"}, + "status": {"key": "Status", "type": "str"}, + "sub_state": {"key": "SubState", "type": "str"}, + "send_time": {"key": "SendTime", "type": "str"}, + "detail": {"key": "Detail", "type": "str"}, } def __init__( @@ -67,7 +67,7 @@ def __init__( :keyword detail: The detail of the friendly error message. :paramtype detail: str """ - super(ActionDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.mechanism_type = mechanism_type self.name = name self.status = status @@ -76,7 +76,7 @@ def __init__( self.detail = detail -class ActionGroupList(msrest.serialization.Model): +class ActionGroupList(_serialization.Model): """A list of action groups. :ivar value: The list of action groups. @@ -86,16 +86,12 @@ class ActionGroupList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ActionGroupResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: The list of action groups. @@ -103,15 +99,15 @@ def __init__( :keyword next_link: Provides the link to retrieve the next set of elements. :paramtype next_link: str """ - super(ActionGroupList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ActionGroupPatchBody(msrest.serialization.Model): +class ActionGroupPatchBody(_serialization.Model): """An action group object for the body of patch operations. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. @@ -119,30 +115,24 @@ class ActionGroupPatchBody(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - enabled: Optional[bool] = True, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. :paramtype enabled: bool """ - super(ActionGroupPatchBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.enabled = enabled -class AzureResource(msrest.serialization.Model): +class AzureResource(_serialization.Model): """An azure resource object. Variables are only populated by the server, and will be ignored when sending a request. @@ -155,41 +145,35 @@ class AzureResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(AzureResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -197,7 +181,7 @@ def __init__( self.tags = tags -class ActionGroupResource(AzureResource): +class ActionGroupResource(AzureResource): # pylint: disable=too-many-instance-attributes """An action group resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -210,9 +194,9 @@ class ActionGroupResource(AzureResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar location: Required. Resource location. + :ivar location: Resource location. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar group_short_name: The short name of the action group. This will be used in SMS messages. :vartype group_short_name: str @@ -253,32 +237,35 @@ class ActionGroupResource(AzureResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "group_short_name": {"max_length": 12}, } _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}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'properties.armRoleReceivers', 'type': '[ArmRoleReceiver]'}, - 'event_hub_receivers': {'key': 'properties.eventHubReceivers', 'type': '[EventHubReceiver]'}, + "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}"}, + "group_short_name": {"key": "properties.groupShortName", "type": "str"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, + "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, + "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, + "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, + "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, + "automation_runbook_receivers": { + "key": "properties.automationRunbookReceivers", + "type": "[AutomationRunbookReceiver]", + }, + "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, + "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, + "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, + "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, + "event_hub_receivers": {"key": "properties.eventHubReceivers", "type": "[EventHubReceiver]"}, } def __init__( @@ -287,7 +274,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, - enabled: Optional[bool] = True, + enabled: bool = True, email_receivers: Optional[List["_models.EmailReceiver"]] = None, sms_receivers: Optional[List["_models.SmsReceiver"]] = None, webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, @@ -302,9 +289,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. Resource location. + :keyword location: Resource location. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword group_short_name: The short name of the action group. This will be used in SMS messages. @@ -348,7 +335,7 @@ def __init__( :paramtype event_hub_receivers: list[~$(python-base-namespace).v2022_06_01.models.EventHubReceiver] """ - super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled self.email_receivers = email_receivers @@ -364,67 +351,60 @@ def __init__( self.event_hub_receivers = event_hub_receivers -class ArmRoleReceiver(msrest.serialization.Model): +class ArmRoleReceiver(_serialization.Model): """An arm role receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the arm role receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the arm role receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar role_id: Required. The arm role id. + :ivar role_id: The arm role id. Required. :vartype role_id: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'role_id': {'required': True}, + "name": {"required": True}, + "role_id": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } - def __init__( - self, - *, - name: str, - role_id: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs): """ - :keyword name: Required. The name of the arm role receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the arm role receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword role_id: Required. The arm role id. + :keyword role_id: The arm role id. Required. :paramtype role_id: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(ArmRoleReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.role_id = role_id self.use_common_alert_schema = use_common_alert_schema -class AutomationRunbookReceiver(msrest.serialization.Model): +class AutomationRunbookReceiver(_serialization.Model): """The Azure Automation Runbook notification receiver. All required parameters must be populated in order to send to Azure. - :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook - and authenticate to Azure resource. + :ivar automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :vartype automation_account_id: str - :ivar runbook_name: Required. The name for this runbook. + :ivar runbook_name: The name for this runbook. Required. :vartype runbook_name: str - :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. :vartype webhook_resource_id: str - :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. :vartype is_global_runbook: bool :ivar name: Indicates name of the webhook. :vartype name: str @@ -435,20 +415,20 @@ class AutomationRunbookReceiver(msrest.serialization.Model): """ _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, + "automation_account_id": {"required": True}, + "runbook_name": {"required": True}, + "webhook_resource_id": {"required": True}, + "is_global_runbook": {"required": True}, } _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "automation_account_id": {"key": "automationAccountId", "type": "str"}, + "runbook_name": {"key": "runbookName", "type": "str"}, + "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, + "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( @@ -460,18 +440,18 @@ def __init__( is_global_runbook: bool, name: Optional[str] = None, service_uri: Optional[str] = None, - use_common_alert_schema: Optional[bool] = False, + use_common_alert_schema: bool = False, **kwargs ): """ - :keyword automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. + :keyword automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. :paramtype automation_account_id: str - :keyword runbook_name: Required. The name for this runbook. + :keyword runbook_name: The name for this runbook. Required. :paramtype runbook_name: str - :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. :paramtype webhook_resource_id: str - :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. :paramtype is_global_runbook: bool :keyword name: Indicates name of the webhook. :paramtype name: str @@ -480,7 +460,7 @@ def __init__( :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(AutomationRunbookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name self.webhook_resource_id = webhook_resource_id @@ -490,78 +470,72 @@ def __init__( self.use_common_alert_schema = use_common_alert_schema -class AzureAppPushReceiver(msrest.serialization.Model): +class AzureAppPushReceiver(_serialization.Model): """The Azure mobile App push notification receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :vartype name: str - :ivar email_address: Required. The email address registered for the Azure mobile app. + :ivar email_address: The email address registered for the Azure mobile app. Required. :vartype email_address: str """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, + "name": {"required": True}, + "email_address": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, **kwargs): """ - :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique - across all receivers within an action group. + :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address registered for the Azure mobile app. + :keyword email_address: The email address registered for the Azure mobile app. Required. :paramtype email_address: str """ - super(AzureAppPushReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address -class AzureFunctionReceiver(msrest.serialization.Model): +class AzureFunctionReceiver(_serialization.Model): """An azure function receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the azure function receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the azure function receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar function_app_resource_id: Required. The azure resource id of the function app. + :ivar function_app_resource_id: The azure resource id of the function app. Required. :vartype function_app_resource_id: str - :ivar function_name: Required. The function name in the function app. + :ivar function_name: The function name in the function app. Required. :vartype function_name: str - :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :ivar http_trigger_url: The http trigger url where http request sent to. Required. :vartype http_trigger_url: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'function_app_resource_id': {'required': True}, - 'function_name': {'required': True}, - 'http_trigger_url': {'required': True}, + "name": {"required": True}, + "function_app_resource_id": {"required": True}, + "function_name": {"required": True}, + "http_trigger_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, - 'function_name': {'key': 'functionName', 'type': 'str'}, - 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, + "function_name": {"key": "functionName", "type": "str"}, + "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( @@ -571,23 +545,23 @@ def __init__( function_app_resource_id: str, function_name: str, http_trigger_url: str, - use_common_alert_schema: Optional[bool] = False, + use_common_alert_schema: bool = False, **kwargs ): """ - :keyword name: Required. The name of the azure function receiver. Names must be unique across - all receivers within an action group. + :keyword name: The name of the azure function receiver. Names must be unique across all + receivers within an action group. Required. :paramtype name: str - :keyword function_app_resource_id: Required. The azure resource id of the function app. + :keyword function_app_resource_id: The azure resource id of the function app. Required. :paramtype function_app_resource_id: str - :keyword function_name: Required. The function name in the function app. + :keyword function_name: The function name in the function app. Required. :paramtype function_name: str - :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :keyword http_trigger_url: The http trigger url where http request sent to. Required. :paramtype http_trigger_url: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(AzureFunctionReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.function_app_resource_id = function_app_resource_id self.function_name = function_name @@ -595,7 +569,7 @@ def __init__( self.use_common_alert_schema = use_common_alert_schema -class Context(msrest.serialization.Model): +class Context(_serialization.Model): """The context info. :ivar notification_source: The source of the notification request. @@ -605,116 +579,98 @@ class Context(msrest.serialization.Model): """ _attribute_map = { - 'notification_source': {'key': 'notificationSource', 'type': 'str'}, - 'context_type': {'key': 'contextType', 'type': 'str'}, + "notification_source": {"key": "notificationSource", "type": "str"}, + "context_type": {"key": "contextType", "type": "str"}, } - def __init__( - self, - *, - notification_source: Optional[str] = None, - context_type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs): """ :keyword notification_source: The source of the notification request. :paramtype notification_source: str :keyword context_type: The context id type. :paramtype context_type: str """ - super(Context, self).__init__(**kwargs) + super().__init__(**kwargs) self.notification_source = notification_source self.context_type = context_type -class EmailReceiver(msrest.serialization.Model): +class EmailReceiver(_serialization.Model): """An email receiver. Variables are only 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 name: Required. The name of the email receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the email receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar email_address: Required. The email address of this receiver. + :ivar email_address: The email address of this receiver. Required. :vartype email_address: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - "Disabled". + and "Disabled". :vartype status: str or ~$(python-base-namespace).v2022_06_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "email_address": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - email_address: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs): """ - :keyword name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the email receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword email_address: Required. The email address of this receiver. + :keyword email_address: The email address of this receiver. Required. :paramtype email_address: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(EmailReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.email_address = email_address self.use_common_alert_schema = use_common_alert_schema self.status = None -class EnableRequest(msrest.serialization.Model): +class EnableRequest(_serialization.Model): """Describes a receiver that should be resubscribed. All required parameters must be populated in order to send to Azure. - :ivar receiver_name: Required. The name of the receiver to resubscribe. + :ivar receiver_name: The name of the receiver to resubscribe. Required. :vartype receiver_name: str """ _validation = { - 'receiver_name': {'required': True}, + "receiver_name": {"required": True}, } _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, + "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__( - self, - *, - receiver_name: str, - **kwargs - ): + def __init__(self, *, receiver_name: str, **kwargs): """ - :keyword receiver_name: Required. The name of the receiver to resubscribe. + :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str """ - super(EnableRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.receiver_name = receiver_name -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. :ivar code: Error code. @@ -724,62 +680,56 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: Error code. :paramtype code: str :keyword message: Error message indicating why the operation failed. :paramtype message: str """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class EventHubReceiver(msrest.serialization.Model): +class EventHubReceiver(_serialization.Model): """An Event hub receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Event hub receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the Event hub receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar event_hub_name_space: Required. The Event Hub namespace. + :ivar event_hub_name_space: The Event Hub namespace. Required. :vartype event_hub_name_space: str - :ivar event_hub_name: Required. The name of the specific Event Hub queue. + :ivar event_hub_name: The name of the specific Event Hub queue. Required. :vartype event_hub_name: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool :ivar tenant_id: The tenant Id for the subscription containing this event hub. :vartype tenant_id: str - :ivar subscription_id: Required. The Id for the subscription containing this event hub. + :ivar subscription_id: The Id for the subscription containing this event hub. Required. :vartype subscription_id: str """ _validation = { - 'name': {'required': True}, - 'event_hub_name_space': {'required': True}, - 'event_hub_name': {'required': True}, - 'subscription_id': {'required': True}, + "name": {"required": True}, + "event_hub_name_space": {"required": True}, + "event_hub_name": {"required": True}, + "subscription_id": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'event_hub_name_space': {'key': 'eventHubNameSpace', 'type': 'str'}, - 'event_hub_name': {'key': 'eventHubName', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "event_hub_name_space": {"key": "eventHubNameSpace", "type": "str"}, + "event_hub_name": {"key": "eventHubName", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, } def __init__( @@ -789,26 +739,26 @@ def __init__( event_hub_name_space: str, event_hub_name: str, subscription_id: str, - use_common_alert_schema: Optional[bool] = False, + use_common_alert_schema: bool = False, tenant_id: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the Event hub receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the Event hub receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword event_hub_name_space: Required. The Event Hub namespace. + :keyword event_hub_name_space: The Event Hub namespace. Required. :paramtype event_hub_name_space: str - :keyword event_hub_name: Required. The name of the specific Event Hub queue. + :keyword event_hub_name: The name of the specific Event Hub queue. Required. :paramtype event_hub_name: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool :keyword tenant_id: The tenant Id for the subscription containing this event hub. :paramtype tenant_id: str - :keyword subscription_id: Required. The Id for the subscription containing this event hub. + :keyword subscription_id: The Id for the subscription containing this event hub. Required. :paramtype subscription_id: str """ - super(EventHubReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.event_hub_name_space = event_hub_name_space self.event_hub_name = event_hub_name @@ -817,70 +767,65 @@ def __init__( self.subscription_id = subscription_id -class ItsmReceiver(msrest.serialization.Model): +class ItsmReceiver(_serialization.Model): """An Itsm receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar workspace_id: Required. OMS LA instance identifier. + :ivar workspace_id: OMS LA instance identifier. Required. :vartype workspace_id: str - :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined - in above workspace. + :ivar connection_id: Unique identification of ITSM connection among multiple defined in above + workspace. Required. :vartype connection_id: str - :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :vartype ticket_configuration: str - :ivar region: Required. Region in which workspace resides. Supported + :ivar region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :vartype region: str """ _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, + "name": {"required": True}, + "workspace_id": {"required": True}, + "connection_id": {"required": True}, + "ticket_configuration": {"required": True}, + "region": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "connection_id": {"key": "connectionId", "type": "str"}, + "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, + "region": {"key": "region", "type": "str"}, } def __init__( - self, - *, - name: str, - workspace_id: str, - connection_id: str, - ticket_configuration: str, - region: str, - **kwargs + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs ): """ - :keyword name: Required. The name of the Itsm receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword workspace_id: Required. OMS LA instance identifier. + :keyword workspace_id: OMS LA instance identifier. Required. :paramtype workspace_id: str - :keyword connection_id: Required. Unique identification of ITSM connection among multiple - defined in above workspace. + :keyword connection_id: Unique identification of ITSM connection among multiple defined in + above workspace. Required. :paramtype connection_id: str - :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. + :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. :paramtype ticket_configuration: str - :keyword region: Required. Region in which workspace resides. Supported + :keyword region: Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + Required. :paramtype region: str """ - super(ItsmReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.workspace_id = workspace_id self.connection_id = connection_id @@ -888,68 +833,62 @@ def __init__( self.region = region -class LogicAppReceiver(msrest.serialization.Model): +class LogicAppReceiver(_serialization.Model): """A logic app receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :vartype name: str - :ivar resource_id: Required. The azure resource id of the logic app receiver. + :ivar resource_id: The azure resource id of the logic app receiver. Required. :vartype resource_id: str - :ivar callback_url: Required. The callback url where http request sent to. + :ivar callback_url: The callback url where http request sent to. Required. :vartype callback_url: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool """ _validation = { - 'name': {'required': True}, - 'resource_id': {'required': True}, - 'callback_url': {'required': True}, + "name": {"required": True}, + "resource_id": {"required": True}, + "callback_url": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "callback_url": {"key": "callbackUrl", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } def __init__( - self, - *, - name: str, - resource_id: str, - callback_url: str, - use_common_alert_schema: Optional[bool] = False, - **kwargs + self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs ): """ - :keyword name: Required. The name of the logic app receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword resource_id: Required. The azure resource id of the logic app receiver. + :keyword resource_id: The azure resource id of the logic app receiver. Required. :paramtype resource_id: str - :keyword callback_url: Required. The callback url where http request sent to. + :keyword callback_url: The callback url where http request sent to. Required. :paramtype callback_url: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool """ - super(LogicAppReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.resource_id = resource_id self.callback_url = callback_url self.use_common_alert_schema = use_common_alert_schema -class NotificationRequestBody(msrest.serialization.Model): +class NotificationRequestBody(_serialization.Model): # pylint: disable=too-many-instance-attributes """The request body which contain contact detail metadata. All required parameters must be populated in order to send to Azure. - :ivar alert_type: Required. The name of the supported alert type. + :ivar alert_type: The name of the supported alert type. Required. :vartype alert_type: str :ivar email_receivers: The list of email receivers that are part of this action group. :vartype email_receivers: list[~$(python-base-namespace).v2022_06_01.models.EmailReceiver] @@ -985,22 +924,22 @@ class NotificationRequestBody(msrest.serialization.Model): """ _validation = { - 'alert_type': {'required': True, 'max_length': 30, 'min_length': 0}, + "alert_type": {"required": True, "max_length": 30}, } _attribute_map = { - 'alert_type': {'key': 'alertType', 'type': 'str'}, - 'email_receivers': {'key': 'emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'armRoleReceivers', 'type': '[ArmRoleReceiver]'}, - 'event_hub_receivers': {'key': 'eventHubReceivers', 'type': '[EventHubReceiver]'}, + "alert_type": {"key": "alertType", "type": "str"}, + "email_receivers": {"key": "emailReceivers", "type": "[EmailReceiver]"}, + "sms_receivers": {"key": "smsReceivers", "type": "[SmsReceiver]"}, + "webhook_receivers": {"key": "webhookReceivers", "type": "[WebhookReceiver]"}, + "itsm_receivers": {"key": "itsmReceivers", "type": "[ItsmReceiver]"}, + "azure_app_push_receivers": {"key": "azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, + "automation_runbook_receivers": {"key": "automationRunbookReceivers", "type": "[AutomationRunbookReceiver]"}, + "voice_receivers": {"key": "voiceReceivers", "type": "[VoiceReceiver]"}, + "logic_app_receivers": {"key": "logicAppReceivers", "type": "[LogicAppReceiver]"}, + "azure_function_receivers": {"key": "azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, + "arm_role_receivers": {"key": "armRoleReceivers", "type": "[ArmRoleReceiver]"}, + "event_hub_receivers": {"key": "eventHubReceivers", "type": "[EventHubReceiver]"}, } def __init__( @@ -1021,7 +960,7 @@ def __init__( **kwargs ): """ - :keyword alert_type: Required. The name of the supported alert type. + :keyword alert_type: The name of the supported alert type. Required. :paramtype alert_type: str :keyword email_receivers: The list of email receivers that are part of this action group. :paramtype email_receivers: list[~$(python-base-namespace).v2022_06_01.models.EmailReceiver] @@ -1059,7 +998,7 @@ def __init__( :paramtype event_hub_receivers: list[~$(python-base-namespace).v2022_06_01.models.EventHubReceiver] """ - super(NotificationRequestBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.alert_type = alert_type self.email_receivers = email_receivers self.sms_receivers = sms_receivers @@ -1074,71 +1013,64 @@ def __init__( self.event_hub_receivers = event_hub_receivers -class SmsReceiver(msrest.serialization.Model): +class SmsReceiver(_serialization.Model): """An SMS receiver. Variables are only 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 name: Required. The name of the SMS receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the SMS receiver. + :ivar country_code: The country code of the SMS receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the SMS receiver. + :ivar phone_number: The phone number of the SMS receiver. Required. :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and "Disabled". :vartype status: str or ~$(python-base-namespace).v2022_06_01.models.ReceiverStatus """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the SMS receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the SMS receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the SMS receiver. + :keyword country_code: The country code of the SMS receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the SMS receiver. + :keyword phone_number: The phone number of the SMS receiver. Required. :paramtype phone_number: str """ - super(SmsReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number self.status = None -class TestNotificationDetailsResponse(msrest.serialization.Model): +class TestNotificationDetailsResponse(_serialization.Model): """The details of the test notification results. All required parameters must be populated in order to send to Azure. :ivar context: The context info. :vartype context: ~$(python-base-namespace).v2022_06_01.models.Context - :ivar state: Required. The overall state. + :ivar state: The overall state. Required. :vartype state: str :ivar completed_time: The completed time. :vartype completed_time: str @@ -1149,15 +1081,15 @@ class TestNotificationDetailsResponse(msrest.serialization.Model): """ _validation = { - 'state': {'required': True}, + "state": {"required": True}, } _attribute_map = { - 'context': {'key': 'context', 'type': 'Context'}, - 'state': {'key': 'state', 'type': 'str'}, - 'completed_time': {'key': 'completedTime', 'type': 'str'}, - 'created_time': {'key': 'createdTime', 'type': 'str'}, - 'action_details': {'key': 'actionDetails', 'type': '[ActionDetail]'}, + "context": {"key": "context", "type": "Context"}, + "state": {"key": "state", "type": "str"}, + "completed_time": {"key": "completedTime", "type": "str"}, + "created_time": {"key": "createdTime", "type": "str"}, + "action_details": {"key": "actionDetails", "type": "[ActionDetail]"}, } def __init__( @@ -1173,7 +1105,7 @@ def __init__( """ :keyword context: The context info. :paramtype context: ~$(python-base-namespace).v2022_06_01.models.Context - :keyword state: Required. The overall state. + :keyword state: The overall state. Required. :paramtype state: str :keyword completed_time: The completed time. :paramtype completed_time: str @@ -1182,7 +1114,7 @@ def __init__( :keyword action_details: The list of action detail. :paramtype action_details: list[~$(python-base-namespace).v2022_06_01.models.ActionDetail] """ - super(TestNotificationDetailsResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.context = context self.state = state self.completed_time = completed_time @@ -1190,64 +1122,57 @@ def __init__( self.action_details = action_details -class VoiceReceiver(msrest.serialization.Model): +class VoiceReceiver(_serialization.Model): """A voice receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers - within an action group. + :ivar name: The name of the voice receiver. Names must be unique across all receivers within an + action group. Required. :vartype name: str - :ivar country_code: Required. The country code of the voice receiver. + :ivar country_code: The country code of the voice receiver. Required. :vartype country_code: str - :ivar phone_number: Required. The phone number of the voice receiver. + :ivar phone_number: The phone number of the voice receiver. Required. :vartype phone_number: str """ _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__( - self, - *, - name: str, - country_code: str, - phone_number: str, - **kwargs - ): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): """ - :keyword name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the voice receiver. Names must be unique across all receivers within + an action group. Required. :paramtype name: str - :keyword country_code: Required. The country code of the voice receiver. + :keyword country_code: The country code of the voice receiver. Required. :paramtype country_code: str - :keyword phone_number: Required. The phone number of the voice receiver. + :keyword phone_number: The phone number of the voice receiver. Required. :paramtype phone_number: str """ - super(VoiceReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.country_code = country_code self.phone_number = phone_number -class WebhookReceiver(msrest.serialization.Model): +class WebhookReceiver(_serialization.Model): """A webhook receiver. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :ivar name: The name of the webhook receiver. Names must be unique across all receivers within + an action group. Required. :vartype name: str - :ivar service_uri: Required. The URI where webhooks should be sent. + :ivar service_uri: The URI where webhooks should be sent. Required. :vartype service_uri: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool @@ -1262,18 +1187,18 @@ class WebhookReceiver(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, + "name": {"required": True}, + "service_uri": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'use_aad_auth': {'key': 'useAadAuth', 'type': 'bool'}, - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'identifier_uri': {'key': 'identifierUri', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "use_aad_auth": {"key": "useAadAuth", "type": "bool"}, + "object_id": {"key": "objectId", "type": "str"}, + "identifier_uri": {"key": "identifierUri", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } def __init__( @@ -1281,18 +1206,18 @@ def __init__( *, name: str, service_uri: str, - use_common_alert_schema: Optional[bool] = False, - use_aad_auth: Optional[bool] = False, + use_common_alert_schema: bool = False, + use_aad_auth: bool = False, object_id: Optional[str] = None, identifier_uri: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs ): """ - :keyword name: Required. The name of the webhook receiver. Names must be unique across all - receivers within an action group. + :keyword name: The name of the webhook receiver. Names must be unique across all receivers + within an action group. Required. :paramtype name: str - :keyword service_uri: Required. The URI where webhooks should be sent. + :keyword service_uri: The URI where webhooks should be sent. Required. :paramtype service_uri: str :keyword use_common_alert_schema: Indicates whether to use common alert schema. :paramtype use_common_alert_schema: bool @@ -1305,7 +1230,7 @@ def __init__( :keyword tenant_id: Indicates the tenant id for aad auth. :paramtype tenant_id: str """ - super(WebhookReceiver, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.service_uri = service_uri self.use_common_alert_schema = use_common_alert_schema diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_patch.py @@ -10,6 +10,7 @@ __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. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/__init__.py index 60f9d62f0ead..0e396f5d7fb0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ActionGroupsOperations', + "ActionGroupsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_action_groups_operations.py index 3a6787b26316..bad27509a156 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_action_groups_operations.py @@ -6,11 +6,16 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,528 +27,438 @@ 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 -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.ActionGroupResource] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - action_group_name: str, - *, - json: Optional[_models.ActionGroupPatchBody] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_post_test_notifications_request_initial( - subscription_id: str, - *, - json: Optional[_models.NotificationRequestBody] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_post_test_notifications_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_create_notifications_at_resource_group_level_request_initial( - subscription_id: str, - resource_group_name: str, - *, - json: Optional[_models.NotificationRequestBody] = None, - content: Any = None, - **kwargs: Any + +def build_create_notifications_at_resource_group_level_request( + resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_create_notifications_at_action_group_resource_level_request_initial( - subscription_id: str, - resource_group_name: str, - action_group_name: str, - *, - json: Optional[_models.NotificationRequestBody] = None, - content: Any = None, - **kwargs: Any + +def build_create_notifications_at_action_group_resource_level_request( + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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_test_notifications_request( - subscription_id: str, - notification_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_test_notifications_request(notification_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_test_notifications_at_resource_group_level_request( - subscription_id: str, - resource_group_name: str, - notification_id: str, - **kwargs: Any + resource_group_name: str, notification_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_test_notifications_at_action_group_resource_level_request( - subscription_id: str, - resource_group_name: str, - action_group_name: str, - notification_id: str, - **kwargs: Any + resource_group_name: str, action_group_name: str, notification_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_id_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_enable_receiver_request( - resource_group_name: str, - action_group_name: str, - subscription_id: str, - *, - json: Optional[_models.EnableRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _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 ActionGroupsOperations: """ @@ -564,41 +479,105 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, action_group_name: str, action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. + :param action_group: The action group to create or use for the update. Required. :type action_group: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a model type + or a IO type. Required. + :type action_group: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group, 'ActionGroupResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IO, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -607,7 +586,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -615,10 +595,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -627,55 +606,47 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any - ) -> _models.ActionGroupResource: + def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -683,10 +654,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -694,52 +664,46 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, **kwargs: Any ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -747,10 +711,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -761,52 +724,118 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, action_group_name: str, action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. + :param action_group_patch: Parameters supplied to the operation. Required. :type action_group_patch: ~$(python-base-namespace).v2022_06_01.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: ActionGroupResource, or the result of cls(response) + :return: ActionGroupResource or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO + type. Required. + :type action_group_patch: ~$(python-base-namespace).v2022_06_01.models.ActionGroupPatchBody or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: ActionGroupResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] - _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IO, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -814,10 +843,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -825,41 +853,43 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ActionGroupResource', pipeline_response) + deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore def _post_test_notifications_initial( - self, - notification_request: _models.NotificationRequestBody, - **kwargs: Any + self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_post_test_notifications_request_initial( + request = build_post_test_notifications_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._post_test_notifications_initial.metadata['url'], + content=_content, + template_url=self._post_test_notifications_initial.metadata["url"], headers=_headers, params=_params, ) @@ -867,44 +897,48 @@ def _post_test_notifications_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _post_test_notifications_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore - + _post_test_notifications_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore - @distributed_trace + @overload def begin_post_test_notifications( self, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -917,86 +951,138 @@ def begin_post_test_notifications( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_post_test_notifications( + self, notification_request: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_post_test_notifications( + self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._post_test_notifications_initial( # type: ignore notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_post_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_post_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore def _create_notifications_at_resource_group_level_initial( - self, - resource_group_name: str, - notification_request: _models.NotificationRequestBody, - **kwargs: Any + self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_create_notifications_at_resource_group_level_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_notifications_at_resource_group_level_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_notifications_at_resource_group_level_initial.metadata['url'], + content=_content, + template_url=self._create_notifications_at_resource_group_level_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1004,47 +1090,52 @@ def _create_notifications_at_resource_group_level_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_notifications_at_resource_group_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore - + _create_notifications_at_resource_group_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore - @distributed_trace + @overload def begin_create_notifications_at_resource_group_level( self, resource_group_name: str, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1057,89 +1148,155 @@ def begin_create_notifications_at_resource_group_level( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_notifications_at_resource_group_level( + self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_notifications_at_resource_group_level_initial( # type: ignore resource_group_name=resource_group_name, notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_create_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore def _create_notifications_at_action_group_resource_level_initial( self, resource_group_name: str, action_group_name: str, - notification_request: _models.NotificationRequestBody, + notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] - _json = self._serialize.body(notification_request, 'NotificationRequestBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IO, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") - request = build_create_notifications_at_action_group_resource_level_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_notifications_at_action_group_resource_level_request( resource_group_name=resource_group_name, action_group_name=action_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_notifications_at_action_group_resource_level_initial.metadata['url'], + content=_content, + template_url=self._create_notifications_at_action_group_resource_level_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1147,50 +1304,130 @@ def _create_notifications_at_action_group_resource_level_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if response.status_code == 202: - response_headers['location']=self._deserialize('str', response.headers.get('location')) - + response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_notifications_at_action_group_resource_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore - + _create_notifications_at_action_group_resource_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore - @distributed_trace + @overload def begin_create_notifications_at_action_group_resource_level( self, resource_group_name: str, action_group_name: str, notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str :param notification_request: The notification request body which includes the contact details. + Required. :type notification_request: ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_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 TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_request: Union[_models.NotificationRequestBody, IO], + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a model type or a IO type. Required. + :type notification_request: + ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 @@ -1203,20 +1440,17 @@ def begin_create_notifications_at_action_group_resource_level( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_notifications_at_action_group_resource_level_initial( # type: ignore resource_group_name=resource_group_name, @@ -1224,72 +1458,63 @@ def begin_create_notifications_at_action_group_resource_level( notification_request=notification_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_notifications_at_action_group_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + begin_create_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore @distributed_trace - def get_test_notifications( - self, - notification_id: str, - **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: + def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_request( - subscription_id=self._config.subscription_id, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications.metadata['url'], + template_url=self.get_test_notifications.metadata["url"], headers=_headers, params=_params, ) @@ -1297,10 +1522,9 @@ def get_test_notifications( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1308,52 +1532,46 @@ def get_test_notifications( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore @distributed_trace def get_test_notifications_at_resource_group_level( - self, - resource_group_name: str, - notification_id: str, - **kwargs: Any + self, resource_group_name: str, notification_id: str, **kwargs: Any ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_at_resource_group_level_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications_at_resource_group_level.metadata['url'], + template_url=self.get_test_notifications_at_resource_group_level.metadata["url"], headers=_headers, params=_params, ) @@ -1361,10 +1579,9 @@ def get_test_notifications_at_resource_group_level( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1372,56 +1589,49 @@ def get_test_notifications_at_resource_group_level( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore @distributed_trace def get_test_notifications_at_action_group_resource_level( - self, - resource_group_name: str, - action_group_name: str, - notification_id: str, - **kwargs: Any + self, resource_group_name: str, action_group_name: str, notification_id: str, **kwargs: Any ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param notification_id: The notification id. + :param notification_id: The notification id. Required. :type notification_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse, or the result of cls(response) + :return: TestNotificationDetailsResponse or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - request = build_get_test_notifications_at_action_group_resource_level_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, notification_id=notification_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_test_notifications_at_action_group_resource_level.metadata['url'], + template_url=self.get_test_notifications_at_action_group_resource_level.metadata["url"], headers=_headers, params=_params, ) @@ -1429,10 +1639,9 @@ def get_test_notifications_at_action_group_resource_level( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1440,46 +1649,41 @@ def get_test_notifications_at_action_group_resource_level( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_test_notifications_at_action_group_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}"} # type: ignore - + get_test_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}"} # type: ignore @distributed_trace - def list_by_subscription_id( - self, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_06_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_06_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription_id.metadata['url'], + template_url=self.list_by_subscription_id.metadata["url"], headers=_headers, params=_params, ) @@ -1487,14 +1691,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1510,10 +1711,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1524,46 +1723,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.ActionGroupList]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ActionGroupResource"]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ActionGroupList or the result of cls(response) + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_06_01.models.ActionGroupList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_06_01.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1571,15 +1766,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1595,10 +1786,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1609,47 +1798,116 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore - @distributed_trace + @overload def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param action_group_name: The name of the action group. + :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. + :param enable_request: The receiver to re-enable. Required. :type enable_request: ~$(python-base-namespace).v2022_06_01.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + Required. + :type enable_request: ~$(python-base-namespace).v2022_06_01.models.EnableRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(enable_request, 'EnableRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IO, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") request = build_enable_receiver_request( resource_group_name=resource_group_name, @@ -1658,7 +1916,8 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.enable_receiver.metadata['url'], + content=_content, + template_url=self.enable_receiver.metadata["url"], headers=_headers, params=_params, ) @@ -1666,10 +1925,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1680,5 +1938,4 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore - + enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_patch.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_patch.py @@ -10,6 +10,7 @@ __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.