1# --------------------------------------------------------------------------------------------
2# Copyright (c) Microsoft Corporation. All rights reserved.
3# Licensed under the MIT License. See License.txt in the project root for license information.
4# --------------------------------------------------------------------------------------------
5
6
7# pylint: disable=unused-argument, line-too-long
8def create_diagnostics_settings(client, name, resource_uri,
9                                logs=None,
10                                metrics=None,
11                                event_hub=None,
12                                event_hub_rule=None,
13                                storage_account=None,
14                                workspace=None,
15                                export_to_resource_specific=None):
16    from azure.mgmt.monitor.models import DiagnosticSettingsResource
17    from knack.util import CLIError
18    if export_to_resource_specific and workspace is None:
19        raise CLIError('usage error: --workspace and --export-to-specific-resource')
20    parameters = DiagnosticSettingsResource(storage_account_id=storage_account,
21                                            workspace_id=workspace,
22                                            event_hub_name=event_hub,
23                                            event_hub_authorization_rule_id=event_hub_rule,
24                                            metrics=metrics,
25                                            logs=logs,
26                                            log_analytics_destination_type='Dedicated' if export_to_resource_specific else None)
27
28    return client.create_or_update(resource_uri=resource_uri, parameters=parameters, name=name)
29