diff --git a/src/datadog/HISTORY.rst b/src/datadog/HISTORY.rst new file mode 100644 index 00000000000..1c139576ba0 --- /dev/null +++ b/src/datadog/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. diff --git a/src/datadog/README.md b/src/datadog/README.md new file mode 100644 index 00000000000..b5ab201dcc0 --- /dev/null +++ b/src/datadog/README.md @@ -0,0 +1,5 @@ +Microsoft Azure CLI 'datadog' Extension +========================================== + +This package is for the 'datadog' extension. +i.e. 'az datadog' diff --git a/src/datadog/azext_datadog/__init__.py b/src/datadog/azext_datadog/__init__.py new file mode 100644 index 00000000000..51fecb70315 --- /dev/null +++ b/src/datadog/azext_datadog/__init__.py @@ -0,0 +1,50 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azext_datadog.generated._help import helps # pylint: disable=unused-import +try: + from azext_datadog.manual._help import helps # pylint: disable=reimported +except ImportError: + pass + + +class MicrosoftDatadogClientCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from azext_datadog.generated._client_factory import cf_datadog_cl + datadog_custom = CliCommandType( + operations_tmpl='azext_datadog.custom#{}', + client_factory=cf_datadog_cl) + parent = super(MicrosoftDatadogClientCommandsLoader, self) + parent.__init__(cli_ctx=cli_ctx, custom_command_type=datadog_custom) + + def load_command_table(self, args): + from azext_datadog.generated.commands import load_command_table + load_command_table(self, args) + try: + from azext_datadog.manual.commands import load_command_table as load_command_table_manual + load_command_table_manual(self, args) + except ImportError: + pass + return self.command_table + + def load_arguments(self, command): + from azext_datadog.generated._params import load_arguments + load_arguments(self, command) + try: + from azext_datadog.manual._params import load_arguments as load_arguments_manual + load_arguments_manual(self, command) + except ImportError: + pass + + +COMMAND_LOADER_CLS = MicrosoftDatadogClientCommandsLoader diff --git a/src/datadog/azext_datadog/action.py b/src/datadog/azext_datadog/action.py new file mode 100644 index 00000000000..d95d53bf711 --- /dev/null +++ b/src/datadog/azext_datadog/action.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.action import * # noqa: F403 +try: + from .manual.action import * # noqa: F403 +except ImportError: + pass diff --git a/src/datadog/azext_datadog/azext_metadata.json b/src/datadog/azext_datadog/azext_metadata.json new file mode 100644 index 00000000000..4f48fa652a5 --- /dev/null +++ b/src/datadog/azext_datadog/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isExperimental": true, + "azext.minCliCoreVersion": "2.11.0" +} \ No newline at end of file diff --git a/src/datadog/azext_datadog/custom.py b/src/datadog/azext_datadog/custom.py new file mode 100644 index 00000000000..dbe9d5f9742 --- /dev/null +++ b/src/datadog/azext_datadog/custom.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.custom import * # noqa: F403 +try: + from .manual.custom import * # noqa: F403 +except ImportError: + pass diff --git a/src/datadog/azext_datadog/generated/__init__.py b/src/datadog/azext_datadog/generated/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/datadog/azext_datadog/generated/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/datadog/azext_datadog/generated/_client_factory.py b/src/datadog/azext_datadog/generated/_client_factory.py new file mode 100644 index 00000000000..2846bbd5a71 --- /dev/null +++ b/src/datadog/azext_datadog/generated/_client_factory.py @@ -0,0 +1,48 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + + +def cf_datadog_cl(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from ..vendored_sdks.datadog import MicrosoftDatadogClient + return get_mgmt_service_client(cli_ctx, + MicrosoftDatadogClient) + + +def cf_api_key(cli_ctx, *_): + return cf_datadog_cl(cli_ctx).api_key + + +def cf_host(cli_ctx, *_): + return cf_datadog_cl(cli_ctx).host + + +def cf_linked_resource(cli_ctx, *_): + return cf_datadog_cl(cli_ctx).linked_resource + + +def cf_monitored_resource(cli_ctx, *_): + return cf_datadog_cl(cli_ctx).monitored_resource + + +def cf_monitor(cli_ctx, *_): + return cf_datadog_cl(cli_ctx).monitor + + +def cf_refresh_set_password(cli_ctx, *_): + return cf_datadog_cl(cli_ctx).refresh_set_password + + +def cf_tag_rule(cli_ctx, *_): + return cf_datadog_cl(cli_ctx).tag_rule + + +def cf_single_sign_on_configuration(cli_ctx, *_): + return cf_datadog_cl(cli_ctx).single_sign_on_configuration diff --git a/src/datadog/azext_datadog/generated/_help.py b/src/datadog/azext_datadog/generated/_help.py new file mode 100644 index 00000000000..f05316bb415 --- /dev/null +++ b/src/datadog/azext_datadog/generated/_help.py @@ -0,0 +1,351 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +from knack.help_files import helps + + +helps['datadog api-key'] = """ + type: group + short-summary: datadog api-key +""" + +helps['datadog api-key list'] = """ + type: command + short-summary: "List the api keys for a given monitor resource." + examples: + - name: ApiKeys_List + text: |- + az datadog api-key list --monitor-name "myMonitor" --resource-group "myResourceGroup" +""" + +helps['datadog api-key get-default-key'] = """ + type: command + short-summary: "Get the default api key." + examples: + - name: ApiKeys_GetDefaultKey + text: |- + az datadog api-key get-default-key --monitor-name "myMonitor" --resource-group "myResourceGroup" +""" + +helps['datadog api-key set-default-key'] = """ + type: command + short-summary: "Set the default api key." + examples: + - name: ApiKeys_SetDefaultKey + text: |- + az datadog api-key set-default-key --monitor-name "myMonitor" --key "1111111111111111aaaaaaaaaaaaaaaa" \ +--resource-group "myResourceGroup" +""" + +helps['datadog host'] = """ + type: group + short-summary: datadog host +""" + +helps['datadog host list'] = """ + type: command + short-summary: "List the hosts for a given monitor resource." + examples: + - name: Hosts_List + text: |- + az datadog host list --monitor-name "myMonitor" --resource-group "myResourceGroup" +""" + +helps['datadog linked-resource'] = """ + type: group + short-summary: datadog linked-resource +""" + +helps['datadog linked-resource list'] = """ + type: command + short-summary: "List all Azure resources associated to the same Datadog organization as the target resource." + examples: + - name: LinkedResources_List + text: |- + az datadog linked-resource list --monitor-name "myMonitor" --resource-group "myResourceGroup" +""" + +helps['datadog monitored-resource'] = """ + type: group + short-summary: datadog monitored-resource +""" + +helps['datadog monitored-resource list'] = """ + type: command + short-summary: "List the resources currently being monitored by the Datadog monitor resource." + examples: + - name: MonitoredResources_List + text: |- + az datadog monitored-resource list --monitor-name "myMonitor" --resource-group "myResourceGroup" +""" + +helps['datadog monitor'] = """ + type: group + short-summary: datadog monitor +""" + +helps['datadog monitor list'] = """ + type: command + short-summary: "List all monitors under the specified subscription." + examples: + - name: Monitors_ListByResourceGroup + text: |- + az datadog monitor list --resource-group "myResourceGroup" +""" + +helps['datadog monitor show'] = """ + type: command + short-summary: "Get the properties of a specific monitor resource." + examples: + - name: Monitors_Get + text: |- + az datadog monitor show --name "myMonitor" --resource-group "myResourceGroup" +""" + +helps['datadog monitor create'] = """ + type: command + short-summary: "Create a monitor resource." + parameters: + - name: --datadog-organization-properties + long-summary: | + Usage: --datadog-organization-properties linking-auth-code=XX linking-client-id=XX enterprise-app-id=XX + + linking-auth-code: The auth code used to linking to an existing datadog organization. + linking-client-id: The client_id from an existing in exchange for an auth token to link organization. + enterprise-app-id: The Id of the Enterprise App used for Single sign on. + - name: --user-info + long-summary: | + Usage: --user-info name=XX email-address=XX phone-number=XX + + name: Name of the user + email-address: Email of the user used by Datadog for contacting them if needed + phone-number: Phone number of the user used by Datadog for contacting them if needed + examples: + - name: Monitors_Create + text: |- + az datadog monitor create --name "myMonitor" --sku-name "myMonitor" --location "West US" \ +--datadog-organization-properties name="myOrg" enterprise-app-id="00000000-0000-0000-0000-000000000000" \ +linking-auth-code="someAuthCode" linking-client-id="00000000-0000-0000-0000-000000000000" subscription="pro" \ +--monitoring-status "Enabled" --user-info name="Alice" email-address="alice@microsoft.com" phone-number="123-456-7890" \ +--sku-name "free_Monthly" --tags Environment="Dev" --resource-group "myResourceGroup" +""" + +helps['datadog monitor update'] = """ + type: command + short-summary: "Update a monitor resource." + examples: + - name: Monitors_Update + text: |- + az datadog monitor update --name "myMonitor" --monitoring-status "Enabled" --tags Environment="Dev" \ +--resource-group "myResourceGroup" +""" + +helps['datadog monitor delete'] = """ + type: command + short-summary: "Delete a monitor resource." + examples: + - name: Monitors_Delete + text: |- + az datadog monitor delete --name "myMonitor" --resource-group "myResourceGroup" +""" + +helps['datadog monitor wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the datadog monitor is met. + examples: + - name: Pause executing next line of CLI script until the datadog monitor is successfully created. + text: |- + az datadog monitor wait --name "myMonitor" --resource-group "myResourceGroup" --created + - name: Pause executing next line of CLI script until the datadog monitor is successfully deleted. + text: |- + az datadog monitor wait --name "myMonitor" --resource-group "myResourceGroup" --deleted +""" + +helps['datadog refresh-set-password'] = """ + type: group + short-summary: datadog refresh-set-password +""" + +helps['datadog refresh-set-password get'] = """ + type: command + short-summary: "Refresh the set password link and return a latest one." + examples: + - name: RefreshSetPassword_Get + text: |- + az datadog refresh-set-password get --monitor-name "myMonitor" --resource-group "myResourceGroup" +""" + +helps['datadog tag-rule'] = """ + type: group + short-summary: datadog tag-rule +""" + +helps['datadog tag-rule list'] = """ + type: command + short-summary: "List the tag rules for a given monitor resource." + examples: + - name: TagRules_List + text: |- + az datadog tag-rule list --monitor-name "myMonitor" --resource-group "myResourceGroup" +""" + +helps['datadog tag-rule show'] = """ + type: command + short-summary: "Get a tag rule set for a given monitor resource." + examples: + - name: TagRules_Get + text: |- + az datadog tag-rule show --monitor-name "myMonitor" --resource-group "myResourceGroup" --rule-set-name \ +"default" +""" + +helps['datadog tag-rule create'] = """ + type: command + short-summary: "Create or update a tag rule set for a given monitor resource." + parameters: + - name: --metric-rules-filtering-tags + short-summary: "List of filtering tags to be used for capturing metrics. If empty, all resources will be \ +captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include \ +actions are specified, the rules will only include resources with the associated tags." + long-summary: | + Usage: --metric-rules-filtering-tags name=XX value=XX action=XX + + name: The name (also known as the key) of the tag. + value: The value of the tag. + action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. + + Multiple actions can be specified by using more than one --metric-rules-filtering-tags argument. + - name: --log-rules-filtering-tags + short-summary: "List of filtering tags to be used for capturing logs. This only takes effect if \ +SendResourceLogs flag is enabled. If empty, all resources will be captured. If only Exclude action is specified, the \ +rules will apply to the list of all available resources. If Include actions are specified, the rules will only include \ +resources with the associated tags." + long-summary: | + Usage: --log-rules-filtering-tags name=XX value=XX action=XX + + name: The name (also known as the key) of the tag. + value: The value of the tag. + action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. + + Multiple actions can be specified by using more than one --log-rules-filtering-tags argument. + examples: + - name: TagRules_CreateOrUpdate + text: |- + az datadog tag-rule create --monitor-name "myMonitor" --log-rules-filtering-tags name="Environment" \ +action="Include" value="Prod" --log-rules-filtering-tags name="Environment" action="Exclude" value="Dev" \ +--log-rules-send-aad-logs false --log-rules-send-resource-logs true --log-rules-send-subscription-logs true \ +--resource-group "myResourceGroup" --rule-set-name "default" +""" + +helps['datadog tag-rule update'] = """ + type: command + short-summary: "Create or update a tag rule set for a given monitor resource." + parameters: + - name: --metric-rules-filtering-tags + short-summary: "List of filtering tags to be used for capturing metrics. If empty, all resources will be \ +captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include \ +actions are specified, the rules will only include resources with the associated tags." + long-summary: | + Usage: --metric-rules-filtering-tags name=XX value=XX action=XX + + name: The name (also known as the key) of the tag. + value: The value of the tag. + action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. + + Multiple actions can be specified by using more than one --metric-rules-filtering-tags argument. + - name: --log-rules-filtering-tags + short-summary: "List of filtering tags to be used for capturing logs. This only takes effect if \ +SendResourceLogs flag is enabled. If empty, all resources will be captured. If only Exclude action is specified, the \ +rules will apply to the list of all available resources. If Include actions are specified, the rules will only include \ +resources with the associated tags." + long-summary: | + Usage: --log-rules-filtering-tags name=XX value=XX action=XX + + name: The name (also known as the key) of the tag. + value: The value of the tag. + action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. + + Multiple actions can be specified by using more than one --log-rules-filtering-tags argument. +""" + +helps['datadog single-sign-on-configuration'] = """ + type: group + short-summary: datadog single-sign-on-configuration +""" + +helps['datadog single-sign-on-configuration list'] = """ + type: command + short-summary: "List the single sign-on configurations for a given monitor resource." + examples: + - name: SingleSignOnConfigurations_List + text: |- + az datadog single-sign-on-configuration list --monitor-name "myMonitor" --resource-group \ +"myResourceGroup" +""" + +helps['datadog single-sign-on-configuration show'] = """ + type: command + short-summary: "Gets the datadog single sign-on resource for the given Monitor." + examples: + - name: SingleSignOnConfigurations_Get + text: |- + az datadog single-sign-on-configuration show --configuration-name "default" --monitor-name "myMonitor" \ +--resource-group "myResourceGroup" +""" + +helps['datadog single-sign-on-configuration create'] = """ + type: command + short-summary: "Configures single-sign-on for this resource." + parameters: + - name: --properties + long-summary: | + Usage: --properties single-sign-on-state=XX enterprise-app-id=XX single-sign-on-url=XX + + single-sign-on-state: Various states of the SSO resource + enterprise-app-id: The Id of the Enterprise App used for Single sign-on. + single-sign-on-url: The login URL specific to this Datadog Organization. + examples: + - name: SingleSignOnConfigurations_CreateOrUpdate + text: |- + az datadog single-sign-on-configuration create --configuration-name "default" --monitor-name \ +"myMonitor" --properties enterprise-app-id="00000000-0000-0000-0000-000000000000" single-sign-on-state="Enable" \ +--resource-group "myResourceGroup" +""" + +helps['datadog single-sign-on-configuration update'] = """ + type: command + short-summary: "Configures single-sign-on for this resource." + parameters: + - name: --properties + long-summary: | + Usage: --properties single-sign-on-state=XX enterprise-app-id=XX single-sign-on-url=XX + + single-sign-on-state: Various states of the SSO resource + enterprise-app-id: The Id of the Enterprise App used for Single sign-on. + single-sign-on-url: The login URL specific to this Datadog Organization. +""" + +helps['datadog single-sign-on-configuration wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the datadog single-sign-on-configuration is \ +met. + examples: + - name: Pause executing next line of CLI script until the datadog single-sign-on-configuration is successfully \ +created. + text: |- + az datadog single-sign-on-configuration wait --configuration-name "default" --monitor-name "myMonitor" \ +--resource-group "myResourceGroup" --created + - name: Pause executing next line of CLI script until the datadog single-sign-on-configuration is successfully \ +updated. + text: |- + az datadog single-sign-on-configuration wait --configuration-name "default" --monitor-name "myMonitor" \ +--resource-group "myResourceGroup" --updated +""" diff --git a/src/datadog/azext_datadog/generated/_params.py b/src/datadog/azext_datadog/generated/_params.py new file mode 100644 index 00000000000..3f8dea6d53b --- /dev/null +++ b/src/datadog/azext_datadog/generated/_params.py @@ -0,0 +1,183 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from azure.cli.core.commands.parameters import ( + tags_type, + get_three_state_flag, + get_enum_type, + resource_group_name_type, + get_location_type +) +from azure.cli.core.commands.validators import get_default_location_from_resource_group +from azext_datadog.action import ( + AddDatadogOrganizationProperties, + AddUserInfo, + AddMetricRulesFilteringTags, + AddLogRulesFilteringTags, + AddProperties +) + + +def load_arguments(self, _): + + with self.argument_context('datadog api-key list') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name') + + with self.argument_context('datadog api-key get-default-key') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name', id_part='name') + + with self.argument_context('datadog api-key set-default-key') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name', id_part='name') + c.argument('created_by', type=str, help='The user that created the API key.') + c.argument('name', type=str, help='The name of the API key.') + c.argument('key', type=str, help='The value of the API key.') + c.argument('created', type=str, help='The time of creation of the API key.') + + with self.argument_context('datadog host list') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name') + + with self.argument_context('datadog linked-resource list') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name') + + with self.argument_context('datadog monitored-resource list') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name') + + with self.argument_context('datadog monitor list') as c: + c.argument('resource_group_name', resource_group_name_type) + + with self.argument_context('datadog monitor show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', options_list=['--name', '-n', '--monitor-name'], type=str, help='Monitor resource ' + 'name', id_part='name') + + with self.argument_context('datadog monitor create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', options_list=['--name', '-n', '--monitor-name'], type=str, help='Monitor resource ' + 'name') + c.argument('tags', tags_type) + c.argument('location', arg_type=get_location_type(self.cli_ctx), + validator=get_default_location_from_resource_group) + c.argument('identity_type', arg_type=get_enum_type(['SystemAssigned', 'UserAssigned']), help='') + c.argument('provisioning_state', arg_type=get_enum_type(['Accepted', 'Creating', 'Updating', 'Deleting', '' + 'Succeeded', 'Failed', 'Canceled', 'Deleted', '' + 'NotSpecified']), help='') + c.argument('monitoring_status', arg_type=get_enum_type(['Enabled', 'Disabled']), help='Flag specifying if the ' + 'resource monitoring is enabled or disabled.') + c.argument('marketplace_subscription_status', arg_type=get_enum_type(['Active', 'Suspended']), help='Flag ' + 'specifying the Marketplace Subscription Status of the resource. If payment is not made in time, ' + 'the resource will go in Suspended state.') + c.argument('datadog_organization_properties', action=AddDatadogOrganizationProperties, nargs='*', help='') + c.argument('user_info', action=AddUserInfo, nargs='*', help='') + c.argument('sku_name', type=str, help='Name of the SKU.') + + with self.argument_context('datadog monitor update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', options_list=['--name', '-n', '--monitor-name'], type=str, help='Monitor resource ' + 'name', id_part='name') + c.argument('tags', tags_type) + c.argument('monitoring_status', arg_type=get_enum_type(['Enabled', 'Disabled']), help='Flag specifying if the ' + 'resource monitoring is enabled or disabled.') + + with self.argument_context('datadog monitor delete') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', options_list=['--name', '-n', '--monitor-name'], type=str, help='Monitor resource ' + 'name', id_part='name') + + with self.argument_context('datadog monitor wait') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', options_list=['--name', '-n', '--monitor-name'], type=str, help='Monitor resource ' + 'name', id_part='name') + + with self.argument_context('datadog refresh-set-password get') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name', id_part='name') + + with self.argument_context('datadog tag-rule list') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name') + + with self.argument_context('datadog tag-rule show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name', id_part='name') + c.argument('rule_set_name', type=str, help='', id_part='child_name_1') + + with self.argument_context('datadog tag-rule create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name') + c.argument('rule_set_name', type=str, help='') + c.argument('metric_rules_filtering_tags', action=AddMetricRulesFilteringTags, nargs='*', help='List of ' + 'filtering tags to be used for capturing metrics. If empty, all resources will be captured. If only ' + 'Exclude action is specified, the rules will apply to the list of all available resources. If ' + 'Include actions are specified, the rules will only include resources with the associated tags.') + c.argument('log_rules_send_aad_logs', arg_type=get_three_state_flag(), help='Flag specifying if AAD logs ' + 'should be sent for the Monitor resource.') + c.argument('log_rules_send_subscription_logs', arg_type=get_three_state_flag(), help='Flag specifying if Azure ' + 'subscription logs should be sent for the Monitor resource.') + c.argument('log_rules_send_resource_logs', arg_type=get_three_state_flag(), help='Flag specifying if Azure ' + 'resource logs should be sent for the Monitor resource.') + c.argument('log_rules_filtering_tags', action=AddLogRulesFilteringTags, nargs='*', help='List of filtering ' + 'tags to be used for capturing logs. This only takes effect if SendResourceLogs flag is enabled. If ' + 'empty, all resources will be captured. If only Exclude action is specified, the rules will apply ' + 'to the list of all available resources. If Include actions are specified, the rules will only ' + 'include resources with the associated tags.') + + with self.argument_context('datadog tag-rule update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name', id_part='name') + c.argument('rule_set_name', type=str, help='', id_part='child_name_1') + c.argument('metric_rules_filtering_tags', action=AddMetricRulesFilteringTags, nargs='*', help='List of ' + 'filtering tags to be used for capturing metrics. If empty, all resources will be captured. If only ' + 'Exclude action is specified, the rules will apply to the list of all available resources. If ' + 'Include actions are specified, the rules will only include resources with the associated tags.') + c.argument('log_rules_send_aad_logs', arg_type=get_three_state_flag(), help='Flag specifying if AAD logs ' + 'should be sent for the Monitor resource.') + c.argument('log_rules_send_subscription_logs', arg_type=get_three_state_flag(), help='Flag specifying if Azure ' + 'subscription logs should be sent for the Monitor resource.') + c.argument('log_rules_send_resource_logs', arg_type=get_three_state_flag(), help='Flag specifying if Azure ' + 'resource logs should be sent for the Monitor resource.') + c.argument('log_rules_filtering_tags', action=AddLogRulesFilteringTags, nargs='*', help='List of filtering ' + 'tags to be used for capturing logs. This only takes effect if SendResourceLogs flag is enabled. If ' + 'empty, all resources will be captured. If only Exclude action is specified, the rules will apply ' + 'to the list of all available resources. If Include actions are specified, the rules will only ' + 'include resources with the associated tags.') + + with self.argument_context('datadog single-sign-on-configuration list') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name') + + with self.argument_context('datadog single-sign-on-configuration show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name', id_part='name') + c.argument('configuration_name', type=str, help='', id_part='child_name_1') + + with self.argument_context('datadog single-sign-on-configuration create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name') + c.argument('configuration_name', type=str, help='') + c.argument('properties', action=AddProperties, nargs='*', help='') + + with self.argument_context('datadog single-sign-on-configuration update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name', id_part='name') + c.argument('configuration_name', type=str, help='', id_part='child_name_1') + c.argument('properties', action=AddProperties, nargs='*', help='') + + with self.argument_context('datadog single-sign-on-configuration wait') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('monitor_name', type=str, help='Monitor resource name', id_part='name') + c.argument('configuration_name', type=str, help='', id_part='child_name_1') diff --git a/src/datadog/azext_datadog/generated/_validators.py b/src/datadog/azext_datadog/generated/_validators.py new file mode 100644 index 00000000000..b33a44c1ebf --- /dev/null +++ b/src/datadog/azext_datadog/generated/_validators.py @@ -0,0 +1,9 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- diff --git a/src/datadog/azext_datadog/generated/action.py b/src/datadog/azext_datadog/generated/action.py new file mode 100644 index 00000000000..27649270eec --- /dev/null +++ b/src/datadog/azext_datadog/generated/action.py @@ -0,0 +1,144 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access + +import argparse +from collections import defaultdict +from knack.util import CLIError + + +class AddDatadogOrganizationProperties(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.datadog_organization_properties = action + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'linking-auth-code': + d['linking_auth_code'] = v[0] + elif kl == 'linking-client-id': + d['linking_client_id'] = v[0] + elif kl == 'enterprise-app-id': + d['enterprise_app_id'] = v[0] + return d + + +class AddUserInfo(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.user_info = action + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'name': + d['name'] = v[0] + elif kl == 'email-address': + d['email_address'] = v[0] + elif kl == 'phone-number': + d['phone_number'] = v[0] + return d + + +class AddMetricRulesFilteringTags(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + super(AddMetricRulesFilteringTags, self).__call__(parser, namespace, action, option_string) + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'name': + d['name'] = v[0] + elif kl == 'value': + d['value'] = v[0] + elif kl == 'action': + d['action'] = v[0] + return d + + +class AddLogRulesFilteringTags(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + super(AddLogRulesFilteringTags, self).__call__(parser, namespace, action, option_string) + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'name': + d['name'] = v[0] + elif kl == 'value': + d['value'] = v[0] + elif kl == 'action': + d['action'] = v[0] + return d + + +class AddProperties(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.properties = action + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'single-sign-on-state': + d['single_sign_on_state'] = v[0] + elif kl == 'enterprise-app-id': + d['enterprise_app_id'] = v[0] + elif kl == 'single-sign-on-url': + d['single_sign_on_url'] = v[0] + return d diff --git a/src/datadog/azext_datadog/generated/commands.py b/src/datadog/azext_datadog/generated/commands.py new file mode 100644 index 00000000000..93f36271259 --- /dev/null +++ b/src/datadog/azext_datadog/generated/commands.py @@ -0,0 +1,97 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-statements +# pylint: disable=too-many-locals + +from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): + + from azext_datadog.generated._client_factory import cf_api_key + datadog_api_key = CliCommandType( + operations_tmpl='azext_datadog.vendored_sdks.datadog.operations._api_key_operations#ApiKeyOperations.{}', + client_factory=cf_api_key) + with self.command_group('datadog api-key', datadog_api_key, client_factory=cf_api_key, is_experimental=True) as g: + g.custom_command('list', 'datadog_api_key_list') + g.custom_command('get-default-key', 'datadog_api_key_get_default_key') + g.custom_command('set-default-key', 'datadog_api_key_set_default_key') + + from azext_datadog.generated._client_factory import cf_host + datadog_host = CliCommandType( + operations_tmpl='azext_datadog.vendored_sdks.datadog.operations._host_operations#HostOperations.{}', + client_factory=cf_host) + with self.command_group('datadog host', datadog_host, client_factory=cf_host, is_experimental=True) as g: + g.custom_command('list', 'datadog_host_list') + + from azext_datadog.generated._client_factory import cf_linked_resource + datadog_linked_resource = CliCommandType( + operations_tmpl='azext_datadog.vendored_sdks.datadog.operations._linked_resource_operations#LinkedResourceOpera' + 'tions.{}', + client_factory=cf_linked_resource) + with self.command_group('datadog linked-resource', datadog_linked_resource, client_factory=cf_linked_resource, + is_experimental=True) as g: + g.custom_command('list', 'datadog_linked_resource_list') + + from azext_datadog.generated._client_factory import cf_monitored_resource + datadog_monitored_resource = CliCommandType( + operations_tmpl='azext_datadog.vendored_sdks.datadog.operations._monitored_resource_operations#MonitoredResourc' + 'eOperations.{}', + client_factory=cf_monitored_resource) + with self.command_group('datadog monitored-resource', datadog_monitored_resource, + client_factory=cf_monitored_resource, is_experimental=True) as g: + g.custom_command('list', 'datadog_monitored_resource_list') + + from azext_datadog.generated._client_factory import cf_monitor + datadog_monitor = CliCommandType( + operations_tmpl='azext_datadog.vendored_sdks.datadog.operations._monitor_operations#MonitorOperations.{}', + client_factory=cf_monitor) + with self.command_group('datadog monitor', datadog_monitor, client_factory=cf_monitor, is_experimental=True) as g: + g.custom_command('list', 'datadog_monitor_list') + g.custom_show_command('show', 'datadog_monitor_show') + g.custom_command('create', 'datadog_monitor_create', supports_no_wait=True) + g.custom_command('update', 'datadog_monitor_update') + g.custom_command('delete', 'datadog_monitor_delete', supports_no_wait=True, confirmation=True) + g.custom_wait_command('wait', 'datadog_monitor_show') + + from azext_datadog.generated._client_factory import cf_refresh_set_password + datadog_refresh_set_password = CliCommandType( + operations_tmpl='azext_datadog.vendored_sdks.datadog.operations._refresh_set_password_operations#RefreshSetPass' + 'wordOperations.{}', + client_factory=cf_refresh_set_password) + with self.command_group('datadog refresh-set-password', datadog_refresh_set_password, + client_factory=cf_refresh_set_password, is_experimental=True) as g: + g.custom_command('get', 'datadog_refresh_set_password_get') + + from azext_datadog.generated._client_factory import cf_tag_rule + datadog_tag_rule = CliCommandType( + operations_tmpl='azext_datadog.vendored_sdks.datadog.operations._tag_rule_operations#TagRuleOperations.{}', + client_factory=cf_tag_rule) + with self.command_group('datadog tag-rule', datadog_tag_rule, client_factory=cf_tag_rule, + is_experimental=True) as g: + g.custom_command('list', 'datadog_tag_rule_list') + g.custom_show_command('show', 'datadog_tag_rule_show') + g.custom_command('create', 'datadog_tag_rule_create') + g.custom_command('update', 'datadog_tag_rule_update') + + from azext_datadog.generated._client_factory import cf_single_sign_on_configuration + datadog_single_sign_on_configuration = CliCommandType( + operations_tmpl='azext_datadog.vendored_sdks.datadog.operations._single_sign_on_configuration_operations#Single' + 'SignOnConfigurationOperations.{}', + client_factory=cf_single_sign_on_configuration) + with self.command_group('datadog single-sign-on-configuration', datadog_single_sign_on_configuration, + client_factory=cf_single_sign_on_configuration, is_experimental=True) as g: + g.custom_command('list', 'datadog_single_sign_on_configuration_list') + g.custom_show_command('show', 'datadog_single_sign_on_configuration_show') + g.custom_command('create', 'datadog_single_sign_on_configuration_create', supports_no_wait=True) + g.generic_update_command('update', setter_arg_name='properties', setter_name='begin_create_or_update', + custom_func_name='datadog_single_sign_on_configuration_update', + supports_no_wait=True) + g.custom_wait_command('wait', 'datadog_single_sign_on_configuration_show') diff --git a/src/datadog/azext_datadog/generated/custom.py b/src/datadog/azext_datadog/generated/custom.py new file mode 100644 index 00000000000..8ff6b15be07 --- /dev/null +++ b/src/datadog/azext_datadog/generated/custom.py @@ -0,0 +1,225 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines +# pylint: disable=unused-argument + +from azure.cli.core.util import sdk_no_wait + + +def datadog_api_key_list(client, + resource_group_name, + monitor_name): + return client.list(resource_group_name=resource_group_name, + monitor_name=monitor_name) + + +def datadog_api_key_get_default_key(client, + resource_group_name, + monitor_name): + return client.get_default_key(resource_group_name=resource_group_name, + monitor_name=monitor_name) + + +def datadog_api_key_set_default_key(client, + resource_group_name, + monitor_name, + key, + created_by=None, + name=None, + created=None): + return client.set_default_key(resource_group_name=resource_group_name, + monitor_name=monitor_name, + created_by=created_by, + name=name, + key=key, + created=created) + + +def datadog_host_list(client, + resource_group_name, + monitor_name): + return client.list(resource_group_name=resource_group_name, + monitor_name=monitor_name) + + +def datadog_linked_resource_list(client, + resource_group_name, + monitor_name): + return client.list(resource_group_name=resource_group_name, + monitor_name=monitor_name) + + +def datadog_monitored_resource_list(client, + resource_group_name, + monitor_name): + return client.list(resource_group_name=resource_group_name, + monitor_name=monitor_name) + + +def datadog_monitor_list(client, + resource_group_name=None): + if resource_group_name: + return client.list_by_resource_group(resource_group_name=resource_group_name) + return client.list() + + +def datadog_monitor_show(client, + resource_group_name, + monitor_name): + return client.get(resource_group_name=resource_group_name, + monitor_name=monitor_name) + + +def datadog_monitor_create(client, + resource_group_name, + monitor_name, + location, + tags=None, + identity_type=None, + provisioning_state=None, + monitoring_status=None, + marketplace_subscription_status=None, + datadog_organization_properties=None, + user_info=None, + sku_name=None, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_create, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + tags=tags, + location=location, + type=identity_type, + provisioning_state=provisioning_state, + monitoring_status=monitoring_status, + marketplace_subscription_status=marketplace_subscription_status, + datadog_organization_properties=datadog_organization_properties, + user_info=user_info, + name=sku_name) + + +def datadog_monitor_update(client, + resource_group_name, + monitor_name, + tags=None, + monitoring_status=None): + return client.update(resource_group_name=resource_group_name, + monitor_name=monitor_name, + tags=tags, + monitoring_status=monitoring_status) + + +def datadog_monitor_delete(client, + resource_group_name, + monitor_name, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_delete, + resource_group_name=resource_group_name, + monitor_name=monitor_name) + + +def datadog_refresh_set_password_get(client, + resource_group_name, + monitor_name): + return client.get(resource_group_name=resource_group_name, + monitor_name=monitor_name) + + +def datadog_tag_rule_list(client, + resource_group_name, + monitor_name): + return client.list(resource_group_name=resource_group_name, + monitor_name=monitor_name) + + +def datadog_tag_rule_show(client, + resource_group_name, + monitor_name, + rule_set_name): + return client.get(resource_group_name=resource_group_name, + monitor_name=monitor_name, + rule_set_name=rule_set_name) + + +def datadog_tag_rule_create(client, + resource_group_name, + monitor_name, + rule_set_name, + metric_rules_filtering_tags=None, + log_rules_send_aad_logs=None, + log_rules_send_subscription_logs=None, + log_rules_send_resource_logs=None, + log_rules_filtering_tags=None): + return client.create_or_update(resource_group_name=resource_group_name, + monitor_name=monitor_name, + rule_set_name=rule_set_name, + filtering_tags=metric_rules_filtering_tags, + send_aad_logs=log_rules_send_aad_logs, + send_subscription_logs=log_rules_send_subscription_logs, + send_resource_logs=log_rules_send_resource_logs, + log_rules_filtering_tags=log_rules_filtering_tags) + + +def datadog_tag_rule_update(client, + resource_group_name, + monitor_name, + rule_set_name, + metric_rules_filtering_tags=None, + log_rules_send_aad_logs=None, + log_rules_send_subscription_logs=None, + log_rules_send_resource_logs=None, + log_rules_filtering_tags=None): + return client.create_or_update(resource_group_name=resource_group_name, + monitor_name=monitor_name, + rule_set_name=rule_set_name, + filtering_tags=metric_rules_filtering_tags, + send_aad_logs=log_rules_send_aad_logs, + send_subscription_logs=log_rules_send_subscription_logs, + send_resource_logs=log_rules_send_resource_logs, + log_rules_filtering_tags=log_rules_filtering_tags) + + +def datadog_single_sign_on_configuration_list(client, + resource_group_name, + monitor_name): + return client.list(resource_group_name=resource_group_name, + monitor_name=monitor_name) + + +def datadog_single_sign_on_configuration_show(client, + resource_group_name, + monitor_name, + configuration_name): + return client.get(resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name) + + +def datadog_single_sign_on_configuration_create(client, + resource_group_name, + monitor_name, + configuration_name, + properties=None, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_create_or_update, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + properties=properties) + + +def datadog_single_sign_on_configuration_update(instance, + resource_group_name, + monitor_name, + configuration_name, + no_wait=False): + return instance diff --git a/src/datadog/azext_datadog/manual/__init__.py b/src/datadog/azext_datadog/manual/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/datadog/azext_datadog/manual/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/datadog/azext_datadog/tests/__init__.py b/src/datadog/azext_datadog/tests/__init__.py new file mode 100644 index 00000000000..50e0627daff --- /dev/null +++ b/src/datadog/azext_datadog/tests/__init__.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +import inspect +import logging +import os +import sys +import traceback +import datetime as dt + +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError + + +logger = logging.getLogger('azure.cli.testsdk') +logger.addHandler(logging.StreamHandler()) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) +exceptions = [] +test_map = dict() +SUCCESSED = "successed" +FAILED = "failed" + + +def try_manual(func): + def import_manual_function(origin_func): + from importlib import import_module + decorated_path = inspect.getfile(origin_func) + module_path = __path__[0] + if not decorated_path.startswith(module_path): + raise Exception("Decorator can only be used in submodules!") + manual_path = os.path.join( + decorated_path[module_path.rfind(os.path.sep) + 1:]) + manual_file_path, manual_file_name = os.path.split(manual_path) + module_name, _ = os.path.splitext(manual_file_name) + manual_module = "..manual." + \ + ".".join(manual_file_path.split(os.path.sep) + [module_name, ]) + return getattr(import_module(manual_module, package=__name__), origin_func.__name__) + + def get_func_to_call(): + func_to_call = func + try: + func_to_call = import_manual_function(func) + func_to_call = import_manual_function(func) + logger.info("Found manual override for %s(...)", func.__name__) + except (ImportError, AttributeError): + pass + return func_to_call + + def wrapper(*args, **kwargs): + func_to_call = get_func_to_call() + logger.info("running %s()...", func.__name__) + try: + test_map[func.__name__] = dict() + test_map[func.__name__]["result"] = SUCCESSED + test_map[func.__name__]["error_message"] = "" + test_map[func.__name__]["error_stack"] = "" + test_map[func.__name__]["error_normalized"] = "" + test_map[func.__name__]["start_dt"] = dt.datetime.utcnow() + ret = func_to_call(*args, **kwargs) + except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, + JMESPathCheckAssertionError) as e: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + test_map[func.__name__]["result"] = FAILED + test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500] + test_map[func.__name__]["error_stack"] = traceback.format_exc().replace( + "\r\n", " ").replace("\n", " ")[:500] + logger.info("--------------------------------------") + logger.info("step exception: %s", e) + logger.error("--------------------------------------") + logger.error("step exception in %s: %s", func.__name__, e) + logger.info(traceback.format_exc()) + exceptions.append((func.__name__, sys.exc_info())) + else: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + return ret + + if inspect.isclass(func): + return get_func_to_call() + return wrapper + + +def calc_coverage(filename): + filename = filename.split(".")[0] + coverage_name = filename + "_coverage.md" + with open(coverage_name, "w") as f: + f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\n") + total = len(test_map) + covered = 0 + for k, v in test_map.items(): + if not k.startswith("step_"): + total -= 1 + continue + if v["result"] == SUCCESSED: + covered += 1 + f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|" + "{end_dt}|\n".format(step_name=k, **v)) + f.write("Coverage: {}/{}\n".format(covered, total)) + print("Create coverage\n", file=sys.stderr) + + +def raise_if(): + if exceptions: + if len(exceptions) <= 1: + raise exceptions[0][1][1] + message = "{}\nFollowed with exceptions in other steps:\n".format(str(exceptions[0][1][1])) + message += "\n".join(["{}: {}".format(h[0], h[1][1]) for h in exceptions[1:]]) + raise exceptions[0][1][0](message).with_traceback(exceptions[0][1][2]) diff --git a/src/datadog/azext_datadog/tests/latest/__init__.py b/src/datadog/azext_datadog/tests/latest/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/datadog/azext_datadog/tests/latest/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/datadog/azext_datadog/tests/latest/test_datadog_scenario.py b/src/datadog/azext_datadog/tests/latest/test_datadog_scenario.py new file mode 100644 index 00000000000..ac22a35637a --- /dev/null +++ b/src/datadog/azext_datadog/tests/latest/test_datadog_scenario.py @@ -0,0 +1,283 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import os +from azure.cli.testsdk import ScenarioTest +from .. import try_manual, raise_if, calc_coverage +from azure.cli.testsdk import ResourceGroupPreparer + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +@try_manual +def setup(test, rg): + pass + + +# EXAMPLE: /Monitors/put/Monitors_Create +@try_manual +def step__monitors_put_monitors_create(test, rg): + test.cmd('az datadog monitor create ' + '--name "{myMonitor}" ' + '--sku-name "{myMonitor}" ' + '--location "West US" ' + '--datadog-organization-properties name="myOrg" enterprise-app-id="00000000-0000-0000-0000-000000000000" ' + 'linking-auth-code="someAuthCode" linking-client-id="00000000-0000-0000-0000-000000000000" ' + 'subscription="pro" ' + '--monitoring-status "Enabled" ' + '--user-info name="Alice" email-address="alice@microsoft.com" phone-number="123-456-7890" ' + '--sku-name "free_Monthly" ' + '--tags Environment="Dev" ' + '--resource-group "{rg}"', + checks=[ + test.check("name", "{myMonitor}", case_sensitive=False), + test.check("sku.name", "free_Monthly", case_sensitive=False), + test.check("location", "West US", case_sensitive=False), + test.check("monitoringStatus", "Enabled", case_sensitive=False), + test.check("tags.Environment", "Dev", case_sensitive=False), + ]) + test.cmd('az datadog monitor wait --created ' + '--name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Monitors/get/Monitors_Get +@try_manual +def step__monitors_get_monitors_get(test, rg): + test.cmd('az datadog monitor show ' + '--name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=[ + test.check("name", "{myMonitor}", case_sensitive=False), + test.check("location", "West US", case_sensitive=False), + test.check("monitoringStatus", "Enabled", case_sensitive=False), + test.check("tags.Environment", "Dev", case_sensitive=False), + ]) + + +# EXAMPLE: /Monitors/get/Monitors_List +@try_manual +def step__monitors_get_monitors_list(test, rg): + test.cmd('az datadog monitor list ' + '-g ""', + checks=[ + test.check('length(@)', 1), + ]) + + +# EXAMPLE: /Monitors/get/Monitors_ListByResourceGroup +@try_manual +def step__monitors_get_monitors_listbyresourcegroup(test, rg): + test.cmd('az datadog monitor list ' + '--resource-group "{rg}"', + checks=[ + test.check('length(@)', 1), + ]) + + +# EXAMPLE: /Monitors/patch/Monitors_Update +@try_manual +def step__monitors_patch_monitors_update(test, rg): + test.cmd('az datadog monitor update ' + '--name "{myMonitor}" ' + '--monitoring-status "Enabled" ' + '--tags Environment="Dev" ' + '--resource-group "{rg}"', + checks=[ + test.check("name", "{myMonitor}", case_sensitive=False), + test.check("sku.name", "free_Monthly", case_sensitive=False), + test.check("location", "West US", case_sensitive=False), + test.check("monitoringStatus", "Enabled", case_sensitive=False), + test.check("tags.Environment", "Dev", case_sensitive=False), + ]) + + +# EXAMPLE: /ApiKeys/post/ApiKeys_GetDefaultKey +@try_manual +def step__apikeys_post_apikeys_getdefaultkey(test, rg): + test.cmd('az datadog api-key get-default-key ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /ApiKeys/post/ApiKeys_List +@try_manual +def step__apikeys_post_apikeys_list(test, rg): + test.cmd('az datadog api-key list ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /ApiKeys/post/ApiKeys_SetDefaultKey +@try_manual +def step__apikeys_post_apikeys_setdefaultkey(test, rg): + test.cmd('az datadog api-key set-default-key ' + '--monitor-name "{myMonitor}" ' + '--key "1111111111111111aaaaaaaaaaaaaaaa" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Hosts/post/Hosts_List +@try_manual +def step__hosts_post_hosts_list(test, rg): + test.cmd('az datadog host list ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /LinkedResources/post/LinkedResources_List +@try_manual +def step__linkedresources_post_linkedresources_list(test, rg): + test.cmd('az datadog linked-resource list ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /MonitoredResources/post/MonitoredResources_List +@try_manual +def step__monitoredresources_post(test, rg): + test.cmd('az datadog monitored-resource list ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /RefreshSetPassword/post/RefreshSetPassword_Get +@try_manual +def step__refreshsetpassword_post(test, rg): + test.cmd('az datadog refresh-set-password get ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /SingleSignOnConfigurations/put/SingleSignOnConfigurations_CreateOrUpdate +@try_manual +def step__singlesignonconfigurations_put(test, rg): + test.cmd('az datadog single-sign-on-configuration create ' + '--configuration-name "default" ' + '--monitor-name "{myMonitor}" ' + '--properties enterprise-app-id="00000000-0000-0000-0000-000000000000" single-sign-on-state="Enable" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /SingleSignOnConfigurations/get/SingleSignOnConfigurations_Get +@try_manual +def step__singlesignonconfigurations_get(test, rg): + test.cmd('az datadog single-sign-on-configuration show ' + '--configuration-name "default" ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /SingleSignOnConfigurations/get/SingleSignOnConfigurations_List +@try_manual +def step__singlesignonconfigurations_get2(test, rg): + test.cmd('az datadog single-sign-on-configuration list ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /TagRules/put/TagRules_CreateOrUpdate +@try_manual +def step__tagrules_put_tagrules_createorupdate(test, rg): + test.cmd('az datadog tag-rule create ' + '--monitor-name "{myMonitor}" ' + '--log-rules-filtering-tags name="Environment" action="Include" value="Prod" ' + '--log-rules-filtering-tags name="Environment" action="Exclude" value="Dev" ' + '--log-rules-send-aad-logs false ' + '--log-rules-send-resource-logs true ' + '--log-rules-send-subscription-logs true ' + '--resource-group "{rg}" ' + '--rule-set-name "default"', + checks=[]) + + +# EXAMPLE: /TagRules/get/TagRules_Get +@try_manual +def step__tagrules_get_tagrules_get(test, rg): + test.cmd('az datadog tag-rule show ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}" ' + '--rule-set-name "default"', + checks=[]) + + +# EXAMPLE: /TagRules/get/TagRules_List +@try_manual +def step__tagrules_get_tagrules_list(test, rg): + test.cmd('az datadog tag-rule list ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Monitors/delete/Monitors_Delete +@try_manual +def step__monitors_delete_monitors_delete(test, rg): + test.cmd('az datadog monitor delete -y ' + '--name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=[]) + + +@try_manual +def cleanup(test, rg): + pass + + +@try_manual +def call_scenario(test, rg): + setup(test, rg) + step__monitors_put_monitors_create(test, rg) + step__monitors_get_monitors_get(test, rg) + step__monitors_get_monitors_list(test, rg) + step__monitors_get_monitors_listbyresourcegroup(test, rg) + step__monitors_patch_monitors_update(test, rg) + step__apikeys_post_apikeys_getdefaultkey(test, rg) + step__apikeys_post_apikeys_list(test, rg) + step__apikeys_post_apikeys_setdefaultkey(test, rg) + step__hosts_post_hosts_list(test, rg) + step__linkedresources_post_linkedresources_list(test, rg) + step__monitoredresources_post(test, rg) + step__refreshsetpassword_post(test, rg) + step__singlesignonconfigurations_put(test, rg) + step__singlesignonconfigurations_get(test, rg) + step__singlesignonconfigurations_get2(test, rg) + step__tagrules_put_tagrules_createorupdate(test, rg) + step__tagrules_get_tagrules_get(test, rg) + step__tagrules_get_tagrules_list(test, rg) + step__monitors_delete_monitors_delete(test, rg) + cleanup(test, rg) + + +@try_manual +class MicrosoftDatadogClientScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='clitestdatadog_myResourceGroup'[:7], key='rg', parameter_name='rg') + def test_datadog(self, rg): + + self.kwargs.update({ + 'myMonitor': 'myMonitor', + }) + + call_scenario(self, rg) + calc_coverage(__file__) + raise_if() diff --git a/src/datadog/azext_datadog/vendored_sdks/__init__.py b/src/datadog/azext_datadog/vendored_sdks/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/__init__.py b/src/datadog/azext_datadog/vendored_sdks/datadog/__init__.py new file mode 100644 index 00000000000..4169586605e --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._microsoft_datadog_client import MicrosoftDatadogClient +__all__ = ['MicrosoftDatadogClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/_configuration.py b/src/datadog/azext_datadog/vendored_sdks/datadog/_configuration.py new file mode 100644 index 00000000000..456fc5ca871 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/_configuration.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class MicrosoftDatadogClientConfiguration(Configuration): + """Configuration for MicrosoftDatadogClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The Microsoft Azure subscription ID. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(MicrosoftDatadogClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-02-01-preview" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'microsoftdatadogclient/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/_microsoft_datadog_client.py b/src/datadog/azext_datadog/vendored_sdks/datadog/_microsoft_datadog_client.py new file mode 100644 index 00000000000..318539a3f04 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/_microsoft_datadog_client.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + +from ._configuration import MicrosoftDatadogClientConfiguration +from .operations import ApiKeyOperations +from .operations import HostOperations +from .operations import LinkedResourceOperations +from .operations import MonitoredResourceOperations +from .operations import OperationOperations +from .operations import MonitorOperations +from .operations import RefreshSetPasswordOperations +from .operations import TagRuleOperations +from .operations import SingleSignOnConfigurationOperations +from . import models + + +class MicrosoftDatadogClient(object): + """MicrosoftDatadogClient. + + :ivar api_key: ApiKeyOperations operations + :vartype api_key: microsoft_datadog_client.operations.ApiKeyOperations + :ivar host: HostOperations operations + :vartype host: microsoft_datadog_client.operations.HostOperations + :ivar linked_resource: LinkedResourceOperations operations + :vartype linked_resource: microsoft_datadog_client.operations.LinkedResourceOperations + :ivar monitored_resource: MonitoredResourceOperations operations + :vartype monitored_resource: microsoft_datadog_client.operations.MonitoredResourceOperations + :ivar operation: OperationOperations operations + :vartype operation: microsoft_datadog_client.operations.OperationOperations + :ivar monitor: MonitorOperations operations + :vartype monitor: microsoft_datadog_client.operations.MonitorOperations + :ivar refresh_set_password: RefreshSetPasswordOperations operations + :vartype refresh_set_password: microsoft_datadog_client.operations.RefreshSetPasswordOperations + :ivar tag_rule: TagRuleOperations operations + :vartype tag_rule: microsoft_datadog_client.operations.TagRuleOperations + :ivar single_sign_on_configuration: SingleSignOnConfigurationOperations operations + :vartype single_sign_on_configuration: microsoft_datadog_client.operations.SingleSignOnConfigurationOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The Microsoft Azure subscription ID. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = MicrosoftDatadogClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.api_key = ApiKeyOperations( + self._client, self._config, self._serialize, self._deserialize) + self.host = HostOperations( + self._client, self._config, self._serialize, self._deserialize) + self.linked_resource = LinkedResourceOperations( + self._client, self._config, self._serialize, self._deserialize) + self.monitored_resource = MonitoredResourceOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.monitor = MonitorOperations( + self._client, self._config, self._serialize, self._deserialize) + self.refresh_set_password = RefreshSetPasswordOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tag_rule = TagRuleOperations( + self._client, self._config, self._serialize, self._deserialize) + self.single_sign_on_configuration = SingleSignOnConfigurationOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> MicrosoftDatadogClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/__init__.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/__init__.py new file mode 100644 index 00000000000..3b629c26f27 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._microsoft_datadog_client_async import MicrosoftDatadogClient +__all__ = ['MicrosoftDatadogClient'] diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/_configuration_async.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/_configuration_async.py new file mode 100644 index 00000000000..e2d16a4bf3e --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/_configuration_async.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class MicrosoftDatadogClientConfiguration(Configuration): + """Configuration for MicrosoftDatadogClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The Microsoft Azure subscription ID. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(MicrosoftDatadogClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-02-01-preview" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'microsoftdatadogclient/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/_microsoft_datadog_client_async.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/_microsoft_datadog_client_async.py new file mode 100644 index 00000000000..7b6366c0e29 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/_microsoft_datadog_client_async.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration_async import MicrosoftDatadogClientConfiguration +from .operations_async import ApiKeyOperations +from .operations_async import HostOperations +from .operations_async import LinkedResourceOperations +from .operations_async import MonitoredResourceOperations +from .operations_async import OperationOperations +from .operations_async import MonitorOperations +from .operations_async import RefreshSetPasswordOperations +from .operations_async import TagRuleOperations +from .operations_async import SingleSignOnConfigurationOperations +from .. import models + + +class MicrosoftDatadogClient(object): + """MicrosoftDatadogClient. + + :ivar api_key: ApiKeyOperations operations + :vartype api_key: microsoft_datadog_client.aio.operations_async.ApiKeyOperations + :ivar host: HostOperations operations + :vartype host: microsoft_datadog_client.aio.operations_async.HostOperations + :ivar linked_resource: LinkedResourceOperations operations + :vartype linked_resource: microsoft_datadog_client.aio.operations_async.LinkedResourceOperations + :ivar monitored_resource: MonitoredResourceOperations operations + :vartype monitored_resource: microsoft_datadog_client.aio.operations_async.MonitoredResourceOperations + :ivar operation: OperationOperations operations + :vartype operation: microsoft_datadog_client.aio.operations_async.OperationOperations + :ivar monitor: MonitorOperations operations + :vartype monitor: microsoft_datadog_client.aio.operations_async.MonitorOperations + :ivar refresh_set_password: RefreshSetPasswordOperations operations + :vartype refresh_set_password: microsoft_datadog_client.aio.operations_async.RefreshSetPasswordOperations + :ivar tag_rule: TagRuleOperations operations + :vartype tag_rule: microsoft_datadog_client.aio.operations_async.TagRuleOperations + :ivar single_sign_on_configuration: SingleSignOnConfigurationOperations operations + :vartype single_sign_on_configuration: microsoft_datadog_client.aio.operations_async.SingleSignOnConfigurationOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The Microsoft Azure subscription ID. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = MicrosoftDatadogClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.api_key = ApiKeyOperations( + self._client, self._config, self._serialize, self._deserialize) + self.host = HostOperations( + self._client, self._config, self._serialize, self._deserialize) + self.linked_resource = LinkedResourceOperations( + self._client, self._config, self._serialize, self._deserialize) + self.monitored_resource = MonitoredResourceOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.monitor = MonitorOperations( + self._client, self._config, self._serialize, self._deserialize) + self.refresh_set_password = RefreshSetPasswordOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tag_rule = TagRuleOperations( + self._client, self._config, self._serialize, self._deserialize) + self.single_sign_on_configuration = SingleSignOnConfigurationOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "MicrosoftDatadogClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/__init__.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/__init__.py new file mode 100644 index 00000000000..c164696fbc8 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._api_key_operations_async import ApiKeyOperations +from ._host_operations_async import HostOperations +from ._linked_resource_operations_async import LinkedResourceOperations +from ._monitored_resource_operations_async import MonitoredResourceOperations +from ._operation_operations_async import OperationOperations +from ._monitor_operations_async import MonitorOperations +from ._refresh_set_password_operations_async import RefreshSetPasswordOperations +from ._tag_rule_operations_async import TagRuleOperations +from ._single_sign_on_configuration_operations_async import SingleSignOnConfigurationOperations + +__all__ = [ + 'ApiKeyOperations', + 'HostOperations', + 'LinkedResourceOperations', + 'MonitoredResourceOperations', + 'OperationOperations', + 'MonitorOperations', + 'RefreshSetPasswordOperations', + 'TagRuleOperations', + 'SingleSignOnConfigurationOperations', +] diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_api_key_operations_async.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_api_key_operations_async.py new file mode 100644 index 00000000000..ab42f19d5cd --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_api_key_operations_async.py @@ -0,0 +1,254 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApiKeyOperations: + """ApiKeyOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + monitor_name: str, + **kwargs + ) -> AsyncIterable["models.DatadogApiKeyListResponse"]: + """List the api keys for a given monitor resource. + + List the api keys for a given monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatadogApiKeyListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_datadog_client.models.DatadogApiKeyListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogApiKeyListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DatadogApiKeyListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/listApiKeys'} # type: ignore + + async def get_default_key( + self, + resource_group_name: str, + monitor_name: str, + **kwargs + ) -> "models.DatadogApiKey": + """Get the default api key. + + Get the default api key. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DatadogApiKey, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.DatadogApiKey + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogApiKey"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + # Construct URL + url = self.get_default_key.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DatadogApiKey', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_default_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/getDefaultKey'} # type: ignore + + async def set_default_key( + self, + resource_group_name: str, + monitor_name: str, + key: str, + created_by: Optional[str] = None, + name: Optional[str] = None, + created: Optional[str] = None, + **kwargs + ) -> None: + """Set the default api key. + + Set the default api key. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param key: The value of the API key. + :type key: str + :param created_by: The user that created the API key. + :type created_by: str + :param name: The name of the API key. + :type name: str + :param created: The time of creation of the API key. + :type created: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.DatadogApiKey(created_by=created_by, name=name, key=key, created=created) + api_version = "2020-02-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.set_default_key.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'DatadogApiKey') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + set_default_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/setDefaultKey'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_host_operations_async.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_host_operations_async.py new file mode 100644 index 00000000000..f219da6c04b --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_host_operations_async.py @@ -0,0 +1,117 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class HostOperations: + """HostOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + monitor_name: str, + **kwargs + ) -> AsyncIterable["models.DatadogHostListResponse"]: + """List the hosts for a given monitor resource. + + List the hosts for a given monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatadogHostListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_datadog_client.models.DatadogHostListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogHostListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DatadogHostListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/listHosts'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_linked_resource_operations_async.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_linked_resource_operations_async.py new file mode 100644 index 00000000000..dc1dd4956fa --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_linked_resource_operations_async.py @@ -0,0 +1,117 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class LinkedResourceOperations: + """LinkedResourceOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + monitor_name: str, + **kwargs + ) -> AsyncIterable["models.LinkedResourceListResponse"]: + """List all Azure resources associated to the same Datadog organization as the target resource. + + List all Azure resources associated to the same Datadog organization as the target resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LinkedResourceListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_datadog_client.models.LinkedResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LinkedResourceListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LinkedResourceListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/listLinkedResources'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_monitor_operations_async.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_monitor_operations_async.py new file mode 100644 index 00000000000..8b7176e59b4 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_monitor_operations_async.py @@ -0,0 +1,588 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class MonitorOperations: + """MonitorOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.DatadogMonitorResourceListResponse"]: + """List all monitors under the specified subscription. + + List all monitors under 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 DatadogMonitorResourceListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_datadog_client.models.DatadogMonitorResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResourceListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DatadogMonitorResourceListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Datadog/monitors'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["models.DatadogMonitorResourceListResponse"]: + """List all monitors under the specified resource group. + + List all monitors under the specified resource group. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatadogMonitorResourceListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_datadog_client.models.DatadogMonitorResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResourceListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DatadogMonitorResourceListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors'} # type: ignore + + async def get( + self, + resource_group_name: str, + monitor_name: str, + **kwargs + ) -> "models.DatadogMonitorResource": + """Get the properties of a specific monitor resource. + + Get the properties of a specific monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DatadogMonitorResource, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.DatadogMonitorResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + monitor_name: str, + location: str, + tags: Optional[Dict[str, str]] = None, + type: Optional[Union[str, "models.ManagedIdentityTypes"]] = None, + provisioning_state: Optional[Union[str, "models.ProvisioningState"]] = None, + monitoring_status: Optional[Union[str, "models.MonitoringStatus"]] = None, + marketplace_subscription_status: Optional[Union[str, "models.MarketplaceSubscriptionStatus"]] = None, + datadog_organization_properties: Optional["models.DatadogOrganizationProperties"] = None, + user_info: Optional["models.UserInfo"] = None, + name: Optional[str] = None, + **kwargs + ) -> "models.DatadogMonitorResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.DatadogMonitorResource(tags=tags, location=location, type_identity_type=type, provisioning_state=provisioning_state, monitoring_status=monitoring_status, marketplace_subscription_status=marketplace_subscription_status, datadog_organization_properties=datadog_organization_properties, user_info=user_info, name_sku_name=name) + api_version = "2020-02-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'DatadogMonitorResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + + async def begin_create( + self, + resource_group_name: str, + monitor_name: str, + location: str, + tags: Optional[Dict[str, str]] = None, + type: Optional[Union[str, "models.ManagedIdentityTypes"]] = None, + provisioning_state: Optional[Union[str, "models.ProvisioningState"]] = None, + monitoring_status: Optional[Union[str, "models.MonitoringStatus"]] = None, + marketplace_subscription_status: Optional[Union[str, "models.MarketplaceSubscriptionStatus"]] = None, + datadog_organization_properties: Optional["models.DatadogOrganizationProperties"] = None, + user_info: Optional["models.UserInfo"] = None, + name: Optional[str] = None, + **kwargs + ) -> AsyncLROPoller["models.DatadogMonitorResource"]: + """Create a monitor resource. + + Create a monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param location: + :type location: str + :param tags: Dictionary of :code:``. + :type tags: dict[str, str] + :param type: + :type type: str or ~microsoft_datadog_client.models.ManagedIdentityTypes + :param provisioning_state: + :type provisioning_state: str or ~microsoft_datadog_client.models.ProvisioningState + :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + :type monitoring_status: str or ~microsoft_datadog_client.models.MonitoringStatus + :param marketplace_subscription_status: Flag specifying the Marketplace Subscription Status of + the resource. If payment is not made in time, the resource will go in Suspended state. + :type marketplace_subscription_status: str or ~microsoft_datadog_client.models.MarketplaceSubscriptionStatus + :param datadog_organization_properties: + :type datadog_organization_properties: ~microsoft_datadog_client.models.DatadogOrganizationProperties + :param user_info: + :type user_info: ~microsoft_datadog_client.models.UserInfo + :param name: Name of the SKU. + :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. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DatadogMonitorResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_datadog_client.models.DatadogMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResource"] + 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_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + location=location, + tags=tags, + type=type, + provisioning_state=provisioning_state, + monitoring_status=monitoring_status, + marketplace_subscription_status=marketplace_subscription_status, + datadog_organization_properties=datadog_organization_properties, + user_info=user_info, + name=name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + monitor_name: str, + tags: Optional[Dict[str, str]] = None, + monitoring_status: Optional[Union[str, "models.MonitoringStatus"]] = None, + **kwargs + ) -> "models.DatadogMonitorResource": + """Update a monitor resource. + + Update a monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param tags: The new tags of the monitor resource. + :type tags: dict[str, str] + :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + :type monitoring_status: str or ~microsoft_datadog_client.models.MonitoringStatus + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DatadogMonitorResource, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.DatadogMonitorResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.DatadogMonitorResourceUpdateParameters(tags=tags, monitoring_status=monitoring_status) + api_version = "2020-02-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'DatadogMonitorResourceUpdateParameters') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + monitor_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + monitor_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Delete a monitor resource. + + Delete a monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_monitored_resource_operations_async.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_monitored_resource_operations_async.py new file mode 100644 index 00000000000..50b609ec8b3 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_monitored_resource_operations_async.py @@ -0,0 +1,117 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class MonitoredResourceOperations: + """MonitoredResourceOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + monitor_name: str, + **kwargs + ) -> AsyncIterable["models.MonitoredResourceListResponse"]: + """List the resources currently being monitored by the Datadog monitor resource. + + List the resources currently being monitored by the Datadog monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitoredResourceListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_datadog_client.models.MonitoredResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.MonitoredResourceListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('MonitoredResourceListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/listMonitoredResources'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_operation_operations_async.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_operation_operations_async.py new file mode 100644 index 00000000000..e49ef087be6 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_operation_operations_async.py @@ -0,0 +1,104 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations: + """OperationOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """List all operations provided by Microsoft.Datadog for the 2020-02-01-preview api version. + + List all operations provided by Microsoft.Datadog for the 2020-02-01-preview api version. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_datadog_client.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Datadog/operations'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_refresh_set_password_operations_async.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_refresh_set_password_operations_async.py new file mode 100644 index 00000000000..d57e456daab --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_refresh_set_password_operations_async.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RefreshSetPasswordOperations: + """RefreshSetPasswordOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + monitor_name: str, + **kwargs + ) -> "models.DatadogSetPasswordLink": + """Refresh the set password link and return a latest one. + + Refresh the set password link and return a latest one. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DatadogSetPasswordLink, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.DatadogSetPasswordLink + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogSetPasswordLink"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DatadogSetPasswordLink', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/refreshSetPasswordLink'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_single_sign_on_configuration_operations_async.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_single_sign_on_configuration_operations_async.py new file mode 100644 index 00000000000..049816a80b3 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_single_sign_on_configuration_operations_async.py @@ -0,0 +1,317 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SingleSignOnConfigurationOperations: + """SingleSignOnConfigurationOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + monitor_name: str, + **kwargs + ) -> AsyncIterable["models.DatadogSingleSignOnResourceListResponse"]: + """List the single sign-on configurations for a given monitor resource. + + List the single sign-on configurations for a given monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatadogSingleSignOnResourceListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_datadog_client.models.DatadogSingleSignOnResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogSingleSignOnResourceListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DatadogSingleSignOnResourceListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/singleSignOnConfigurations'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + properties: Optional["models.DatadogSingleSignOnProperties"] = None, + **kwargs + ) -> "models.DatadogSingleSignOnResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogSingleSignOnResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.DatadogSingleSignOnResource(properties=properties) + api_version = "2020-02-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'DatadogSingleSignOnResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DatadogSingleSignOnResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DatadogSingleSignOnResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + properties: Optional["models.DatadogSingleSignOnProperties"] = None, + **kwargs + ) -> AsyncLROPoller["models.DatadogSingleSignOnResource"]: + """Configures single-sign-on for this resource. + + Configures single-sign-on for this resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param configuration_name: + :type configuration_name: str + :param properties: + :type properties: ~microsoft_datadog_client.models.DatadogSingleSignOnProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DatadogSingleSignOnResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_datadog_client.models.DatadogSingleSignOnResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogSingleSignOnResource"] + 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( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DatadogSingleSignOnResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + monitor_name: str, + configuration_name: str, + **kwargs + ) -> "models.DatadogSingleSignOnResource": + """Gets the datadog single sign-on resource for the given Monitor. + + Gets the datadog single sign-on resource for the given Monitor. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param configuration_name: + :type configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DatadogSingleSignOnResource, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.DatadogSingleSignOnResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogSingleSignOnResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DatadogSingleSignOnResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_tag_rule_operations_async.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_tag_rule_operations_async.py new file mode 100644 index 00000000000..d6e840c774e --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations_async/_tag_rule_operations_async.py @@ -0,0 +1,278 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TagRuleOperations: + """TagRuleOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + monitor_name: str, + **kwargs + ) -> AsyncIterable["models.MonitoringTagRulesListResponse"]: + """List the tag rules for a given monitor resource. + + List the tag rules for a given monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_datadog_client.models.MonitoringTagRulesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.MonitoringTagRulesListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('MonitoringTagRulesListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/tagRules'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + monitor_name: str, + rule_set_name: str, + filtering_tags: Optional[List["models.FilteringTag"]] = None, + send_aad_logs: Optional[bool] = None, + send_subscription_logs: Optional[bool] = None, + send_resource_logs: Optional[bool] = None, + log_rules_filtering_tags: Optional[List["models.FilteringTag"]] = None, + **kwargs + ) -> "models.MonitoringTagRules": + """Create or update a tag rule set for a given monitor resource. + + Create or update a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param rule_set_name: + :type rule_set_name: str + :param filtering_tags: List of filtering tags to be used for capturing metrics. If empty, all + resources will be captured. If only Exclude action is specified, the rules will apply to the + list of all available resources. If Include actions are specified, the rules will only include + resources with the associated tags. + :type filtering_tags: list[~microsoft_datadog_client.models.FilteringTag] + :param send_aad_logs: Flag specifying if AAD logs should be sent for the Monitor resource. + :type send_aad_logs: bool + :param send_subscription_logs: Flag specifying if Azure subscription logs should be sent for + the Monitor resource. + :type send_subscription_logs: bool + :param send_resource_logs: Flag specifying if Azure resource logs should be sent for the + Monitor resource. + :type send_resource_logs: bool + :param log_rules_filtering_tags: List of filtering tags to be used for capturing logs. This + only takes effect if SendResourceLogs flag is enabled. If empty, all resources will be + captured. If only Exclude action is specified, the rules will apply to the list of all + available resources. If Include actions are specified, the rules will only include resources + with the associated tags. + :type log_rules_filtering_tags: list[~microsoft_datadog_client.models.FilteringTag] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringTagRules, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.MonitoringTagRules + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.MonitoringTagRules"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.MonitoringTagRules(filtering_tags_properties_metric_rules_filtering_tags=filtering_tags, send_aad_logs=send_aad_logs, send_subscription_logs=send_subscription_logs, send_resource_logs=send_resource_logs, filtering_tags_properties_log_rules_filtering_tags=log_rules_filtering_tags) + api_version = "2020-02-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'MonitoringTagRules') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MonitoringTagRules', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + monitor_name: str, + rule_set_name: str, + **kwargs + ) -> "models.MonitoringTagRules": + """Get a tag rule set for a given monitor resource. + + Get a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param rule_set_name: + :type rule_set_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringTagRules, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.MonitoringTagRules + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.MonitoringTagRules"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MonitoringTagRules', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/models/__init__.py b/src/datadog/azext_datadog/vendored_sdks/datadog/models/__init__.py new file mode 100644 index 00000000000..f703afa79c2 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/models/__init__.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import DatadogApiKey + from ._models_py3 import DatadogApiKeyListResponse + from ._models_py3 import DatadogHost + from ._models_py3 import DatadogHostListResponse + from ._models_py3 import DatadogHostMetadata + from ._models_py3 import DatadogInstallMethod + from ._models_py3 import DatadogLogsAgent + from ._models_py3 import DatadogMonitorResource + from ._models_py3 import DatadogMonitorResourceListResponse + from ._models_py3 import DatadogMonitorResourceUpdateParameters + from ._models_py3 import DatadogOrganizationProperties + from ._models_py3 import DatadogSetPasswordLink + from ._models_py3 import DatadogSingleSignOnProperties + from ._models_py3 import DatadogSingleSignOnResource + from ._models_py3 import DatadogSingleSignOnResourceListResponse + from ._models_py3 import ErrorResponseBody + from ._models_py3 import FilteringTag + from ._models_py3 import LinkedResource + from ._models_py3 import LinkedResourceListResponse + from ._models_py3 import MonitoredResource + from ._models_py3 import MonitoredResourceListResponse + from ._models_py3 import MonitoringTagRules + from ._models_py3 import MonitoringTagRulesListResponse + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult + from ._models_py3 import OperationResult + from ._models_py3 import ResourceProviderDefaultErrorResponse + from ._models_py3 import UserInfo +except (SyntaxError, ImportError): + from ._models import DatadogApiKey # type: ignore + from ._models import DatadogApiKeyListResponse # type: ignore + from ._models import DatadogHost # type: ignore + from ._models import DatadogHostListResponse # type: ignore + from ._models import DatadogHostMetadata # type: ignore + from ._models import DatadogInstallMethod # type: ignore + from ._models import DatadogLogsAgent # type: ignore + from ._models import DatadogMonitorResource # type: ignore + from ._models import DatadogMonitorResourceListResponse # type: ignore + from ._models import DatadogMonitorResourceUpdateParameters # type: ignore + from ._models import DatadogOrganizationProperties # type: ignore + from ._models import DatadogSetPasswordLink # type: ignore + from ._models import DatadogSingleSignOnProperties # type: ignore + from ._models import DatadogSingleSignOnResource # type: ignore + from ._models import DatadogSingleSignOnResourceListResponse # type: ignore + from ._models import ErrorResponseBody # type: ignore + from ._models import FilteringTag # type: ignore + from ._models import LinkedResource # type: ignore + from ._models import LinkedResourceListResponse # type: ignore + from ._models import MonitoredResource # type: ignore + from ._models import MonitoredResourceListResponse # type: ignore + from ._models import MonitoringTagRules # type: ignore + from ._models import MonitoringTagRulesListResponse # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import OperationResult # type: ignore + from ._models import ResourceProviderDefaultErrorResponse # type: ignore + from ._models import UserInfo # type: ignore + +from ._microsoft_datadog_client_enums import ( + LiftrResourceCategories, + ManagedIdentityTypes, + MarketplaceSubscriptionStatus, + MonitoringStatus, + ProvisioningState, + SingleSignOnStates, + TagAction, +) + +__all__ = [ + 'DatadogApiKey', + 'DatadogApiKeyListResponse', + 'DatadogHost', + 'DatadogHostListResponse', + 'DatadogHostMetadata', + 'DatadogInstallMethod', + 'DatadogLogsAgent', + 'DatadogMonitorResource', + 'DatadogMonitorResourceListResponse', + 'DatadogMonitorResourceUpdateParameters', + 'DatadogOrganizationProperties', + 'DatadogSetPasswordLink', + 'DatadogSingleSignOnProperties', + 'DatadogSingleSignOnResource', + 'DatadogSingleSignOnResourceListResponse', + 'ErrorResponseBody', + 'FilteringTag', + 'LinkedResource', + 'LinkedResourceListResponse', + 'MonitoredResource', + 'MonitoredResourceListResponse', + 'MonitoringTagRules', + 'MonitoringTagRulesListResponse', + 'OperationDisplay', + 'OperationListResult', + 'OperationResult', + 'ResourceProviderDefaultErrorResponse', + 'UserInfo', + 'LiftrResourceCategories', + 'ManagedIdentityTypes', + 'MarketplaceSubscriptionStatus', + 'MonitoringStatus', + 'ProvisioningState', + 'SingleSignOnStates', + 'TagAction', +] diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/models/_microsoft_datadog_client_enums.py b/src/datadog/azext_datadog/vendored_sdks/datadog/models/_microsoft_datadog_client_enums.py new file mode 100644 index 00000000000..7e344646af0 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/models/_microsoft_datadog_client_enums.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class LiftrResourceCategories(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + UNKNOWN = "Unknown" + MONITOR_LOGS = "MonitorLogs" + +class ManagedIdentityTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + +class MarketplaceSubscriptionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Flag specifying the Marketplace Subscription Status of the resource. If payment is not made in + time, the resource will go in Suspended state. + """ + + ACTIVE = "Active" + SUSPENDED = "Suspended" + +class MonitoringStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Flag specifying if the resource monitoring is enabled or disabled. + """ + + ENABLED = "Enabled" + DISABLED = "Disabled" + +class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + ACCEPTED = "Accepted" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + DELETED = "Deleted" + NOT_SPECIFIED = "NotSpecified" + +class SingleSignOnStates(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Various states of the SSO resource + """ + + INITIAL = "Initial" + ENABLE = "Enable" + DISABLE = "Disable" + EXISTING = "Existing" + +class TagAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Valid actions for a filtering tag. Exclusion takes priority over inclusion. + """ + + INCLUDE = "Include" + EXCLUDE = "Exclude" diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models.py b/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models.py new file mode 100644 index 00000000000..46eb3288f11 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models.py @@ -0,0 +1,880 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class DatadogApiKey(msrest.serialization.Model): + """DatadogApiKey. + + All required parameters must be populated in order to send to Azure. + + :param created_by: The user that created the API key. + :type created_by: str + :param name: The name of the API key. + :type name: str + :param key: Required. The value of the API key. + :type key: str + :param created: The time of creation of the API key. + :type created: str + """ + + _validation = { + 'key': {'required': True}, + } + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'key': {'key': 'key', 'type': 'str'}, + 'created': {'key': 'created', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogApiKey, self).__init__(**kwargs) + self.created_by = kwargs.get('created_by', None) + self.name = kwargs.get('name', None) + self.key = kwargs['key'] + self.created = kwargs.get('created', None) + + +class DatadogApiKeyListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.DatadogApiKey] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DatadogApiKey]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogApiKeyListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class DatadogHost(msrest.serialization.Model): + """DatadogHost. + + :param name: The name of the host. + :type name: str + :param aliases: The aliases for the host. + :type aliases: list[str] + :param apps: The Datadog integrations reporting metrics for the host. + :type apps: list[str] + :param meta: + :type meta: ~microsoft_datadog_client.models.DatadogHostMetadata + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'aliases': {'key': 'aliases', 'type': '[str]'}, + 'apps': {'key': 'apps', 'type': '[str]'}, + 'meta': {'key': 'meta', 'type': 'DatadogHostMetadata'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogHost, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.aliases = kwargs.get('aliases', None) + self.apps = kwargs.get('apps', None) + self.meta = kwargs.get('meta', None) + + +class DatadogHostListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.DatadogHost] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DatadogHost]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogHostListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class DatadogHostMetadata(msrest.serialization.Model): + """DatadogHostMetadata. + + :param agent_version: The agent version. + :type agent_version: str + :param install_method: + :type install_method: ~microsoft_datadog_client.models.DatadogInstallMethod + :param logs_agent: + :type logs_agent: ~microsoft_datadog_client.models.DatadogLogsAgent + """ + + _attribute_map = { + 'agent_version': {'key': 'agentVersion', 'type': 'str'}, + 'install_method': {'key': 'installMethod', 'type': 'DatadogInstallMethod'}, + 'logs_agent': {'key': 'logsAgent', 'type': 'DatadogLogsAgent'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogHostMetadata, self).__init__(**kwargs) + self.agent_version = kwargs.get('agent_version', None) + self.install_method = kwargs.get('install_method', None) + self.logs_agent = kwargs.get('logs_agent', None) + + +class DatadogInstallMethod(msrest.serialization.Model): + """DatadogInstallMethod. + + :param tool: The tool. + :type tool: str + :param tool_version: The tool version. + :type tool_version: str + :param installer_version: The installer version. + :type installer_version: str + """ + + _attribute_map = { + 'tool': {'key': 'tool', 'type': 'str'}, + 'tool_version': {'key': 'toolVersion', 'type': 'str'}, + 'installer_version': {'key': 'installerVersion', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogInstallMethod, self).__init__(**kwargs) + self.tool = kwargs.get('tool', None) + self.tool_version = kwargs.get('tool_version', None) + self.installer_version = kwargs.get('installer_version', None) + + +class DatadogLogsAgent(msrest.serialization.Model): + """DatadogLogsAgent. + + :param transport: The transport. + :type transport: str + """ + + _attribute_map = { + 'transport': {'key': 'transport', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogLogsAgent, self).__init__(**kwargs) + self.transport = kwargs.get('transport', None) + + +class DatadogMonitorResource(msrest.serialization.Model): + """DatadogMonitorResource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: ARM id of the monitor resource. + :vartype id: str + :ivar name: Name of the monitor resource. + :vartype name: str + :ivar type: The type of the monitor resource. + :vartype type: str + :param tags: A set of tags. Dictionary of :code:``. + :type tags: dict[str, str] + :param location: Required. + :type location: str + :ivar principal_id: The identity ID. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :param type_identity_type: Possible values include: "SystemAssigned", "UserAssigned". + :type type_identity_type: str or ~microsoft_datadog_client.models.ManagedIdentityTypes + :param provisioning_state: Possible values include: "Accepted", "Creating", "Updating", + "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". + :type provisioning_state: str or ~microsoft_datadog_client.models.ProvisioningState + :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + Possible values include: "Enabled", "Disabled". + :type monitoring_status: str or ~microsoft_datadog_client.models.MonitoringStatus + :param marketplace_subscription_status: Flag specifying the Marketplace Subscription Status of + the resource. If payment is not made in time, the resource will go in Suspended state. Possible + values include: "Active", "Suspended". + :type marketplace_subscription_status: str or + ~microsoft_datadog_client.models.MarketplaceSubscriptionStatus + :param datadog_organization_properties: + :type datadog_organization_properties: + ~microsoft_datadog_client.models.DatadogOrganizationProperties + :param user_info: + :type user_info: ~microsoft_datadog_client.models.UserInfo + :ivar liftr_resource_category: Possible values include: "Unknown", "MonitorLogs". + :vartype liftr_resource_category: str or + ~microsoft_datadog_client.models.LiftrResourceCategories + :ivar liftr_resource_preference: The priority of the resource. + :vartype liftr_resource_preference: int + :param name_sku_name: Name of the SKU. + :type name_sku_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'liftr_resource_category': {'readonly': True}, + 'liftr_resource_preference': {'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'}, + 'principal_id': {'key': 'identity.principalId', 'type': 'str'}, + 'tenant_id': {'key': 'identity.tenantId', 'type': 'str'}, + 'type_identity_type': {'key': 'identity.type', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, + 'marketplace_subscription_status': {'key': 'properties.marketplaceSubscriptionStatus', 'type': 'str'}, + 'datadog_organization_properties': {'key': 'properties.datadogOrganizationProperties', 'type': 'DatadogOrganizationProperties'}, + 'user_info': {'key': 'properties.userInfo', 'type': 'UserInfo'}, + 'liftr_resource_category': {'key': 'properties.liftrResourceCategory', 'type': 'str'}, + 'liftr_resource_preference': {'key': 'properties.liftrResourcePreference', 'type': 'int'}, + 'name_sku_name': {'key': 'sku.name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogMonitorResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.tags = kwargs.get('tags', None) + self.location = kwargs['location'] + self.principal_id = None + self.tenant_id = None + self.type_identity_type = kwargs.get('type_identity_type', None) + self.provisioning_state = kwargs.get('provisioning_state', None) + self.monitoring_status = kwargs.get('monitoring_status', None) + self.marketplace_subscription_status = kwargs.get('marketplace_subscription_status', None) + self.datadog_organization_properties = kwargs.get('datadog_organization_properties', None) + self.user_info = kwargs.get('user_info', None) + self.liftr_resource_category = None + self.liftr_resource_preference = None + self.name_sku_name = kwargs.get('name_sku_name', None) + + +class DatadogMonitorResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.DatadogMonitorResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DatadogMonitorResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogMonitorResourceListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class DatadogMonitorResourceUpdateParameters(msrest.serialization.Model): + """The parameters for a PATCH request to a monitor resource. + + :param tags: A set of tags. The new tags of the monitor resource. + :type tags: dict[str, str] + :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + Possible values include: "Enabled", "Disabled". + :type monitoring_status: str or ~microsoft_datadog_client.models.MonitoringStatus + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogMonitorResourceUpdateParameters, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.monitoring_status = kwargs.get('monitoring_status', None) + + +class DatadogOrganizationProperties(msrest.serialization.Model): + """DatadogOrganizationProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Datadog organization. + :vartype name: str + :ivar id: Id of the Datadog organization. + :vartype id: str + :param linking_auth_code: The auth code used to linking to an existing datadog organization. + :type linking_auth_code: str + :param linking_client_id: The client_id from an existing in exchange for an auth token to link + organization. + :type linking_client_id: str + :param enterprise_app_id: The Id of the Enterprise App used for Single sign on. + :type enterprise_app_id: str + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'linking_auth_code': {'key': 'linkingAuthCode', 'type': 'str'}, + 'linking_client_id': {'key': 'linkingClientId', 'type': 'str'}, + 'enterprise_app_id': {'key': 'enterpriseAppId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogOrganizationProperties, self).__init__(**kwargs) + self.name = None + self.id = None + self.linking_auth_code = kwargs.get('linking_auth_code', None) + self.linking_client_id = kwargs.get('linking_client_id', None) + self.enterprise_app_id = kwargs.get('enterprise_app_id', None) + + +class DatadogSetPasswordLink(msrest.serialization.Model): + """DatadogSetPasswordLink. + + :param set_password_link: + :type set_password_link: str + """ + + _attribute_map = { + 'set_password_link': {'key': 'setPasswordLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogSetPasswordLink, self).__init__(**kwargs) + self.set_password_link = kwargs.get('set_password_link', None) + + +class DatadogSingleSignOnProperties(msrest.serialization.Model): + """DatadogSingleSignOnProperties. + + :param single_sign_on_state: Various states of the SSO resource. Possible values include: + "Initial", "Enable", "Disable", "Existing". + :type single_sign_on_state: str or ~microsoft_datadog_client.models.SingleSignOnStates + :param enterprise_app_id: The Id of the Enterprise App used for Single sign-on. + :type enterprise_app_id: str + :param single_sign_on_url: The login URL specific to this Datadog Organization. + :type single_sign_on_url: str + """ + + _attribute_map = { + 'single_sign_on_state': {'key': 'singleSignOnState', 'type': 'str'}, + 'enterprise_app_id': {'key': 'enterpriseAppId', 'type': 'str'}, + 'single_sign_on_url': {'key': 'singleSignOnUrl', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogSingleSignOnProperties, self).__init__(**kwargs) + self.single_sign_on_state = kwargs.get('single_sign_on_state', None) + self.enterprise_app_id = kwargs.get('enterprise_app_id', None) + self.single_sign_on_url = kwargs.get('single_sign_on_url', None) + + +class DatadogSingleSignOnResource(msrest.serialization.Model): + """DatadogSingleSignOnResource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: ARM id of the resource. + :vartype id: str + :ivar name: Name of the configuration. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param properties: + :type properties: ~microsoft_datadog_client.models.DatadogSingleSignOnProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DatadogSingleSignOnProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogSingleSignOnResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = kwargs.get('properties', None) + + +class DatadogSingleSignOnResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.DatadogSingleSignOnResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DatadogSingleSignOnResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DatadogSingleSignOnResourceListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ErrorResponseBody(msrest.serialization.Model): + """ErrorResponseBody. + + :param code: + :type code: str + :param message: + :type message: str + :param target: + :type target: str + :param details: + :type details: list[~microsoft_datadog_client.models.ErrorResponseBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorResponseBody]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponseBody, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.target = kwargs.get('target', None) + self.details = kwargs.get('details', None) + + +class FilteringTag(msrest.serialization.Model): + """The definition of a filtering tag. Filtering tags are used for capturing resources and include/exclude them from being monitored. + + :param name: The name (also known as the key) of the tag. + :type name: str + :param value: The value of the tag. + :type value: str + :param action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. + Possible values include: "Include", "Exclude". + :type action: str or ~microsoft_datadog_client.models.TagAction + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'action': {'key': 'action', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(FilteringTag, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.value = kwargs.get('value', None) + self.action = kwargs.get('action', None) + + +class LinkedResource(msrest.serialization.Model): + """The definition of a linked resource. + + :param id: The ARM id of the linked resource. + :type id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LinkedResource, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + + +class LinkedResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.LinkedResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LinkedResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LinkedResourceListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class MonitoredResource(msrest.serialization.Model): + """The properties of a resource currently being monitored by the Datadog monitor resource. + + :param id: The ARM id of the resource. + :type id: str + :param sending_metrics: Flag indicating if resource is sending metrics to Datadog. + :type sending_metrics: bool + :param reason_for_metrics_status: Reason for why the resource is sending metrics (or why it is + not sending). + :type reason_for_metrics_status: str + :param sending_logs: Flag indicating if resource is sending logs to Datadog. + :type sending_logs: bool + :param reason_for_logs_status: Reason for why the resource is sending logs (or why it is not + sending). + :type reason_for_logs_status: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'sending_metrics': {'key': 'sendingMetrics', 'type': 'bool'}, + 'reason_for_metrics_status': {'key': 'reasonForMetricsStatus', 'type': 'str'}, + 'sending_logs': {'key': 'sendingLogs', 'type': 'bool'}, + 'reason_for_logs_status': {'key': 'reasonForLogsStatus', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(MonitoredResource, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.sending_metrics = kwargs.get('sending_metrics', None) + self.reason_for_metrics_status = kwargs.get('reason_for_metrics_status', None) + self.sending_logs = kwargs.get('sending_logs', None) + self.reason_for_logs_status = kwargs.get('reason_for_logs_status', None) + + +class MonitoredResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.MonitoredResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[MonitoredResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(MonitoredResourceListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class MonitoringTagRules(msrest.serialization.Model): + """Capture logs and metrics of Azure resources based on ARM tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the rule set. + :vartype name: str + :ivar id: The id of the rule set. + :vartype id: str + :ivar type: The type of the rule set. + :vartype type: str + :param filtering_tags_properties_metric_rules_filtering_tags: List of filtering tags to be used + for capturing metrics. If empty, all resources will be captured. If only Exclude action is + specified, the rules will apply to the list of all available resources. If Include actions are + specified, the rules will only include resources with the associated tags. + :type filtering_tags_properties_metric_rules_filtering_tags: + list[~microsoft_datadog_client.models.FilteringTag] + :param send_aad_logs: Flag specifying if AAD logs should be sent for the Monitor resource. + :type send_aad_logs: bool + :param send_subscription_logs: Flag specifying if Azure subscription logs should be sent for + the Monitor resource. + :type send_subscription_logs: bool + :param send_resource_logs: Flag specifying if Azure resource logs should be sent for the + Monitor resource. + :type send_resource_logs: bool + :param filtering_tags_properties_log_rules_filtering_tags: List of filtering tags to be used + for capturing logs. This only takes effect if SendResourceLogs flag is enabled. If empty, all + resources will be captured. If only Exclude action is specified, the rules will apply to the + list of all available resources. If Include actions are specified, the rules will only include + resources with the associated tags. + :type filtering_tags_properties_log_rules_filtering_tags: + list[~microsoft_datadog_client.models.FilteringTag] + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'filtering_tags_properties_metric_rules_filtering_tags': {'key': 'properties.metricRules.filteringTags', 'type': '[FilteringTag]'}, + 'send_aad_logs': {'key': 'properties.logRules.sendAadLogs', 'type': 'bool'}, + 'send_subscription_logs': {'key': 'properties.logRules.sendSubscriptionLogs', 'type': 'bool'}, + 'send_resource_logs': {'key': 'properties.logRules.sendResourceLogs', 'type': 'bool'}, + 'filtering_tags_properties_log_rules_filtering_tags': {'key': 'properties.logRules.filteringTags', 'type': '[FilteringTag]'}, + } + + def __init__( + self, + **kwargs + ): + super(MonitoringTagRules, self).__init__(**kwargs) + self.name = None + self.id = None + self.type = None + self.filtering_tags_properties_metric_rules_filtering_tags = kwargs.get('filtering_tags_properties_metric_rules_filtering_tags', None) + self.send_aad_logs = kwargs.get('send_aad_logs', None) + self.send_subscription_logs = kwargs.get('send_subscription_logs', None) + self.send_resource_logs = kwargs.get('send_resource_logs', None) + self.filtering_tags_properties_log_rules_filtering_tags = kwargs.get('filtering_tags_properties_log_rules_filtering_tags', None) + + +class MonitoringTagRulesListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.MonitoringTagRules] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[MonitoringTagRules]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(MonitoringTagRulesListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider, i.e., Microsoft.Datadog. + :type provider: str + :param resource: Type on which the operation is performed, e.g., 'monitors'. + :type resource: str + :param operation: Operation type, e.g., read, write, delete, etc. + :type operation: str + :param description: Description of the operation, e.g., 'Write monitors'. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + self.operation = kwargs.get('operation', None) + self.description = kwargs.get('description', None) + + +class OperationListResult(msrest.serialization.Model): + """Result of GET request to list the Microsoft.Datadog operations. + + :param value: List of operations supported by the Microsoft.Datadog provider. + :type value: list[~microsoft_datadog_client.models.OperationResult] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationResult]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class OperationResult(msrest.serialization.Model): + """A Microsoft.Datadog REST API operation. + + :param name: Operation name, i.e., {provider}/{resource}/{operation}. + :type name: str + :param display: The object that represents the operation. + :type display: ~microsoft_datadog_client.models.OperationDisplay + :param is_data_action: Indicates whether the operation is a data action. + :type is_data_action: bool + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationResult, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + self.is_data_action = kwargs.get('is_data_action', None) + + +class ResourceProviderDefaultErrorResponse(msrest.serialization.Model): + """ResourceProviderDefaultErrorResponse. + + :param error: + :type error: ~microsoft_datadog_client.models.ErrorResponseBody + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceProviderDefaultErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class UserInfo(msrest.serialization.Model): + """UserInfo. + + :param name: Name of the user. + :type name: str + :param email_address: Email of the user used by Datadog for contacting them if needed. + :type email_address: str + :param phone_number: Phone number of the user used by Datadog for contacting them if needed. + :type phone_number: str + """ + + _validation = { + 'name': {'max_length': 50, 'min_length': 0}, + 'email_address': {'pattern': r'^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}$'}, + 'phone_number': {'max_length': 40, 'min_length': 0}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'email_address': {'key': 'emailAddress', 'type': 'str'}, + 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(UserInfo, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.email_address = kwargs.get('email_address', None) + self.phone_number = kwargs.get('phone_number', None) diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models_py3.py b/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models_py3.py new file mode 100644 index 00000000000..db5f71213cb --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models_py3.py @@ -0,0 +1,991 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._microsoft_datadog_client_enums import * + + +class DatadogApiKey(msrest.serialization.Model): + """DatadogApiKey. + + All required parameters must be populated in order to send to Azure. + + :param created_by: The user that created the API key. + :type created_by: str + :param name: The name of the API key. + :type name: str + :param key: Required. The value of the API key. + :type key: str + :param created: The time of creation of the API key. + :type created: str + """ + + _validation = { + 'key': {'required': True}, + } + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'key': {'key': 'key', 'type': 'str'}, + 'created': {'key': 'created', 'type': 'str'}, + } + + def __init__( + self, + *, + key: str, + created_by: Optional[str] = None, + name: Optional[str] = None, + created: Optional[str] = None, + **kwargs + ): + super(DatadogApiKey, self).__init__(**kwargs) + self.created_by = created_by + self.name = name + self.key = key + self.created = created + + +class DatadogApiKeyListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.DatadogApiKey] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DatadogApiKey]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DatadogApiKey"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(DatadogApiKeyListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class DatadogHost(msrest.serialization.Model): + """DatadogHost. + + :param name: The name of the host. + :type name: str + :param aliases: The aliases for the host. + :type aliases: list[str] + :param apps: The Datadog integrations reporting metrics for the host. + :type apps: list[str] + :param meta: + :type meta: ~microsoft_datadog_client.models.DatadogHostMetadata + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'aliases': {'key': 'aliases', 'type': '[str]'}, + 'apps': {'key': 'apps', 'type': '[str]'}, + 'meta': {'key': 'meta', 'type': 'DatadogHostMetadata'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + aliases: Optional[List[str]] = None, + apps: Optional[List[str]] = None, + meta: Optional["DatadogHostMetadata"] = None, + **kwargs + ): + super(DatadogHost, self).__init__(**kwargs) + self.name = name + self.aliases = aliases + self.apps = apps + self.meta = meta + + +class DatadogHostListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.DatadogHost] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DatadogHost]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DatadogHost"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(DatadogHostListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class DatadogHostMetadata(msrest.serialization.Model): + """DatadogHostMetadata. + + :param agent_version: The agent version. + :type agent_version: str + :param install_method: + :type install_method: ~microsoft_datadog_client.models.DatadogInstallMethod + :param logs_agent: + :type logs_agent: ~microsoft_datadog_client.models.DatadogLogsAgent + """ + + _attribute_map = { + 'agent_version': {'key': 'agentVersion', 'type': 'str'}, + 'install_method': {'key': 'installMethod', 'type': 'DatadogInstallMethod'}, + 'logs_agent': {'key': 'logsAgent', 'type': 'DatadogLogsAgent'}, + } + + def __init__( + self, + *, + agent_version: Optional[str] = None, + install_method: Optional["DatadogInstallMethod"] = None, + logs_agent: Optional["DatadogLogsAgent"] = None, + **kwargs + ): + super(DatadogHostMetadata, self).__init__(**kwargs) + self.agent_version = agent_version + self.install_method = install_method + self.logs_agent = logs_agent + + +class DatadogInstallMethod(msrest.serialization.Model): + """DatadogInstallMethod. + + :param tool: The tool. + :type tool: str + :param tool_version: The tool version. + :type tool_version: str + :param installer_version: The installer version. + :type installer_version: str + """ + + _attribute_map = { + 'tool': {'key': 'tool', 'type': 'str'}, + 'tool_version': {'key': 'toolVersion', 'type': 'str'}, + 'installer_version': {'key': 'installerVersion', 'type': 'str'}, + } + + def __init__( + self, + *, + tool: Optional[str] = None, + tool_version: Optional[str] = None, + installer_version: Optional[str] = None, + **kwargs + ): + super(DatadogInstallMethod, self).__init__(**kwargs) + self.tool = tool + self.tool_version = tool_version + self.installer_version = installer_version + + +class DatadogLogsAgent(msrest.serialization.Model): + """DatadogLogsAgent. + + :param transport: The transport. + :type transport: str + """ + + _attribute_map = { + 'transport': {'key': 'transport', 'type': 'str'}, + } + + def __init__( + self, + *, + transport: Optional[str] = None, + **kwargs + ): + super(DatadogLogsAgent, self).__init__(**kwargs) + self.transport = transport + + +class DatadogMonitorResource(msrest.serialization.Model): + """DatadogMonitorResource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: ARM id of the monitor resource. + :vartype id: str + :ivar name: Name of the monitor resource. + :vartype name: str + :ivar type: The type of the monitor resource. + :vartype type: str + :param tags: A set of tags. Dictionary of :code:``. + :type tags: dict[str, str] + :param location: Required. + :type location: str + :ivar principal_id: The identity ID. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :param type_identity_type: Possible values include: "SystemAssigned", "UserAssigned". + :type type_identity_type: str or ~microsoft_datadog_client.models.ManagedIdentityTypes + :param provisioning_state: Possible values include: "Accepted", "Creating", "Updating", + "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". + :type provisioning_state: str or ~microsoft_datadog_client.models.ProvisioningState + :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + Possible values include: "Enabled", "Disabled". + :type monitoring_status: str or ~microsoft_datadog_client.models.MonitoringStatus + :param marketplace_subscription_status: Flag specifying the Marketplace Subscription Status of + the resource. If payment is not made in time, the resource will go in Suspended state. Possible + values include: "Active", "Suspended". + :type marketplace_subscription_status: str or + ~microsoft_datadog_client.models.MarketplaceSubscriptionStatus + :param datadog_organization_properties: + :type datadog_organization_properties: + ~microsoft_datadog_client.models.DatadogOrganizationProperties + :param user_info: + :type user_info: ~microsoft_datadog_client.models.UserInfo + :ivar liftr_resource_category: Possible values include: "Unknown", "MonitorLogs". + :vartype liftr_resource_category: str or + ~microsoft_datadog_client.models.LiftrResourceCategories + :ivar liftr_resource_preference: The priority of the resource. + :vartype liftr_resource_preference: int + :param name_sku_name: Name of the SKU. + :type name_sku_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'liftr_resource_category': {'readonly': True}, + 'liftr_resource_preference': {'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'}, + 'principal_id': {'key': 'identity.principalId', 'type': 'str'}, + 'tenant_id': {'key': 'identity.tenantId', 'type': 'str'}, + 'type_identity_type': {'key': 'identity.type', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, + 'marketplace_subscription_status': {'key': 'properties.marketplaceSubscriptionStatus', 'type': 'str'}, + 'datadog_organization_properties': {'key': 'properties.datadogOrganizationProperties', 'type': 'DatadogOrganizationProperties'}, + 'user_info': {'key': 'properties.userInfo', 'type': 'UserInfo'}, + 'liftr_resource_category': {'key': 'properties.liftrResourceCategory', 'type': 'str'}, + 'liftr_resource_preference': {'key': 'properties.liftrResourcePreference', 'type': 'int'}, + 'name_sku_name': {'key': 'sku.name', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + type_identity_type: Optional[Union[str, "ManagedIdentityTypes"]] = None, + provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, + monitoring_status: Optional[Union[str, "MonitoringStatus"]] = None, + marketplace_subscription_status: Optional[Union[str, "MarketplaceSubscriptionStatus"]] = None, + datadog_organization_properties: Optional["DatadogOrganizationProperties"] = None, + user_info: Optional["UserInfo"] = None, + name_sku_name: Optional[str] = None, + **kwargs + ): + super(DatadogMonitorResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.tags = tags + self.location = location + self.principal_id = None + self.tenant_id = None + self.type_identity_type = type_identity_type + self.provisioning_state = provisioning_state + self.monitoring_status = monitoring_status + self.marketplace_subscription_status = marketplace_subscription_status + self.datadog_organization_properties = datadog_organization_properties + self.user_info = user_info + self.liftr_resource_category = None + self.liftr_resource_preference = None + self.name_sku_name = name_sku_name + + +class DatadogMonitorResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.DatadogMonitorResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DatadogMonitorResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DatadogMonitorResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(DatadogMonitorResourceListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class DatadogMonitorResourceUpdateParameters(msrest.serialization.Model): + """The parameters for a PATCH request to a monitor resource. + + :param tags: A set of tags. The new tags of the monitor resource. + :type tags: dict[str, str] + :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + Possible values include: "Enabled", "Disabled". + :type monitoring_status: str or ~microsoft_datadog_client.models.MonitoringStatus + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + monitoring_status: Optional[Union[str, "MonitoringStatus"]] = None, + **kwargs + ): + super(DatadogMonitorResourceUpdateParameters, self).__init__(**kwargs) + self.tags = tags + self.monitoring_status = monitoring_status + + +class DatadogOrganizationProperties(msrest.serialization.Model): + """DatadogOrganizationProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Datadog organization. + :vartype name: str + :ivar id: Id of the Datadog organization. + :vartype id: str + :param linking_auth_code: The auth code used to linking to an existing datadog organization. + :type linking_auth_code: str + :param linking_client_id: The client_id from an existing in exchange for an auth token to link + organization. + :type linking_client_id: str + :param enterprise_app_id: The Id of the Enterprise App used for Single sign on. + :type enterprise_app_id: str + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'linking_auth_code': {'key': 'linkingAuthCode', 'type': 'str'}, + 'linking_client_id': {'key': 'linkingClientId', 'type': 'str'}, + 'enterprise_app_id': {'key': 'enterpriseAppId', 'type': 'str'}, + } + + def __init__( + self, + *, + linking_auth_code: Optional[str] = None, + linking_client_id: Optional[str] = None, + enterprise_app_id: Optional[str] = None, + **kwargs + ): + super(DatadogOrganizationProperties, self).__init__(**kwargs) + self.name = None + self.id = None + self.linking_auth_code = linking_auth_code + self.linking_client_id = linking_client_id + self.enterprise_app_id = enterprise_app_id + + +class DatadogSetPasswordLink(msrest.serialization.Model): + """DatadogSetPasswordLink. + + :param set_password_link: + :type set_password_link: str + """ + + _attribute_map = { + 'set_password_link': {'key': 'setPasswordLink', 'type': 'str'}, + } + + def __init__( + self, + *, + set_password_link: Optional[str] = None, + **kwargs + ): + super(DatadogSetPasswordLink, self).__init__(**kwargs) + self.set_password_link = set_password_link + + +class DatadogSingleSignOnProperties(msrest.serialization.Model): + """DatadogSingleSignOnProperties. + + :param single_sign_on_state: Various states of the SSO resource. Possible values include: + "Initial", "Enable", "Disable", "Existing". + :type single_sign_on_state: str or ~microsoft_datadog_client.models.SingleSignOnStates + :param enterprise_app_id: The Id of the Enterprise App used for Single sign-on. + :type enterprise_app_id: str + :param single_sign_on_url: The login URL specific to this Datadog Organization. + :type single_sign_on_url: str + """ + + _attribute_map = { + 'single_sign_on_state': {'key': 'singleSignOnState', 'type': 'str'}, + 'enterprise_app_id': {'key': 'enterpriseAppId', 'type': 'str'}, + 'single_sign_on_url': {'key': 'singleSignOnUrl', 'type': 'str'}, + } + + def __init__( + self, + *, + single_sign_on_state: Optional[Union[str, "SingleSignOnStates"]] = None, + enterprise_app_id: Optional[str] = None, + single_sign_on_url: Optional[str] = None, + **kwargs + ): + super(DatadogSingleSignOnProperties, self).__init__(**kwargs) + self.single_sign_on_state = single_sign_on_state + self.enterprise_app_id = enterprise_app_id + self.single_sign_on_url = single_sign_on_url + + +class DatadogSingleSignOnResource(msrest.serialization.Model): + """DatadogSingleSignOnResource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: ARM id of the resource. + :vartype id: str + :ivar name: Name of the configuration. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param properties: + :type properties: ~microsoft_datadog_client.models.DatadogSingleSignOnProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'DatadogSingleSignOnProperties'}, + } + + def __init__( + self, + *, + properties: Optional["DatadogSingleSignOnProperties"] = None, + **kwargs + ): + super(DatadogSingleSignOnResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + + +class DatadogSingleSignOnResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.DatadogSingleSignOnResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DatadogSingleSignOnResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DatadogSingleSignOnResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(DatadogSingleSignOnResourceListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ErrorResponseBody(msrest.serialization.Model): + """ErrorResponseBody. + + :param code: + :type code: str + :param message: + :type message: str + :param target: + :type target: str + :param details: + :type details: list[~microsoft_datadog_client.models.ErrorResponseBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorResponseBody]'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["ErrorResponseBody"]] = None, + **kwargs + ): + super(ErrorResponseBody, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class FilteringTag(msrest.serialization.Model): + """The definition of a filtering tag. Filtering tags are used for capturing resources and include/exclude them from being monitored. + + :param name: The name (also known as the key) of the tag. + :type name: str + :param value: The value of the tag. + :type value: str + :param action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. + Possible values include: "Include", "Exclude". + :type action: str or ~microsoft_datadog_client.models.TagAction + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'action': {'key': 'action', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + value: Optional[str] = None, + action: Optional[Union[str, "TagAction"]] = None, + **kwargs + ): + super(FilteringTag, self).__init__(**kwargs) + self.name = name + self.value = value + self.action = action + + +class LinkedResource(msrest.serialization.Model): + """The definition of a linked resource. + + :param id: The ARM id of the linked resource. + :type id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): + super(LinkedResource, self).__init__(**kwargs) + self.id = id + + +class LinkedResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.LinkedResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LinkedResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["LinkedResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(LinkedResourceListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class MonitoredResource(msrest.serialization.Model): + """The properties of a resource currently being monitored by the Datadog monitor resource. + + :param id: The ARM id of the resource. + :type id: str + :param sending_metrics: Flag indicating if resource is sending metrics to Datadog. + :type sending_metrics: bool + :param reason_for_metrics_status: Reason for why the resource is sending metrics (or why it is + not sending). + :type reason_for_metrics_status: str + :param sending_logs: Flag indicating if resource is sending logs to Datadog. + :type sending_logs: bool + :param reason_for_logs_status: Reason for why the resource is sending logs (or why it is not + sending). + :type reason_for_logs_status: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'sending_metrics': {'key': 'sendingMetrics', 'type': 'bool'}, + 'reason_for_metrics_status': {'key': 'reasonForMetricsStatus', 'type': 'str'}, + 'sending_logs': {'key': 'sendingLogs', 'type': 'bool'}, + 'reason_for_logs_status': {'key': 'reasonForLogsStatus', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + sending_metrics: Optional[bool] = None, + reason_for_metrics_status: Optional[str] = None, + sending_logs: Optional[bool] = None, + reason_for_logs_status: Optional[str] = None, + **kwargs + ): + super(MonitoredResource, self).__init__(**kwargs) + self.id = id + self.sending_metrics = sending_metrics + self.reason_for_metrics_status = reason_for_metrics_status + self.sending_logs = sending_logs + self.reason_for_logs_status = reason_for_logs_status + + +class MonitoredResourceListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.MonitoredResource] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[MonitoredResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["MonitoredResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(MonitoredResourceListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class MonitoringTagRules(msrest.serialization.Model): + """Capture logs and metrics of Azure resources based on ARM tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the rule set. + :vartype name: str + :ivar id: The id of the rule set. + :vartype id: str + :ivar type: The type of the rule set. + :vartype type: str + :param filtering_tags_properties_metric_rules_filtering_tags: List of filtering tags to be used + for capturing metrics. If empty, all resources will be captured. If only Exclude action is + specified, the rules will apply to the list of all available resources. If Include actions are + specified, the rules will only include resources with the associated tags. + :type filtering_tags_properties_metric_rules_filtering_tags: + list[~microsoft_datadog_client.models.FilteringTag] + :param send_aad_logs: Flag specifying if AAD logs should be sent for the Monitor resource. + :type send_aad_logs: bool + :param send_subscription_logs: Flag specifying if Azure subscription logs should be sent for + the Monitor resource. + :type send_subscription_logs: bool + :param send_resource_logs: Flag specifying if Azure resource logs should be sent for the + Monitor resource. + :type send_resource_logs: bool + :param filtering_tags_properties_log_rules_filtering_tags: List of filtering tags to be used + for capturing logs. This only takes effect if SendResourceLogs flag is enabled. If empty, all + resources will be captured. If only Exclude action is specified, the rules will apply to the + list of all available resources. If Include actions are specified, the rules will only include + resources with the associated tags. + :type filtering_tags_properties_log_rules_filtering_tags: + list[~microsoft_datadog_client.models.FilteringTag] + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'filtering_tags_properties_metric_rules_filtering_tags': {'key': 'properties.metricRules.filteringTags', 'type': '[FilteringTag]'}, + 'send_aad_logs': {'key': 'properties.logRules.sendAadLogs', 'type': 'bool'}, + 'send_subscription_logs': {'key': 'properties.logRules.sendSubscriptionLogs', 'type': 'bool'}, + 'send_resource_logs': {'key': 'properties.logRules.sendResourceLogs', 'type': 'bool'}, + 'filtering_tags_properties_log_rules_filtering_tags': {'key': 'properties.logRules.filteringTags', 'type': '[FilteringTag]'}, + } + + def __init__( + self, + *, + filtering_tags_properties_metric_rules_filtering_tags: Optional[List["FilteringTag"]] = None, + send_aad_logs: Optional[bool] = None, + send_subscription_logs: Optional[bool] = None, + send_resource_logs: Optional[bool] = None, + filtering_tags_properties_log_rules_filtering_tags: Optional[List["FilteringTag"]] = None, + **kwargs + ): + super(MonitoringTagRules, self).__init__(**kwargs) + self.name = None + self.id = None + self.type = None + self.filtering_tags_properties_metric_rules_filtering_tags = filtering_tags_properties_metric_rules_filtering_tags + self.send_aad_logs = send_aad_logs + self.send_subscription_logs = send_subscription_logs + self.send_resource_logs = send_resource_logs + self.filtering_tags_properties_log_rules_filtering_tags = filtering_tags_properties_log_rules_filtering_tags + + +class MonitoringTagRulesListResponse(msrest.serialization.Model): + """Response of a list operation. + + :param value: Results of a list operation. + :type value: list[~microsoft_datadog_client.models.MonitoringTagRules] + :param next_link: Link to the next set of results, if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[MonitoringTagRules]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["MonitoringTagRules"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(MonitoringTagRulesListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :param provider: Service provider, i.e., Microsoft.Datadog. + :type provider: str + :param resource: Type on which the operation is performed, e.g., 'monitors'. + :type resource: str + :param operation: Operation type, e.g., read, write, delete, etc. + :type operation: str + :param description: Description of the operation, e.g., 'Write monitors'. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(msrest.serialization.Model): + """Result of GET request to list the Microsoft.Datadog operations. + + :param value: List of operations supported by the Microsoft.Datadog provider. + :type value: list[~microsoft_datadog_client.models.OperationResult] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationResult]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["OperationResult"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationResult(msrest.serialization.Model): + """A Microsoft.Datadog REST API operation. + + :param name: Operation name, i.e., {provider}/{resource}/{operation}. + :type name: str + :param display: The object that represents the operation. + :type display: ~microsoft_datadog_client.models.OperationDisplay + :param is_data_action: Indicates whether the operation is a data action. + :type is_data_action: bool + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + is_data_action: Optional[bool] = None, + **kwargs + ): + super(OperationResult, self).__init__(**kwargs) + self.name = name + self.display = display + self.is_data_action = is_data_action + + +class ResourceProviderDefaultErrorResponse(msrest.serialization.Model): + """ResourceProviderDefaultErrorResponse. + + :param error: + :type error: ~microsoft_datadog_client.models.ErrorResponseBody + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + } + + def __init__( + self, + *, + error: Optional["ErrorResponseBody"] = None, + **kwargs + ): + super(ResourceProviderDefaultErrorResponse, self).__init__(**kwargs) + self.error = error + + +class UserInfo(msrest.serialization.Model): + """UserInfo. + + :param name: Name of the user. + :type name: str + :param email_address: Email of the user used by Datadog for contacting them if needed. + :type email_address: str + :param phone_number: Phone number of the user used by Datadog for contacting them if needed. + :type phone_number: str + """ + + _validation = { + 'name': {'max_length': 50, 'min_length': 0}, + 'email_address': {'pattern': r'^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}$'}, + 'phone_number': {'max_length': 40, 'min_length': 0}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'email_address': {'key': 'emailAddress', 'type': 'str'}, + 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + email_address: Optional[str] = None, + phone_number: Optional[str] = None, + **kwargs + ): + super(UserInfo, self).__init__(**kwargs) + self.name = name + self.email_address = email_address + self.phone_number = phone_number diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/operations/__init__.py b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/__init__.py new file mode 100644 index 00000000000..013d425c748 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._api_key_operations import ApiKeyOperations +from ._host_operations import HostOperations +from ._linked_resource_operations import LinkedResourceOperations +from ._monitored_resource_operations import MonitoredResourceOperations +from ._operation_operations import OperationOperations +from ._monitor_operations import MonitorOperations +from ._refresh_set_password_operations import RefreshSetPasswordOperations +from ._tag_rule_operations import TagRuleOperations +from ._single_sign_on_configuration_operations import SingleSignOnConfigurationOperations + +__all__ = [ + 'ApiKeyOperations', + 'HostOperations', + 'LinkedResourceOperations', + 'MonitoredResourceOperations', + 'OperationOperations', + 'MonitorOperations', + 'RefreshSetPasswordOperations', + 'TagRuleOperations', + 'SingleSignOnConfigurationOperations', +] diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_api_key_operations.py b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_api_key_operations.py new file mode 100644 index 00000000000..1c688a2ea92 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_api_key_operations.py @@ -0,0 +1,261 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ApiKeyOperations(object): + """ApiKeyOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DatadogApiKeyListResponse"] + """List the api keys for a given monitor resource. + + List the api keys for a given monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatadogApiKeyListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_datadog_client.models.DatadogApiKeyListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogApiKeyListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DatadogApiKeyListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/listApiKeys'} # type: ignore + + def get_default_key( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DatadogApiKey" + """Get the default api key. + + Get the default api key. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DatadogApiKey, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.DatadogApiKey + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogApiKey"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + # Construct URL + url = self.get_default_key.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DatadogApiKey', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_default_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/getDefaultKey'} # type: ignore + + def set_default_key( + self, + resource_group_name, # type: str + monitor_name, # type: str + key, # type: str + created_by=None, # type: Optional[str] + name=None, # type: Optional[str] + created=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Set the default api key. + + Set the default api key. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param key: The value of the API key. + :type key: str + :param created_by: The user that created the API key. + :type created_by: str + :param name: The name of the API key. + :type name: str + :param created: The time of creation of the API key. + :type created: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.DatadogApiKey(created_by=created_by, name=name, key=key, created=created) + api_version = "2020-02-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.set_default_key.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'DatadogApiKey') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + set_default_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/setDefaultKey'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_host_operations.py b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_host_operations.py new file mode 100644 index 00000000000..2e8a47a760a --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_host_operations.py @@ -0,0 +1,122 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class HostOperations(object): + """HostOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DatadogHostListResponse"] + """List the hosts for a given monitor resource. + + List the hosts for a given monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatadogHostListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_datadog_client.models.DatadogHostListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogHostListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DatadogHostListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/listHosts'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_linked_resource_operations.py b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_linked_resource_operations.py new file mode 100644 index 00000000000..bb4d552082a --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_linked_resource_operations.py @@ -0,0 +1,122 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class LinkedResourceOperations(object): + """LinkedResourceOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.LinkedResourceListResponse"] + """List all Azure resources associated to the same Datadog organization as the target resource. + + List all Azure resources associated to the same Datadog organization as the target resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LinkedResourceListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_datadog_client.models.LinkedResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LinkedResourceListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('LinkedResourceListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/listLinkedResources'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_monitor_operations.py b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_monitor_operations.py new file mode 100644 index 00000000000..7fb70f7eb58 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_monitor_operations.py @@ -0,0 +1,600 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class MonitorOperations(object): + """MonitorOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DatadogMonitorResourceListResponse"] + """List all monitors under the specified subscription. + + List all monitors under 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 DatadogMonitorResourceListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_datadog_client.models.DatadogMonitorResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResourceListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DatadogMonitorResourceListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Datadog/monitors'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DatadogMonitorResourceListResponse"] + """List all monitors under the specified resource group. + + List all monitors under the specified resource group. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatadogMonitorResourceListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_datadog_client.models.DatadogMonitorResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResourceListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DatadogMonitorResourceListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors'} # type: ignore + + def get( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DatadogMonitorResource" + """Get the properties of a specific monitor resource. + + Get the properties of a specific monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DatadogMonitorResource, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.DatadogMonitorResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + + def _create_initial( + self, + resource_group_name, # type: str + monitor_name, # type: str + location, # type: str + tags=None, # type: Optional[Dict[str, str]] + type=None, # type: Optional[Union[str, "models.ManagedIdentityTypes"]] + provisioning_state=None, # type: Optional[Union[str, "models.ProvisioningState"]] + monitoring_status=None, # type: Optional[Union[str, "models.MonitoringStatus"]] + marketplace_subscription_status=None, # type: Optional[Union[str, "models.MarketplaceSubscriptionStatus"]] + datadog_organization_properties=None, # type: Optional["models.DatadogOrganizationProperties"] + user_info=None, # type: Optional["models.UserInfo"] + name=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DatadogMonitorResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.DatadogMonitorResource(tags=tags, location=location, type_identity_type=type, provisioning_state=provisioning_state, monitoring_status=monitoring_status, marketplace_subscription_status=marketplace_subscription_status, datadog_organization_properties=datadog_organization_properties, user_info=user_info, name_sku_name=name) + api_version = "2020-02-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'DatadogMonitorResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + + def begin_create( + self, + resource_group_name, # type: str + monitor_name, # type: str + location, # type: str + tags=None, # type: Optional[Dict[str, str]] + type=None, # type: Optional[Union[str, "models.ManagedIdentityTypes"]] + provisioning_state=None, # type: Optional[Union[str, "models.ProvisioningState"]] + monitoring_status=None, # type: Optional[Union[str, "models.MonitoringStatus"]] + marketplace_subscription_status=None, # type: Optional[Union[str, "models.MarketplaceSubscriptionStatus"]] + datadog_organization_properties=None, # type: Optional["models.DatadogOrganizationProperties"] + user_info=None, # type: Optional["models.UserInfo"] + name=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.DatadogMonitorResource"] + """Create a monitor resource. + + Create a monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param location: + :type location: str + :param tags: Dictionary of :code:``. + :type tags: dict[str, str] + :param type: + :type type: str or ~microsoft_datadog_client.models.ManagedIdentityTypes + :param provisioning_state: + :type provisioning_state: str or ~microsoft_datadog_client.models.ProvisioningState + :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + :type monitoring_status: str or ~microsoft_datadog_client.models.MonitoringStatus + :param marketplace_subscription_status: Flag specifying the Marketplace Subscription Status of + the resource. If payment is not made in time, the resource will go in Suspended state. + :type marketplace_subscription_status: str or ~microsoft_datadog_client.models.MarketplaceSubscriptionStatus + :param datadog_organization_properties: + :type datadog_organization_properties: ~microsoft_datadog_client.models.DatadogOrganizationProperties + :param user_info: + :type user_info: ~microsoft_datadog_client.models.UserInfo + :param name: Name of the SKU. + :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. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DatadogMonitorResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~microsoft_datadog_client.models.DatadogMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResource"] + 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_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + location=location, + tags=tags, + type=type, + provisioning_state=provisioning_state, + monitoring_status=monitoring_status, + marketplace_subscription_status=marketplace_subscription_status, + datadog_organization_properties=datadog_organization_properties, + user_info=user_info, + name=name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + + def update( + self, + resource_group_name, # type: str + monitor_name, # type: str + tags=None, # type: Optional[Dict[str, str]] + monitoring_status=None, # type: Optional[Union[str, "models.MonitoringStatus"]] + **kwargs # type: Any + ): + # type: (...) -> "models.DatadogMonitorResource" + """Update a monitor resource. + + Update a monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param tags: The new tags of the monitor resource. + :type tags: dict[str, str] + :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + :type monitoring_status: str or ~microsoft_datadog_client.models.MonitoringStatus + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DatadogMonitorResource, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.DatadogMonitorResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.DatadogMonitorResourceUpdateParameters(tags=tags, monitoring_status=monitoring_status) + api_version = "2020-02-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'DatadogMonitorResourceUpdateParameters') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Delete a monitor resource. + + Delete a monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_monitored_resource_operations.py b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_monitored_resource_operations.py new file mode 100644 index 00000000000..8e982bdeda7 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_monitored_resource_operations.py @@ -0,0 +1,122 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class MonitoredResourceOperations(object): + """MonitoredResourceOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.MonitoredResourceListResponse"] + """List the resources currently being monitored by the Datadog monitor resource. + + List the resources currently being monitored by the Datadog monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitoredResourceListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_datadog_client.models.MonitoredResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.MonitoredResourceListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('MonitoredResourceListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/listMonitoredResources'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_operation_operations.py b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_operation_operations.py new file mode 100644 index 00000000000..1c90d2b4cbd --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_operation_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations(object): + """OperationOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] + """List all operations provided by Microsoft.Datadog for the 2020-02-01-preview api version. + + List all operations provided by Microsoft.Datadog for the 2020-02-01-preview api version. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_datadog_client.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Datadog/operations'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_refresh_set_password_operations.py b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_refresh_set_password_operations.py new file mode 100644 index 00000000000..2406fedbd38 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_refresh_set_password_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class RefreshSetPasswordOperations(object): + """RefreshSetPasswordOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DatadogSetPasswordLink" + """Refresh the set password link and return a latest one. + + Refresh the set password link and return a latest one. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DatadogSetPasswordLink, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.DatadogSetPasswordLink + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogSetPasswordLink"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DatadogSetPasswordLink', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/refreshSetPasswordLink'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_single_sign_on_configuration_operations.py b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_single_sign_on_configuration_operations.py new file mode 100644 index 00000000000..6b60e79a7a7 --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_single_sign_on_configuration_operations.py @@ -0,0 +1,325 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class SingleSignOnConfigurationOperations(object): + """SingleSignOnConfigurationOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DatadogSingleSignOnResourceListResponse"] + """List the single sign-on configurations for a given monitor resource. + + List the single sign-on configurations for a given monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatadogSingleSignOnResourceListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_datadog_client.models.DatadogSingleSignOnResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogSingleSignOnResourceListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DatadogSingleSignOnResourceListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/singleSignOnConfigurations'} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name, # type: str + monitor_name, # type: str + configuration_name, # type: str + properties=None, # type: Optional["models.DatadogSingleSignOnProperties"] + **kwargs # type: Any + ): + # type: (...) -> "models.DatadogSingleSignOnResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogSingleSignOnResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.DatadogSingleSignOnResource(properties=properties) + api_version = "2020-02-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'DatadogSingleSignOnResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('DatadogSingleSignOnResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DatadogSingleSignOnResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + monitor_name, # type: str + configuration_name, # type: str + properties=None, # type: Optional["models.DatadogSingleSignOnProperties"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.DatadogSingleSignOnResource"] + """Configures single-sign-on for this resource. + + Configures single-sign-on for this resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param configuration_name: + :type configuration_name: str + :param properties: + :type properties: ~microsoft_datadog_client.models.DatadogSingleSignOnProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either DatadogSingleSignOnResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~microsoft_datadog_client.models.DatadogSingleSignOnResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogSingleSignOnResource"] + 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( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_name, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DatadogSingleSignOnResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + monitor_name, # type: str + configuration_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DatadogSingleSignOnResource" + """Gets the datadog single sign-on resource for the given Monitor. + + Gets the datadog single sign-on resource for the given Monitor. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param configuration_name: + :type configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DatadogSingleSignOnResource, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.DatadogSingleSignOnResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogSingleSignOnResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DatadogSingleSignOnResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_tag_rule_operations.py b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_tag_rule_operations.py new file mode 100644 index 00000000000..d30ab42567d --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_tag_rule_operations.py @@ -0,0 +1,285 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TagRuleOperations(object): + """TagRuleOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_datadog_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.MonitoringTagRulesListResponse"] + """List the tag rules for a given monitor resource. + + List the tag rules for a given monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_datadog_client.models.MonitoringTagRulesListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.MonitoringTagRulesListResponse"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('MonitoringTagRulesListResponse', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/tagRules'} # type: ignore + + def create_or_update( + self, + resource_group_name, # type: str + monitor_name, # type: str + rule_set_name, # type: str + filtering_tags=None, # type: Optional[List["models.FilteringTag"]] + send_aad_logs=None, # type: Optional[bool] + send_subscription_logs=None, # type: Optional[bool] + send_resource_logs=None, # type: Optional[bool] + log_rules_filtering_tags=None, # type: Optional[List["models.FilteringTag"]] + **kwargs # type: Any + ): + # type: (...) -> "models.MonitoringTagRules" + """Create or update a tag rule set for a given monitor resource. + + Create or update a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param rule_set_name: + :type rule_set_name: str + :param filtering_tags: List of filtering tags to be used for capturing metrics. If empty, all + resources will be captured. If only Exclude action is specified, the rules will apply to the + list of all available resources. If Include actions are specified, the rules will only include + resources with the associated tags. + :type filtering_tags: list[~microsoft_datadog_client.models.FilteringTag] + :param send_aad_logs: Flag specifying if AAD logs should be sent for the Monitor resource. + :type send_aad_logs: bool + :param send_subscription_logs: Flag specifying if Azure subscription logs should be sent for + the Monitor resource. + :type send_subscription_logs: bool + :param send_resource_logs: Flag specifying if Azure resource logs should be sent for the + Monitor resource. + :type send_resource_logs: bool + :param log_rules_filtering_tags: List of filtering tags to be used for capturing logs. This + only takes effect if SendResourceLogs flag is enabled. If empty, all resources will be + captured. If only Exclude action is specified, the rules will apply to the list of all + available resources. If Include actions are specified, the rules will only include resources + with the associated tags. + :type log_rules_filtering_tags: list[~microsoft_datadog_client.models.FilteringTag] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringTagRules, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.MonitoringTagRules + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.MonitoringTagRules"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _body = models.MonitoringTagRules(filtering_tags_properties_metric_rules_filtering_tags=filtering_tags, send_aad_logs=send_aad_logs, send_subscription_logs=send_subscription_logs, send_resource_logs=send_resource_logs, filtering_tags_properties_log_rules_filtering_tags=log_rules_filtering_tags) + api_version = "2020-02-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + if _body is not None: + body_content = self._serialize.body(_body, 'MonitoringTagRules') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MonitoringTagRules', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + monitor_name, # type: str + rule_set_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.MonitoringTagRules" + """Get a tag rule set for a given monitor resource. + + Get a tag rule set for a given monitor resource. + + :param resource_group_name: The name of the resource group to which the Datadog resource + belongs. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param rule_set_name: + :type rule_set_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringTagRules, or the result of cls(response) + :rtype: ~microsoft_datadog_client.models.MonitoringTagRules + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.MonitoringTagRules"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-02-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ResourceProviderDefaultErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MonitoringTagRules', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/py.typed b/src/datadog/azext_datadog/vendored_sdks/datadog/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/datadog/report.md b/src/datadog/report.md new file mode 100644 index 00000000000..e28371c14ac --- /dev/null +++ b/src/datadog/report.md @@ -0,0 +1,434 @@ +# Azure CLI Module Creation Report + +### datadog api-key get-default-key + +get-default-key a datadog api-key. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog api-key|ApiKeys| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|get-default-key|GetDefaultKey| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +### datadog api-key list + +list a datadog api-key. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog api-key|ApiKeys| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|list|List| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +### datadog api-key set-default-key + +set-default-key a datadog api-key. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog api-key|ApiKeys| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|set-default-key|SetDefaultKey| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--key**|string|The value of the API key.|key|key| +|**--created-by**|string|The user that created the API key.|created_by|createdBy| +|**--name**|string|The name of the API key.|name|name| +|**--created**|string|The time of creation of the API key.|created|created| + +### datadog host list + +list a datadog host. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog host|Hosts| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|list|List| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +### datadog linked-resource list + +list a datadog linked-resource. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog linked-resource|LinkedResources| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|list|List| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +### datadog monitor create + +create a datadog monitor. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog monitor|Monitors| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|create|Create| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--location**|string||location|location| +|**--tags**|dictionary|Dictionary of :code:``|tags|tags| +|**--identity-type**|choice||type|type| +|**--provisioning-state**|choice||provisioning_state|provisioningState| +|**--monitoring-status**|choice|Flag specifying if the resource monitoring is enabled or disabled.|monitoring_status|monitoringStatus| +|**--marketplace-subscription-status**|choice|Flag specifying the Marketplace Subscription Status of the resource. If payment is not made in time, the resource will go in Suspended state.|marketplace_subscription_status|marketplaceSubscriptionStatus| +|**--datadog-organization-properties**|object||datadog_organization_properties|datadogOrganizationProperties| +|**--user-info**|object||user_info|userInfo| +|**--sku-name**|string|Name of the SKU.|name|name| + +### datadog monitor delete + +delete a datadog monitor. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog monitor|Monitors| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|delete|Delete| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +### datadog monitor list + +list a datadog monitor. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog monitor|Monitors| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|list|ListByResourceGroup| +|list|List| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| + +### datadog monitor show + +show a datadog monitor. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog monitor|Monitors| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|show|Get| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +### datadog monitor update + +update a datadog monitor. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog monitor|Monitors| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|update|Update| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--tags**|dictionary|The new tags of the monitor resource.|tags|tags| +|**--monitoring-status**|choice|Flag specifying if the resource monitoring is enabled or disabled.|monitoring_status|monitoringStatus| + +### datadog monitored-resource list + +list a datadog monitored-resource. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog monitored-resource|MonitoredResources| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|list|List| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +### datadog refresh-set-password get + +get a datadog refresh-set-password. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog refresh-set-password|RefreshSetPassword| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|get|Get| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +### datadog single-sign-on-configuration create + +create a datadog single-sign-on-configuration. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog single-sign-on-configuration|SingleSignOnConfigurations| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|create|CreateOrUpdate#Create| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--configuration-name**|string||configuration_name|configurationName| +|**--properties**|object||properties|properties| + +### datadog single-sign-on-configuration list + +list a datadog single-sign-on-configuration. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog single-sign-on-configuration|SingleSignOnConfigurations| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|list|List| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +### datadog single-sign-on-configuration show + +show a datadog single-sign-on-configuration. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog single-sign-on-configuration|SingleSignOnConfigurations| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|show|Get| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--configuration-name**|string||configuration_name|configurationName| + +### datadog single-sign-on-configuration update + +update a datadog single-sign-on-configuration. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog single-sign-on-configuration|SingleSignOnConfigurations| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|update|CreateOrUpdate#Update| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--configuration-name**|string||configuration_name|configurationName| +|**--properties**|object||properties|properties| + +### datadog tag-rule create + +create a datadog tag-rule. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog tag-rule|TagRules| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|create|CreateOrUpdate#Create| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--rule-set-name**|string||rule_set_name|ruleSetName| +|**--metric-rules-filtering-tags**|array|List of filtering tags to be used for capturing metrics. If empty, all resources will be captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include actions are specified, the rules will only include resources with the associated tags.|filtering_tags|filteringTags| +|**--log-rules-send-aad-logs**|boolean|Flag specifying if AAD logs should be sent for the Monitor resource.|send_aad_logs|sendAadLogs| +|**--log-rules-send-subscription-logs**|boolean|Flag specifying if Azure subscription logs should be sent for the Monitor resource.|send_subscription_logs|sendSubscriptionLogs| +|**--log-rules-send-resource-logs**|boolean|Flag specifying if Azure resource logs should be sent for the Monitor resource.|send_resource_logs|sendResourceLogs| +|**--log-rules-filtering-tags**|array|List of filtering tags to be used for capturing logs. This only takes effect if SendResourceLogs flag is enabled. If empty, all resources will be captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include actions are specified, the rules will only include resources with the associated tags.|log_rules_filtering_tags|filteringTags| + +### datadog tag-rule list + +list a datadog tag-rule. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog tag-rule|TagRules| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|list|List| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +### datadog tag-rule show + +show a datadog tag-rule. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog tag-rule|TagRules| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|show|Get| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--rule-set-name**|string||rule_set_name|ruleSetName| + +### datadog tag-rule update + +update a datadog tag-rule. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|datadog tag-rule|TagRules| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|update|CreateOrUpdate#Update| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group to which the Datadog resource belongs.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--rule-set-name**|string||rule_set_name|ruleSetName| +|**--metric-rules-filtering-tags**|array|List of filtering tags to be used for capturing metrics. If empty, all resources will be captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include actions are specified, the rules will only include resources with the associated tags.|filtering_tags|filteringTags| +|**--log-rules-send-aad-logs**|boolean|Flag specifying if AAD logs should be sent for the Monitor resource.|send_aad_logs|sendAadLogs| +|**--log-rules-send-subscription-logs**|boolean|Flag specifying if Azure subscription logs should be sent for the Monitor resource.|send_subscription_logs|sendSubscriptionLogs| +|**--log-rules-send-resource-logs**|boolean|Flag specifying if Azure resource logs should be sent for the Monitor resource.|send_resource_logs|sendResourceLogs| +|**--log-rules-filtering-tags**|array|List of filtering tags to be used for capturing logs. This only takes effect if SendResourceLogs flag is enabled. If empty, all resources will be captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include actions are specified, the rules will only include resources with the associated tags.|log_rules_filtering_tags|filteringTags| diff --git a/src/datadog/setup.cfg b/src/datadog/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/datadog/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/datadog/setup.py b/src/datadog/setup.py new file mode 100644 index 00000000000..5ca60f8b747 --- /dev/null +++ b/src/datadog/setup.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages + +# HISTORY.rst entry. +VERSION = '0.1.0' +try: + from azext_datadog.manual.version import VERSION +except ImportError: + pass + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] +try: + from .manual.dependency import DEPENDENCIES +except ImportError: + pass + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='datadog', + version=VERSION, + description='Microsoft Azure Command-Line Tools MicrosoftDatadogClient Extension', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/master/src/datadog', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_datadog': ['azext_metadata.json']}, +)