# coding: utf-8
# Copyright (c) 2016, 2026, Oracle and/or its affiliates.  All rights reserved.
# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
# NOTE: This class is auto generated by OracleSDKGenerator. DO NOT EDIT. API Version: 20210201

from __future__ import print_function
import click
import oci  # noqa: F401
import six  # noqa: F401
import sys  # noqa: F401
from oci_cli.cli_root import cli
from oci_cli import cli_constants  # noqa: F401
from oci_cli import cli_util
from oci_cli import json_skeleton_utils
from oci_cli import custom_types  # noqa: F401
from oci_cli.aliasing import CommandGroupWithAlias


@cli.command(cli_util.override('apm_config.apm_config_root_group.command_name', 'apm-config'), cls=CommandGroupWithAlias, help=cli_util.override('apm_config.apm_config_root_group.help', """Use the Application Performance Monitoring Configuration API to query and set Application Performance Monitoring
configuration. For more information, see [Application Performance Monitoring]."""), short_help=cli_util.override('apm_config.apm_config_root_group.short_help', """Application Performance Monitoring Configuration API"""))
@cli_util.help_option_group
def apm_config_root_group():
    pass


@click.command(cli_util.override('apm_config.metric_group_group.command_name', 'metric-group'), cls=CommandGroupWithAlias, help="""A metric group defines a set of metrics to collect from a span. It uses a span filter to specify which spans to process. The set is then published to a namespace, which is a product level subdivision of metrics.""")
@cli_util.help_option_group
def metric_group_group():
    pass


@click.command(cli_util.override('apm_config.data_file_group.command_name', 'data-file'), cls=CommandGroupWithAlias, help="""The data file to be uploaded.""")
@cli_util.help_option_group
def data_file_group():
    pass


@click.command(cli_util.override('apm_config.import_configuration_details_group.command_name', 'import-configuration-details'), cls=CommandGroupWithAlias, help="""Array of configuration items with dependencies to import.""")
@cli_util.help_option_group
def import_configuration_details_group():
    pass


@click.command(cli_util.override('apm_config.data_file_summary_collection_group.command_name', 'data-file-summary-collection'), cls=CommandGroupWithAlias, help="""A collection of Data File summaries.""")
@cli_util.help_option_group
def data_file_summary_collection_group():
    pass


@click.command(cli_util.override('apm_config.span_filter_group.command_name', 'span-filter'), cls=CommandGroupWithAlias, help="""A named setting that specifies the filter criteria to match a subset of the spans.""")
@cli_util.help_option_group
def span_filter_group():
    pass


@click.command(cli_util.override('apm_config.config_collection_group.command_name', 'config-collection'), cls=CommandGroupWithAlias, help="""A collection of configuration items.""")
@cli_util.help_option_group
def config_collection_group():
    pass


@click.command(cli_util.override('apm_config.export_configuration_details_group.command_name', 'export-configuration-details'), cls=CommandGroupWithAlias, help="""Array of configuration items with its dependencies to export.""")
@cli_util.help_option_group
def export_configuration_details_group():
    pass


@click.command(cli_util.override('apm_config.config_group.command_name', 'config'), cls=CommandGroupWithAlias, help="""A configuration item, which has a number of mutually exclusive properties that can be used to set specific portions of the configuration.""")
@cli_util.help_option_group
def config_group():
    pass


@click.command(cli_util.override('apm_config.match_agents_with_attribute_key_group.command_name', 'match-agents-with-attribute-key'), cls=CommandGroupWithAlias, help="""The object representing the agent matching attribute keys.""")
@cli_util.help_option_group
def match_agents_with_attribute_key_group():
    pass


@click.command(cli_util.override('apm_config.test_output_group.command_name', 'test-output'), cls=CommandGroupWithAlias, help="""The result of running a test.""")
@cli_util.help_option_group
def test_output_group():
    pass


apm_config_root_group.add_command(metric_group_group)
apm_config_root_group.add_command(data_file_group)
apm_config_root_group.add_command(import_configuration_details_group)
apm_config_root_group.add_command(data_file_summary_collection_group)
apm_config_root_group.add_command(span_filter_group)
apm_config_root_group.add_command(config_collection_group)
apm_config_root_group.add_command(export_configuration_details_group)
apm_config_root_group.add_command(config_group)
apm_config_root_group.add_command(match_agents_with_attribute_key_group)
apm_config_root_group.add_command(test_output_group)


@export_configuration_details_group.command(name=cli_util.override('apm_config.copy_configuration.command_name', 'copy-configuration'), help=u"""Fast importing configuration items to a destination APM domain ID. \n[Command Reference](copyConfiguration)""")
@cli_util.option('--configuration-map', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that has parameters related to the import process (EnableOcidSubstitution, DestinationDomainID, \u2026) and more. Example: `{\"parameter-key\": \"parameter-value\"}` Supported parameters: \u2014 Enable the OCIDs in instructions to be replaced, if set to \"true\" The Config Service replace any OCIDs it finds in the instructions. \u2014 Destination APM Domain ID where the configuration Item(s) will be fast imported to. \u2014 List of Configuration Type or Groups to be fast imported. \u2014 the compartment Id we will fast import to, if the compartment Id is not provided it will be the default destination domain compartmentId.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--apm-target-domain-id', required=True, help=u"""The Target APM Domain ID the request is intended for.""")
@json_skeleton_utils.get_cli_json_input_option({'configuration-map': {'module': 'apm_config', 'class': 'dict(str, string)'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'configuration-map': {'module': 'apm_config', 'class': 'dict(str, string)'}}, output_type={'module': 'apm_config', 'class': 'ImportConfigurationFailedItemsCollection'})
@cli_util.wrap_exceptions
def copy_configuration(ctx, from_json, configuration_map, apm_domain_id, apm_target_domain_id):

    kwargs = {}
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['configurationMap'] = cli_util.parse_json_parameter("configuration_map", configuration_map)

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.copy_configuration(
        apm_domain_id=apm_domain_id,
        apm_target_domain_id=apm_target_domain_id,
        copy_configuration_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.create_config.command_name', 'create'), help=u"""Creates a new configuration item. \n[Command Reference](createConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--config-type', required=True, type=custom_types.CliCaseInsensitiveChoice(["SPAN_FILTER", "METRIC_GROUP", "APDEX", "OPTIONS", "AGENT", "MACS_APM_EXTENSION"]), help=u"""The type of configuration item.""")
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def create_config(ctx, from_json, apm_domain_id, config_type, freeform_tags, defined_tags, opc_dry_run):

    kwargs = {}
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['configType'] = config_type

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.create_config(
        apm_domain_id=apm_domain_id,
        create_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.create_config_create_span_filter_details.command_name', 'create-config-create-span-filter-details'), help=u"""Creates a new configuration item. \n[Command Reference](createConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--display-name', required=True, help=u"""The name by which a configuration entity is displayed to the end user.""")
@cli_util.option('--filter-text', required=True, help=u"""The string that defines the Span Filter expression.""")
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--description', help=u"""An optional string that describes what the filter is intended or used for.""")
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def create_config_create_span_filter_details(ctx, from_json, apm_domain_id, display_name, filter_text, freeform_tags, defined_tags, description, opc_dry_run):

    kwargs = {}
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['displayName'] = display_name
    _details['filterText'] = filter_text

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    if description is not None:
        _details['description'] = description

    _details['configType'] = 'SPAN_FILTER'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.create_config(
        apm_domain_id=apm_domain_id,
        create_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.create_config_create_metric_group_details.command_name', 'create-config-create-metric-group-details'), help=u"""Creates a new configuration item. \n[Command Reference](createConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--display-name', required=True, help=u"""The name by which a configuration entity is displayed to the end user.""")
@cli_util.option('--filter-id', required=True, help=u"""The [OCID] of a Span Filter. The filterId is mandatory for the creation of MetricGroups. A filterId is generated when a Span Filter is created.""")
@cli_util.option('--metrics', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of metrics in this group.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--namespace', help=u"""The namespace to which the metrics are published. It must be one of several predefined namespaces.""")
@cli_util.option('--dimensions', type=custom_types.CLI_COMPLEX_TYPE, help=u"""A list of dimensions for the metric. This variable should not be used.

This option is a JSON list with items of type Dimension.  For documentation on Dimension please see our API reference: https://docs.oracle.com/en-us/iaas/api/#/en/config/20210201/datatypes/Dimension.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'dimensions': {'module': 'apm_config', 'class': 'list[Dimension]'}, 'metrics': {'module': 'apm_config', 'class': 'list[Metric]'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'dimensions': {'module': 'apm_config', 'class': 'list[Dimension]'}, 'metrics': {'module': 'apm_config', 'class': 'list[Metric]'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def create_config_create_metric_group_details(ctx, from_json, apm_domain_id, display_name, filter_id, metrics, freeform_tags, defined_tags, namespace, dimensions, opc_dry_run):

    kwargs = {}
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['displayName'] = display_name
    _details['filterId'] = filter_id
    _details['metrics'] = cli_util.parse_json_parameter("metrics", metrics)

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    if namespace is not None:
        _details['namespace'] = namespace

    if dimensions is not None:
        _details['dimensions'] = cli_util.parse_json_parameter("dimensions", dimensions)

    _details['configType'] = 'METRIC_GROUP'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.create_config(
        apm_domain_id=apm_domain_id,
        create_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.create_config_create_agent_config_details.command_name', 'create-config-create-agent-config-details'), help=u"""Creates a new configuration item. \n[Command Reference](createConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--match-agents-with-attribute-value', required=True, help=u"""The agent attribute VALUE by which an agent configuration is matched to an agent. Each agent configuration object must specify a different value. The attribute KEY corresponding to this VALUE is in the matchAgentsWithAttributeKey field.""")
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--config', type=custom_types.CLI_COMPLEX_TYPE, help=u"""""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--overrides', type=custom_types.CLI_COMPLEX_TYPE, help=u"""""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'config': {'module': 'apm_config', 'class': 'AgentConfigMap'}, 'overrides': {'module': 'apm_config', 'class': 'AgentConfigOverrides'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'config': {'module': 'apm_config', 'class': 'AgentConfigMap'}, 'overrides': {'module': 'apm_config', 'class': 'AgentConfigOverrides'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def create_config_create_agent_config_details(ctx, from_json, apm_domain_id, match_agents_with_attribute_value, freeform_tags, defined_tags, config, overrides, opc_dry_run):

    kwargs = {}
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['matchAgentsWithAttributeValue'] = match_agents_with_attribute_value

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    if config is not None:
        _details['config'] = cli_util.parse_json_parameter("config", config)

    if overrides is not None:
        _details['overrides'] = cli_util.parse_json_parameter("overrides", overrides)

    _details['configType'] = 'AGENT'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.create_config(
        apm_domain_id=apm_domain_id,
        create_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.create_config_create_options_details.command_name', 'create-config-create-options-details'), help=u"""Creates a new configuration item. \n[Command Reference](createConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--display-name', help=u"""The name by which a configuration entity is displayed to the end user.""")
@cli_util.option('--options', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The options are stored here as JSON.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--group', help=u"""A string that specifies the group that an OPTIONS item belongs to.""")
@cli_util.option('--description', help=u"""An optional string that describes what the options are intended or used for.""")
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'options': {'module': 'apm_config', 'class': 'object'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'options': {'module': 'apm_config', 'class': 'object'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def create_config_create_options_details(ctx, from_json, apm_domain_id, freeform_tags, defined_tags, display_name, options, group, description, opc_dry_run):

    kwargs = {}
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    if display_name is not None:
        _details['displayName'] = display_name

    if options is not None:
        _details['options'] = cli_util.parse_json_parameter("options", options)

    if group is not None:
        _details['group'] = group

    if description is not None:
        _details['description'] = description

    _details['configType'] = 'OPTIONS'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.create_config(
        apm_domain_id=apm_domain_id,
        create_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.create_config_create_macs_apm_extension_details.command_name', 'create-config-create-macs-apm-extension-details'), help=u"""Creates a new configuration item. \n[Command Reference](createConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--management-agent-id', required=True, help=u"""The [OCID] of the Management Agent that will provision the APM Agent.""")
@cli_util.option('--process-filter', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""Filter patterns used to discover active Java processes for provisioning the APM Agent.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--run-as-user', required=True, help=u"""The OS user that should be used to discover Java processes.""")
@cli_util.option('--service-name', required=True, help=u"""The name of the service being monitored. This argument enables you to filter by service and view traces and other signals in the APM Explorer user interface.""")
@cli_util.option('--agent-version', required=True, help=u"""The version of the referenced agent bundle.""")
@cli_util.option('--attach-install-dir', required=True, help=u"""The directory owned by runAsUser.""")
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--display-name', help=u"""The name by which a configuration entity is displayed to the end user.""")
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'process-filter': {'module': 'apm_config', 'class': 'list[string]'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'process-filter': {'module': 'apm_config', 'class': 'list[string]'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def create_config_create_macs_apm_extension_details(ctx, from_json, apm_domain_id, management_agent_id, process_filter, run_as_user, service_name, agent_version, attach_install_dir, freeform_tags, defined_tags, display_name, opc_dry_run):

    kwargs = {}
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['managementAgentId'] = management_agent_id
    _details['processFilter'] = cli_util.parse_json_parameter("process_filter", process_filter)
    _details['runAsUser'] = run_as_user
    _details['serviceName'] = service_name
    _details['agentVersion'] = agent_version
    _details['attachInstallDir'] = attach_install_dir

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    if display_name is not None:
        _details['displayName'] = display_name

    _details['configType'] = 'MACS_APM_EXTENSION'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.create_config(
        apm_domain_id=apm_domain_id,
        create_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.create_config_create_apdex_rules_details.command_name', 'create-config-create-apdex-rules-details'), help=u"""Creates a new configuration item. \n[Command Reference](createConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--rules', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--display-name', required=True, help=u"""The name by which a configuration entity is displayed to the end user.""")
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'rules': {'module': 'apm_config', 'class': 'list[Apdex]'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'rules': {'module': 'apm_config', 'class': 'list[Apdex]'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def create_config_create_apdex_rules_details(ctx, from_json, apm_domain_id, rules, display_name, freeform_tags, defined_tags, opc_dry_run):

    kwargs = {}
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['rules'] = cli_util.parse_json_parameter("rules", rules)
    _details['displayName'] = display_name

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    _details['configType'] = 'APDEX'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.create_config(
        apm_domain_id=apm_domain_id,
        create_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.delete_config.command_name', 'delete'), help=u"""Deletes the configuration item identified by the OCID. \n[Command Reference](deleteConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--config-id', required=True, help=u"""The [OCID] of the configuration item.""")
@cli_util.option('--if-match', help=u"""For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.""")
@cli_util.confirm_delete_option
@json_skeleton_utils.get_cli_json_input_option({})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={})
@cli_util.wrap_exceptions
def delete_config(ctx, from_json, apm_domain_id, config_id, if_match):

    if isinstance(config_id, six.string_types) and len(config_id.strip()) == 0:
        raise click.UsageError('Parameter --config-id cannot be whitespace or empty string')

    kwargs = {}
    if if_match is not None:
        kwargs['if_match'] = if_match
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.delete_config(
        apm_domain_id=apm_domain_id,
        config_id=config_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@data_file_group.command(name=cli_util.override('apm_config.delete_data_file.command_name', 'delete'), help=u"""Removes the data file. \n[Command Reference](deleteDataFile)""")
@cli_util.option('--data-file-name', required=True, help=u"""The name of the data file.""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--apm-type', required=True, help=u"""The type of the data file.""")
@cli_util.option('--if-match', help=u"""For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.""")
@cli_util.confirm_delete_option
@json_skeleton_utils.get_cli_json_input_option({})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={})
@cli_util.wrap_exceptions
def delete_data_file(ctx, from_json, data_file_name, apm_domain_id, apm_type, if_match):

    if isinstance(data_file_name, six.string_types) and len(data_file_name.strip()) == 0:
        raise click.UsageError('Parameter --data-file-name cannot be whitespace or empty string')

    kwargs = {}
    if if_match is not None:
        kwargs['if_match'] = if_match
    kwargs['opc_client_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.delete_data_file(
        data_file_name=data_file_name,
        apm_domain_id=apm_domain_id,
        apm_type=apm_type,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@export_configuration_details_group.command(name=cli_util.override('apm_config.export_configuration.command_name', 'export-configuration'), help=u"""Exports configurations for the whole domain by domainId. \n[Command Reference](exportConfiguration)""")
@cli_util.option('--configuration-map', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that has parameters related to the export process (ConfigurationId, Skip, \u2026) and more. Example: `{\"parameter-key\": \"parameter-value\"}` Supported parameters: \u2014 List of the Configuration Type or Groups to Export to a destination domain.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@json_skeleton_utils.get_cli_json_input_option({'configuration-map': {'module': 'apm_config', 'class': 'dict(str, string)'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'configuration-map': {'module': 'apm_config', 'class': 'dict(str, string)'}}, output_type={'module': 'apm_config', 'class': 'ExportConfigurationResponseDetails'})
@cli_util.wrap_exceptions
def export_configuration(ctx, from_json, configuration_map, apm_domain_id):

    kwargs = {}
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['configurationMap'] = cli_util.parse_json_parameter("configuration_map", configuration_map)

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.export_configuration(
        apm_domain_id=apm_domain_id,
        export_configuration_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.get_config.command_name', 'get'), help=u"""Gets the configuration item identified by the OCID. \n[Command Reference](getConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--config-id', required=True, help=u"""The [OCID] of the configuration item.""")
@json_skeleton_utils.get_cli_json_input_option({})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def get_config(ctx, from_json, apm_domain_id, config_id):

    if isinstance(config_id, six.string_types) and len(config_id.strip()) == 0:
        raise click.UsageError('Parameter --config-id cannot be whitespace or empty string')

    kwargs = {}
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.get_config(
        apm_domain_id=apm_domain_id,
        config_id=config_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@data_file_group.command(name=cli_util.override('apm_config.get_data_file.command_name', 'get'), help=u"""Retrieves the Data file with the specified name and type. \n[Command Reference](getDataFile)""")
@cli_util.option('--data-file-name', required=True, help=u"""The name of the data file.""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--apm-type', required=True, help=u"""The type of the data file.""")
@cli_util.option('--file', type=click.File(mode='wb'), required=True, help="The name of the file that will receive the response data, or '-' to write to STDOUT.")
@json_skeleton_utils.get_cli_json_input_option({})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={})
@cli_util.wrap_exceptions
def get_data_file(ctx, from_json, file, data_file_name, apm_domain_id, apm_type):

    if isinstance(data_file_name, six.string_types) and len(data_file_name.strip()) == 0:
        raise click.UsageError('Parameter --data-file-name cannot be whitespace or empty string')

    kwargs = {}
    kwargs['opc_client_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.get_data_file(
        data_file_name=data_file_name,
        apm_domain_id=apm_domain_id,
        apm_type=apm_type,
        **kwargs
    )

    # If outputting to stdout we don't want to print a progress bar because it will get mixed up with the output
    # Also we need a non-zero Content-Length in order to display a meaningful progress bar
    bar = None
    if hasattr(file, 'name') and file.name != '<stdout>' and 'Content-Length' in result.headers:
        content_length = int(result.headers['Content-Length'])
        if content_length > 0:
            bar = click.progressbar(length=content_length, label='Downloading file')

    try:
        if bar:
            bar.__enter__()

        # TODO: Make the download size a configurable option
        # use decode_content=True to automatically unzip service responses (this should be overridden for object storage)
        for chunk in result.data.raw.stream(cli_constants.MEBIBYTE, decode_content=True):
            if bar:
                bar.update(len(chunk))
            file.write(chunk)
    finally:
        if bar:
            bar.render_finish()
        file.close()


@match_agents_with_attribute_key_group.command(name=cli_util.override('apm_config.get_match_agents_with_attribute_key.command_name', 'get'), help=u"""The domain-wide agents matching attribute key. \n[Command Reference](getMatchAgentsWithAttributeKey)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@json_skeleton_utils.get_cli_json_input_option({})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}, output_type={'module': 'apm_config', 'class': 'MatchAgentsWithAttributeKey'})
@cli_util.wrap_exceptions
def get_match_agents_with_attribute_key(ctx, from_json, apm_domain_id):

    kwargs = {}
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.get_match_agents_with_attribute_key(
        apm_domain_id=apm_domain_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@data_file_group.command(name=cli_util.override('apm_config.head_data_file.command_name', 'head'), help=u"""Returns metadata about the datafile. \n[Command Reference](headDataFile)""")
@cli_util.option('--data-file-name', required=True, help=u"""The name of the data file.""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--apm-type', required=True, help=u"""The type of the data file.""")
@json_skeleton_utils.get_cli_json_input_option({})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={})
@cli_util.wrap_exceptions
def head_data_file(ctx, from_json, data_file_name, apm_domain_id, apm_type):

    if isinstance(data_file_name, six.string_types) and len(data_file_name.strip()) == 0:
        raise click.UsageError('Parameter --data-file-name cannot be whitespace or empty string')

    kwargs = {}
    kwargs['opc_client_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.head_data_file(
        data_file_name=data_file_name,
        apm_domain_id=apm_domain_id,
        apm_type=apm_type,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@import_configuration_details_group.command(name=cli_util.override('apm_config.import_configuration.command_name', 'import-configuration'), help=u"""Import configurations Item(s) with its dependencies into a destination domain. \n[Command Reference](importConfiguration)""")
@cli_util.option('--configuration-items', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""A list of Configurations Details .""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--configuration-map', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that has parameters related to the import process (EnableOcidSubstitution, Skip, \u2026) and more. Example: `{\"parameter-key\": \"parameter-value\"}` Supported parameters: \u2014 Enable the OCIDs in instructions to be replaced, if set to \"true\" The Config Service replace any OCIDs it finds in the instructions, if set to true the Config Service will replace. \u2014 Compartment Id we want to import the configuration Items, if the compartment Id is not provided it will be the default destination domain compartmentId.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@json_skeleton_utils.get_cli_json_input_option({'configuration-items': {'module': 'apm_config', 'class': 'list[ExportImportConfigSummary]'}, 'configuration-map': {'module': 'apm_config', 'class': 'dict(str, string)'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'configuration-items': {'module': 'apm_config', 'class': 'list[ExportImportConfigSummary]'}, 'configuration-map': {'module': 'apm_config', 'class': 'dict(str, string)'}}, output_type={'module': 'apm_config', 'class': 'ImportConfigurationFailedItemsCollection'})
@cli_util.wrap_exceptions
def import_configuration(ctx, from_json, configuration_items, configuration_map, apm_domain_id):

    kwargs = {}
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['configurationItems'] = cli_util.parse_json_parameter("configuration_items", configuration_items)
    _details['configurationMap'] = cli_util.parse_json_parameter("configuration_map", configuration_map)

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.import_configuration(
        apm_domain_id=apm_domain_id,
        import_configuration_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_collection_group.command(name=cli_util.override('apm_config.list_configs.command_name', 'list-configs'), help=u"""Returns all configuration items, which can optionally be filtered by configuration type. \n[Command Reference](listConfigs)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--config-type', help=u"""A filter to match configuration items of a given type. Supported values are SPAN_FILTER, METRIC_GROUP, APDEX, AGENT and MACS_APM_EXTENSION.""")
@cli_util.option('--display-name', help=u"""A filter to return resources that match the given display name.""")
@cli_util.option('--limit', type=click.INT, help=u"""The maximum number of items to return.""")
@cli_util.option('--page', help=u"""The maximum number of results per page, or items to return in a paginated \"List\" call. For information on how pagination works, see [List Pagination]. Example: `50`""")
@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The displayName sort order is case-sensitive.""")
@cli_util.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["displayName", "timeCreated", "timeUpdated"]), help=u"""The field to sort by. You can provide one \"sortBy\" value. The default order for displayName, timeCreated and timeUpdated is ascending. The displayName sort by is case-sensitive.""")
@cli_util.option('--options-group', help=u"""A filter to return OPTIONS resources that match the given group.""")
@cli_util.option('--defined-tag-equals', multiple=True, help=u"""A list of tag filters to apply.  Only resources with a defined tag matching the value will be returned. Each item in the list has the format \"{namespace}.{tagName}.{value}\".  All inputs are case-insensitive. Multiple values for the same key (i.e. same namespace and tag name) are interpreted as \"OR\". Values for different keys (i.e. different namespaces, different tag names, or both) are interpreted as \"AND\".""")
@cli_util.option('--freeform-tag-equals', multiple=True, help=u"""A list of tag filters to apply.  Only resources with a freeform tag matching the value will be returned. The key for each tag is \"{tagName}.{value}\".  All inputs are case-insensitive. Multiple values for the same tag name are interpreted as \"OR\".  Values for different tag names are interpreted as \"AND\".""")
@cli_util.option('--defined-tag-exists', multiple=True, help=u"""A list of tag existence filters to apply.  Only resources for which the specified defined tags exist will be returned. Each item in the list has the format \"{namespace}.{tagName}.true\" (for checking existence of a defined tag) or \"{namespace}.true\".  All inputs are case-insensitive. Currently, only existence (\"true\" at the end) is supported. Absence (\"false\" at the end) is not supported. Multiple values for the same key (i.e. same namespace and tag name) are interpreted as \"OR\". Values for different keys (i.e. different namespaces, different tag names, or both) are interpreted as \"AND\".""")
@cli_util.option('--freeform-tag-exists', multiple=True, help=u"""A list of tag existence filters to apply.  Only resources for which the specified freeform tags exist the value will be returned. The key for each tag is \"{tagName}.true\".  All inputs are case-insensitive. Currently, only existence (\"true\" at the end) is supported. Absence (\"false\" at the end) is not supported. Multiple values for different tag names are interpreted as \"AND\".""")
@cli_util.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""")
@cli_util.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""")
@json_skeleton_utils.get_cli_json_input_option({'defined-tag-equals': {'module': 'apm_config', 'class': 'list[string]'}, 'freeform-tag-equals': {'module': 'apm_config', 'class': 'list[string]'}, 'defined-tag-exists': {'module': 'apm_config', 'class': 'list[string]'}, 'freeform-tag-exists': {'module': 'apm_config', 'class': 'list[string]'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'defined-tag-equals': {'module': 'apm_config', 'class': 'list[string]'}, 'freeform-tag-equals': {'module': 'apm_config', 'class': 'list[string]'}, 'defined-tag-exists': {'module': 'apm_config', 'class': 'list[string]'}, 'freeform-tag-exists': {'module': 'apm_config', 'class': 'list[string]'}}, output_type={'module': 'apm_config', 'class': 'ConfigCollection'})
@cli_util.wrap_exceptions
def list_configs(ctx, from_json, all_pages, page_size, apm_domain_id, config_type, display_name, limit, page, sort_order, sort_by, options_group, defined_tag_equals, freeform_tag_equals, defined_tag_exists, freeform_tag_exists):

    if all_pages and limit:
        raise click.UsageError('If you provide the --all option you cannot provide the --limit option')

    kwargs = {}
    if config_type is not None:
        kwargs['config_type'] = config_type
    if display_name is not None:
        kwargs['display_name'] = display_name
    if limit is not None:
        kwargs['limit'] = limit
    if page is not None:
        kwargs['page'] = page
    if sort_order is not None:
        kwargs['sort_order'] = sort_order
    if sort_by is not None:
        kwargs['sort_by'] = sort_by
    if options_group is not None:
        kwargs['options_group'] = options_group
    if defined_tag_equals is not None and len(defined_tag_equals) > 0:
        kwargs['defined_tag_equals'] = defined_tag_equals
    if freeform_tag_equals is not None and len(freeform_tag_equals) > 0:
        kwargs['freeform_tag_equals'] = freeform_tag_equals
    if defined_tag_exists is not None and len(defined_tag_exists) > 0:
        kwargs['defined_tag_exists'] = defined_tag_exists
    if freeform_tag_exists is not None and len(freeform_tag_exists) > 0:
        kwargs['freeform_tag_exists'] = freeform_tag_exists
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('apm_config', 'config', ctx)
    if all_pages:
        if page_size:
            kwargs['limit'] = page_size

        result = cli_util.list_call_get_all_results(
            client.list_configs,
            apm_domain_id=apm_domain_id,
            **kwargs
        )
    elif limit is not None:
        result = cli_util.list_call_get_up_to_limit(
            client.list_configs,
            limit,
            page_size,
            apm_domain_id=apm_domain_id,
            **kwargs
        )
    else:
        result = client.list_configs(
            apm_domain_id=apm_domain_id,
            **kwargs
        )
    cli_util.render_response(result, ctx)


@data_file_summary_collection_group.command(name=cli_util.override('apm_config.list_data_files.command_name', 'list-data-files'), help=u"""Fetches a list of Data files using some parameters. \n[Command Reference](listDataFiles)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--apm-type', help=u"""The type of the data file.""")
@cli_util.option('--name', help=u"""A filter to return resources that match the specified name. Supports regular expressions to filter data files.""")
@cli_util.option('--time-last-modified-before', type=custom_types.CLI_DATETIME, help=u"""Return data files with time 'timeLastModified' before the specified time, expressed in [RFC 3339] timestamp format. Example: `2020-02-19T22:47:12.613Z`""" + custom_types.CLI_DATETIME.VALID_DATETIME_CLI_HELP_MESSAGE)
@cli_util.option('--time-last-modified-after', type=custom_types.CLI_DATETIME, help=u"""Return data files with the 'timeLastModified' after the specified time, expressed in [RFC 3339] timestamp format. Example: `2020-02-19T22:47:12.613Z`""" + custom_types.CLI_DATETIME.VALID_DATETIME_CLI_HELP_MESSAGE)
@cli_util.option('--limit', type=click.INT, help=u"""The maximum number of items to return.""")
@cli_util.option('--page', help=u"""The maximum number of results per page, or items to return in a paginated \"List\" call. For information on how pagination works, see [List Pagination]. Example: `50`""")
@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order to use, either ascending (`ASC`) or descending (`DESC`). The displayName sort order is case-sensitive.""")
@cli_util.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["displayName", "timeCreated", "timeUpdated"]), help=u"""The field to sort by. You can provide one \"sortBy\" value. The default order for displayName, timeCreated and timeUpdated is ascending. The displayName sort by is case-sensitive.""")
@cli_util.option('--metadata', help=u"""A string containing a JSON-encoded object with metadata related to the uploaded file or resource. Example:   {\"fileName\":\"report.pdf\",\"uploader\":\"jane.doe\",\"category\":\"financial\"}""")
@cli_util.option('--all', 'all_pages', is_flag=True, help="""Fetches all pages of results. If you provide this option, then you cannot provide the --limit option.""")
@cli_util.option('--page-size', type=click.INT, help="""When fetching results, the number of results to fetch per call. Only valid when used with --all or --limit, and ignored otherwise.""")
@json_skeleton_utils.get_cli_json_input_option({})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}, output_type={'module': 'apm_config', 'class': 'DataFileSummaryCollection'})
@cli_util.wrap_exceptions
def list_data_files(ctx, from_json, all_pages, page_size, apm_domain_id, apm_type, name, time_last_modified_before, time_last_modified_after, limit, page, sort_order, sort_by, metadata):

    if all_pages and limit:
        raise click.UsageError('If you provide the --all option you cannot provide the --limit option')

    kwargs = {}
    if apm_type is not None:
        kwargs['apm_type'] = apm_type
    if name is not None:
        kwargs['name'] = name
    if time_last_modified_before is not None:
        kwargs['time_last_modified_before'] = time_last_modified_before
    if time_last_modified_after is not None:
        kwargs['time_last_modified_after'] = time_last_modified_after
    if limit is not None:
        kwargs['limit'] = limit
    if page is not None:
        kwargs['page'] = page
    if sort_order is not None:
        kwargs['sort_order'] = sort_order
    if sort_by is not None:
        kwargs['sort_by'] = sort_by
    if metadata is not None:
        kwargs['metadata'] = metadata
    kwargs['opc_client_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('apm_config', 'config', ctx)
    if all_pages:
        if page_size:
            kwargs['limit'] = page_size

        result = cli_util.list_call_get_all_results(
            client.list_data_files,
            apm_domain_id=apm_domain_id,
            **kwargs
        )
    elif limit is not None:
        result = cli_util.list_call_get_up_to_limit(
            client.list_data_files,
            limit,
            page_size,
            apm_domain_id=apm_domain_id,
            **kwargs
        )
    else:
        result = client.list_data_files(
            apm_domain_id=apm_domain_id,
            **kwargs
        )
    cli_util.render_response(result, ctx)


@data_file_group.command(name=cli_util.override('apm_config.put_data_file.command_name', 'put'), help=u"""Creates a new data file or replaces an existing one with the same name and type. \n[Command Reference](putDataFile)""")
@cli_util.option('--put-data-file-body', required=True, help=u"""The data file to be uploaded.""")
@cli_util.option('--data-file-name', required=True, help=u"""The name of the data file.""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--apm-type', required=True, help=u"""The type of the data file.""")
@cli_util.option('--content-md5', help=u"""Optional base64-encoded MD5 hash of the request body. If provided, the server will perform a data integrity check by computing the MD5 of the received content and comparing it to the supplied value.

If the values do not match, the request will be rejected with an HTTP 400 error and a message such as:

\"The computed MD5 of the request body (ACTUAL_MD5) does not match the Content-MD5 header (HEADER_MD5)\"""")
@cli_util.option('--content-type', help=u"""Optional parameter specifying the media type (MIME type) of the request or response body. If not specified, the default is `application/octet-stream`.

This value can be used by recipients to determine how to interpret or render the content.""")
@cli_util.option('--content-language', help=u"""Optional parameter that indicates the natural language of the content. This value can be used by clients or intermediaries to select or display content based on language preferences.""")
@cli_util.option('--content-encoding', help=u"""Optional parameter indicating the content encodings applied to the request body (e.g., gzip, deflate). This value can be used by recipients to determine how to decode the content.""")
@cli_util.option('--content-disposition', help=u"""Optional parameter that provides presentation information for how the content should be displayed or handled by the recipient.

For example, to prompt a file download with a custom filename: `attachment; filename=\"example.txt\"`""")
@cli_util.option('--metadata', help=u"""A string containing a JSON-encoded object with metadata related to the uploaded file or resource. Example:   {\"fileName\":\"report.pdf\",\"uploader\":\"jane.doe\",\"category\":\"financial\"}""")
@json_skeleton_utils.get_cli_json_input_option({})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={})
@cli_util.wrap_exceptions
def put_data_file(ctx, from_json, put_data_file_body, data_file_name, apm_domain_id, apm_type, content_md5, content_type, content_language, content_encoding, content_disposition, metadata):

    if isinstance(data_file_name, six.string_types) and len(data_file_name.strip()) == 0:
        raise click.UsageError('Parameter --data-file-name cannot be whitespace or empty string')

    kwargs = {}
    if content_md5 is not None:
        kwargs['content_md5'] = content_md5
    if content_type is not None:
        kwargs['content_type'] = content_type
    if content_language is not None:
        kwargs['content_language'] = content_language
    if content_encoding is not None:
        kwargs['content_encoding'] = content_encoding
    if content_disposition is not None:
        kwargs['content_disposition'] = content_disposition
    if metadata is not None:
        kwargs['metadata'] = metadata
    kwargs['opc_client_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    # do not automatically retry operations with binary inputs
    kwargs['retry_strategy'] = oci.retry.NoneRetryStrategy()

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.put_data_file(
        put_data_file_body=put_data_file_body,
        data_file_name=data_file_name,
        apm_domain_id=apm_domain_id,
        apm_type=apm_type,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@metric_group_group.command(name=cli_util.override('apm_config.retrieve_namespace_metrics.command_name', 'retrieve-namespace-metrics'), help=u"""Returns all metrics associated with the specified namespace. \n[Command Reference](retrieveNamespaceMetrics)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--name', required=True, help=u"""Name of the namespace.""")
@json_skeleton_utils.get_cli_json_input_option({})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}, output_type={'module': 'apm_config', 'class': 'NamespaceMetricCollection'})
@cli_util.wrap_exceptions
def retrieve_namespace_metrics(ctx, from_json, apm_domain_id, name):

    kwargs = {}
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['name'] = name

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.retrieve_namespace_metrics(
        apm_domain_id=apm_domain_id,
        retrieve_namespace_metrics_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@metric_group_group.command(name=cli_util.override('apm_config.retrieve_namespaces.command_name', 'retrieve-namespaces'), help=u"""Returns all namespaces available in APM. \n[Command Reference](retrieveNamespaces)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@json_skeleton_utils.get_cli_json_input_option({})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}, output_type={'module': 'apm_config', 'class': 'NamespaceCollection'})
@cli_util.wrap_exceptions
def retrieve_namespaces(ctx, from_json, apm_domain_id):

    kwargs = {}
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.retrieve_namespaces(
        apm_domain_id=apm_domain_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@test_output_group.command(name=cli_util.override('apm_config.test.command_name', 'test'), help=u"""Tests a data processing operation on the provided input, returning the potentially modified input as output. Returns 200 on success, 422 when the input can not be processed. \n[Command Reference](test)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--test-type', required=True, type=custom_types.CliCaseInsensitiveChoice(["SPAN_ENRICHMENT"]), help=u"""The kind of test to run.""")
@json_skeleton_utils.get_cli_json_input_option({})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={}, output_type={'module': 'apm_config', 'class': 'TestOutput'})
@cli_util.wrap_exceptions
def test(ctx, from_json, apm_domain_id, test_type):

    kwargs = {}
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['testType'] = test_type

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.test(
        apm_domain_id=apm_domain_id,
        test_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@test_output_group.command(name=cli_util.override('apm_config.test_test_span_enrichment_details.command_name', 'test-test-span-enrichment-details'), help=u"""Tests a data processing operation on the provided input, returning the potentially modified input as output. Returns 200 on success, 422 when the input can not be processed. \n[Command Reference](test)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--options', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""The span enrichment rules to test in the format of an Options resource.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--span', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""The span to test the rules on. This should be a valid JSON object that follows one of the formats used by distributed tracing frameworks, such as OpenTelemetry, Zipkin, or Oracle Application Performance Monitoring.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--filters', type=custom_types.CLI_COMPLEX_TYPE, help=u"""A list of filters to try against the given span.

This option is a JSON list with items of type FilterTextOrId.  For documentation on FilterTextOrId please see our API reference: https://docs.oracle.com/en-us/iaas/api/#/en/config/20210201/datatypes/FilterTextOrId.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@json_skeleton_utils.get_cli_json_input_option({'options': {'module': 'apm_config', 'class': 'object'}, 'filters': {'module': 'apm_config', 'class': 'list[FilterTextOrId]'}, 'span': {'module': 'apm_config', 'class': 'object'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'options': {'module': 'apm_config', 'class': 'object'}, 'filters': {'module': 'apm_config', 'class': 'list[FilterTextOrId]'}, 'span': {'module': 'apm_config', 'class': 'object'}}, output_type={'module': 'apm_config', 'class': 'TestOutput'})
@cli_util.wrap_exceptions
def test_test_span_enrichment_details(ctx, from_json, apm_domain_id, options, span, filters):

    kwargs = {}
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['options'] = cli_util.parse_json_parameter("options", options)
    _details['span'] = cli_util.parse_json_parameter("span", span)

    if filters is not None:
        _details['filters'] = cli_util.parse_json_parameter("filters", filters)

    _details['testType'] = 'SPAN_ENRICHMENT'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.test(
        apm_domain_id=apm_domain_id,
        test_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.update_config.command_name', 'update'), help=u"""Updates the details of the configuration item identified by the OCID. \n[Command Reference](updateConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--config-id', required=True, help=u"""The [OCID] of the configuration item.""")
@cli_util.option('--config-type', required=True, type=custom_types.CliCaseInsensitiveChoice(["SPAN_FILTER", "METRIC_GROUP", "APDEX", "OPTIONS", "AGENT", "MACS_APM_EXTENSION"]), help=u"""The type of configuration item.""")
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--if-match', help=u"""For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.""")
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@cli_util.option('--force', help="""Perform update without prompting for confirmation.""", is_flag=True)
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def update_config(ctx, from_json, force, apm_domain_id, config_id, config_type, freeform_tags, defined_tags, if_match, opc_dry_run):

    if isinstance(config_id, six.string_types) and len(config_id.strip()) == 0:
        raise click.UsageError('Parameter --config-id cannot be whitespace or empty string')
    if not force:
        if freeform_tags or defined_tags:
            if not click.confirm("WARNING: Updates to freeform-tags and defined-tags will replace any existing values. Are you sure you want to continue?"):
                ctx.abort()

    kwargs = {}
    if if_match is not None:
        kwargs['if_match'] = if_match
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['configType'] = config_type

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.update_config(
        apm_domain_id=apm_domain_id,
        config_id=config_id,
        update_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.update_config_update_metric_group_details.command_name', 'update-config-update-metric-group-details'), help=u"""Updates the details of the configuration item identified by the OCID. \n[Command Reference](updateConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--config-id', required=True, help=u"""The [OCID] of the configuration item.""")
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--display-name', help=u"""The name by which a configuration entity is displayed to the end user.""")
@cli_util.option('--filter-id', help=u"""The [OCID] of a Span Filter. The filterId is mandatory for the creation of MetricGroups. A filterId is generated when a Span Filter is created.""")
@cli_util.option('--namespace', help=u"""The namespace to which the metrics are published. It must be one of several predefined namespaces.""")
@cli_util.option('--dimensions', type=custom_types.CLI_COMPLEX_TYPE, help=u"""A list of dimensions for the metric. This variable should not be used.

This option is a JSON list with items of type Dimension.  For documentation on Dimension please see our API reference: https://docs.oracle.com/en-us/iaas/api/#/en/config/20210201/datatypes/Dimension.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--metrics', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of metrics in this group.

This option is a JSON list with items of type Metric.  For documentation on Metric please see our API reference: https://docs.oracle.com/en-us/iaas/api/#/en/config/20210201/datatypes/Metric.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--if-match', help=u"""For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.""")
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@cli_util.option('--force', help="""Perform update without prompting for confirmation.""", is_flag=True)
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'dimensions': {'module': 'apm_config', 'class': 'list[Dimension]'}, 'metrics': {'module': 'apm_config', 'class': 'list[Metric]'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'dimensions': {'module': 'apm_config', 'class': 'list[Dimension]'}, 'metrics': {'module': 'apm_config', 'class': 'list[Metric]'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def update_config_update_metric_group_details(ctx, from_json, force, apm_domain_id, config_id, freeform_tags, defined_tags, display_name, filter_id, namespace, dimensions, metrics, if_match, opc_dry_run):

    if isinstance(config_id, six.string_types) and len(config_id.strip()) == 0:
        raise click.UsageError('Parameter --config-id cannot be whitespace or empty string')
    if not force:
        if freeform_tags or defined_tags or dimensions or metrics:
            if not click.confirm("WARNING: Updates to freeform-tags and defined-tags and dimensions and metrics will replace any existing values. Are you sure you want to continue?"):
                ctx.abort()

    kwargs = {}
    if if_match is not None:
        kwargs['if_match'] = if_match
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    if display_name is not None:
        _details['displayName'] = display_name

    if filter_id is not None:
        _details['filterId'] = filter_id

    if namespace is not None:
        _details['namespace'] = namespace

    if dimensions is not None:
        _details['dimensions'] = cli_util.parse_json_parameter("dimensions", dimensions)

    if metrics is not None:
        _details['metrics'] = cli_util.parse_json_parameter("metrics", metrics)

    _details['configType'] = 'METRIC_GROUP'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.update_config(
        apm_domain_id=apm_domain_id,
        config_id=config_id,
        update_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.update_config_update_agent_config_details.command_name', 'update-config-update-agent-config-details'), help=u"""Updates the details of the configuration item identified by the OCID. \n[Command Reference](updateConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--config-id', required=True, help=u"""The [OCID] of the configuration item.""")
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--config', type=custom_types.CLI_COMPLEX_TYPE, help=u"""""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--overrides', type=custom_types.CLI_COMPLEX_TYPE, help=u"""""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--if-match', help=u"""For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.""")
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@cli_util.option('--force', help="""Perform update without prompting for confirmation.""", is_flag=True)
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'config': {'module': 'apm_config', 'class': 'AgentConfigMap'}, 'overrides': {'module': 'apm_config', 'class': 'AgentConfigOverrides'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'config': {'module': 'apm_config', 'class': 'AgentConfigMap'}, 'overrides': {'module': 'apm_config', 'class': 'AgentConfigOverrides'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def update_config_update_agent_config_details(ctx, from_json, force, apm_domain_id, config_id, freeform_tags, defined_tags, config, overrides, if_match, opc_dry_run):

    if isinstance(config_id, six.string_types) and len(config_id.strip()) == 0:
        raise click.UsageError('Parameter --config-id cannot be whitespace or empty string')
    if not force:
        if freeform_tags or defined_tags or config or overrides:
            if not click.confirm("WARNING: Updates to freeform-tags and defined-tags and config and overrides will replace any existing values. Are you sure you want to continue?"):
                ctx.abort()

    kwargs = {}
    if if_match is not None:
        kwargs['if_match'] = if_match
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    if config is not None:
        _details['config'] = cli_util.parse_json_parameter("config", config)

    if overrides is not None:
        _details['overrides'] = cli_util.parse_json_parameter("overrides", overrides)

    _details['configType'] = 'AGENT'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.update_config(
        apm_domain_id=apm_domain_id,
        config_id=config_id,
        update_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.update_config_update_macs_apm_extension_details.command_name', 'update-config-update-macs-apm-extension-details'), help=u"""Updates the details of the configuration item identified by the OCID. \n[Command Reference](updateConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--config-id', required=True, help=u"""The [OCID] of the configuration item.""")
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--display-name', help=u"""The name by which a configuration entity is displayed to the end user.""")
@cli_util.option('--process-filter', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Filter patterns used to discover active Java processes for provisioning the APM Agent.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--run-as-user', help=u"""The OS user that should be used to discover Java processes.""")
@cli_util.option('--service-name', help=u"""The name of the service being monitored. This argument enables you to filter by service and view traces and other signals in the APM Explorer user interface.""")
@cli_util.option('--agent-version', help=u"""The version of the referenced agent bundle.""")
@cli_util.option('--attach-install-dir', help=u"""The directory owned by runAsUser.""")
@cli_util.option('--if-match', help=u"""For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.""")
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@cli_util.option('--force', help="""Perform update without prompting for confirmation.""", is_flag=True)
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'process-filter': {'module': 'apm_config', 'class': 'list[string]'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'process-filter': {'module': 'apm_config', 'class': 'list[string]'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def update_config_update_macs_apm_extension_details(ctx, from_json, force, apm_domain_id, config_id, freeform_tags, defined_tags, display_name, process_filter, run_as_user, service_name, agent_version, attach_install_dir, if_match, opc_dry_run):

    if isinstance(config_id, six.string_types) and len(config_id.strip()) == 0:
        raise click.UsageError('Parameter --config-id cannot be whitespace or empty string')
    if not force:
        if freeform_tags or defined_tags or process_filter:
            if not click.confirm("WARNING: Updates to freeform-tags and defined-tags and process-filter will replace any existing values. Are you sure you want to continue?"):
                ctx.abort()

    kwargs = {}
    if if_match is not None:
        kwargs['if_match'] = if_match
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    if display_name is not None:
        _details['displayName'] = display_name

    if process_filter is not None:
        _details['processFilter'] = cli_util.parse_json_parameter("process_filter", process_filter)

    if run_as_user is not None:
        _details['runAsUser'] = run_as_user

    if service_name is not None:
        _details['serviceName'] = service_name

    if agent_version is not None:
        _details['agentVersion'] = agent_version

    if attach_install_dir is not None:
        _details['attachInstallDir'] = attach_install_dir

    _details['configType'] = 'MACS_APM_EXTENSION'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.update_config(
        apm_domain_id=apm_domain_id,
        config_id=config_id,
        update_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.update_config_update_apdex_rules_details.command_name', 'update-config-update-apdex-rules-details'), help=u"""Updates the details of the configuration item identified by the OCID. \n[Command Reference](updateConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--config-id', required=True, help=u"""The [OCID] of the configuration item.""")
@cli_util.option('--rules', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--display-name', help=u"""The name by which a configuration entity is displayed to the end user.""")
@cli_util.option('--if-match', help=u"""For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.""")
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@cli_util.option('--force', help="""Perform update without prompting for confirmation.""", is_flag=True)
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'rules': {'module': 'apm_config', 'class': 'list[Apdex]'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'rules': {'module': 'apm_config', 'class': 'list[Apdex]'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def update_config_update_apdex_rules_details(ctx, from_json, force, apm_domain_id, config_id, rules, freeform_tags, defined_tags, display_name, if_match, opc_dry_run):

    if isinstance(config_id, six.string_types) and len(config_id.strip()) == 0:
        raise click.UsageError('Parameter --config-id cannot be whitespace or empty string')
    if not force:
        if freeform_tags or defined_tags or rules:
            if not click.confirm("WARNING: Updates to freeform-tags and defined-tags and rules will replace any existing values. Are you sure you want to continue?"):
                ctx.abort()

    kwargs = {}
    if if_match is not None:
        kwargs['if_match'] = if_match
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['rules'] = cli_util.parse_json_parameter("rules", rules)

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    if display_name is not None:
        _details['displayName'] = display_name

    _details['configType'] = 'APDEX'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.update_config(
        apm_domain_id=apm_domain_id,
        config_id=config_id,
        update_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.update_config_update_span_filter_details.command_name', 'update-config-update-span-filter-details'), help=u"""Updates the details of the configuration item identified by the OCID. \n[Command Reference](updateConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--config-id', required=True, help=u"""The [OCID] of the configuration item.""")
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--display-name', help=u"""The name by which a configuration entity is displayed to the end user.""")
@cli_util.option('--filter-text', help=u"""The string that defines the Span Filter expression.""")
@cli_util.option('--description', help=u"""An optional string that describes what the filter is intended or used for.""")
@cli_util.option('--if-match', help=u"""For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.""")
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@cli_util.option('--force', help="""Perform update without prompting for confirmation.""", is_flag=True)
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def update_config_update_span_filter_details(ctx, from_json, force, apm_domain_id, config_id, freeform_tags, defined_tags, display_name, filter_text, description, if_match, opc_dry_run):

    if isinstance(config_id, six.string_types) and len(config_id.strip()) == 0:
        raise click.UsageError('Parameter --config-id cannot be whitespace or empty string')
    if not force:
        if freeform_tags or defined_tags:
            if not click.confirm("WARNING: Updates to freeform-tags and defined-tags will replace any existing values. Are you sure you want to continue?"):
                ctx.abort()

    kwargs = {}
    if if_match is not None:
        kwargs['if_match'] = if_match
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    if display_name is not None:
        _details['displayName'] = display_name

    if filter_text is not None:
        _details['filterText'] = filter_text

    if description is not None:
        _details['description'] = description

    _details['configType'] = 'SPAN_FILTER'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.update_config(
        apm_domain_id=apm_domain_id,
        config_id=config_id,
        update_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@config_group.command(name=cli_util.override('apm_config.update_config_update_options_details.command_name', 'update-config-update-options-details'), help=u"""Updates the details of the configuration item identified by the OCID. \n[Command Reference](updateConfig)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--config-id', required=True, help=u"""The [OCID] of the configuration item.""")
@cli_util.option('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--defined-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{\"foo-namespace\": {\"bar-key\": \"value\"}}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--display-name', help=u"""The name by which a configuration entity is displayed to the end user.""")
@cli_util.option('--options', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The options are stored here as JSON.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--group', help=u"""A string that specifies the group that an OPTIONS item belongs to.""")
@cli_util.option('--description', help=u"""An optional string that describes what the options are intended or used for.""")
@cli_util.option('--if-match', help=u"""For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.""")
@cli_util.option('--opc-dry-run', help=u"""Indicates that the request is a dry run, if set to \"true\". A dry run request does not modify the configuration item details and is used only to perform validation on the submitted data.""")
@cli_util.option('--force', help="""Perform update without prompting for confirmation.""", is_flag=True)
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'options': {'module': 'apm_config', 'class': 'object'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'freeform-tags': {'module': 'apm_config', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'apm_config', 'class': 'dict(str, dict(str, object))'}, 'options': {'module': 'apm_config', 'class': 'object'}}, output_type={'module': 'apm_config', 'class': 'Config'})
@cli_util.wrap_exceptions
def update_config_update_options_details(ctx, from_json, force, apm_domain_id, config_id, freeform_tags, defined_tags, display_name, options, group, description, if_match, opc_dry_run):

    if isinstance(config_id, six.string_types) and len(config_id.strip()) == 0:
        raise click.UsageError('Parameter --config-id cannot be whitespace or empty string')
    if not force:
        if freeform_tags or defined_tags or options:
            if not click.confirm("WARNING: Updates to freeform-tags and defined-tags and options will replace any existing values. Are you sure you want to continue?"):
                ctx.abort()

    kwargs = {}
    if if_match is not None:
        kwargs['if_match'] = if_match
    if opc_dry_run is not None:
        kwargs['opc_dry_run'] = opc_dry_run
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}

    if freeform_tags is not None:
        _details['freeformTags'] = cli_util.parse_json_parameter("freeform_tags", freeform_tags)

    if defined_tags is not None:
        _details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

    if display_name is not None:
        _details['displayName'] = display_name

    if options is not None:
        _details['options'] = cli_util.parse_json_parameter("options", options)

    if group is not None:
        _details['group'] = group

    if description is not None:
        _details['description'] = description

    _details['configType'] = 'OPTIONS'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.update_config(
        apm_domain_id=apm_domain_id,
        config_id=config_id,
        update_config_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@match_agents_with_attribute_key_group.command(name=cli_util.override('apm_config.update_match_agents_with_attribute_key.command_name', 'update'), help=u"""Updates the agent matching attribute key for the APM Domain. \n[Command Reference](updateMatchAgentsWithAttributeKey)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--items', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of agent matching attribute keys to be updated.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--force', help="""Perform update without prompting for confirmation.""", is_flag=True)
@json_skeleton_utils.get_cli_json_input_option({'items': {'module': 'apm_config', 'class': 'list[string]'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'items': {'module': 'apm_config', 'class': 'list[string]'}}, output_type={'module': 'apm_config', 'class': 'MatchAgentsWithAttributeKey'})
@cli_util.wrap_exceptions
def update_match_agents_with_attribute_key(ctx, from_json, force, apm_domain_id, items):
    if not force:
        if items:
            if not click.confirm("WARNING: Updates to items will replace any existing values. Are you sure you want to continue?"):
                ctx.abort()

    kwargs = {}
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}

    if items is not None:
        _details['items'] = cli_util.parse_json_parameter("items", items)

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.update_match_agents_with_attribute_key(
        apm_domain_id=apm_domain_id,
        update_match_agents_with_attribute_key_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@span_filter_group.command(name=cli_util.override('apm_config.validate_span_filter_pattern.command_name', 'validate-span-filter-pattern'), help=u"""Validates the Span Filter pattern (filterText) for syntactic correctness. Returns 204 on success, 422 when validation fails. \n[Command Reference](validateSpanFilterPattern)""")
@cli_util.option('--apm-domain-id', required=True, help=u"""The APM Domain ID the request is intended for.""")
@cli_util.option('--filter-text', required=True, help=u"""The string that defines the Span Filter expression.""")
@json_skeleton_utils.get_cli_json_input_option({})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={})
@cli_util.wrap_exceptions
def validate_span_filter_pattern(ctx, from_json, apm_domain_id, filter_text):

    kwargs = {}
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])

    _details = {}
    _details['filterText'] = filter_text

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.validate_span_filter_pattern(
        apm_domain_id=apm_domain_id,
        validate_span_filter_pattern_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)
