# 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: 20251101

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('limits_increase.limits_increase_root_group.command_name', 'limits-increase'), cls=CommandGroupWithAlias, help=cli_util.override('limits_increase.limits_increase_root_group.help', """Use the Limits Increase API to work with limit increase requests.
For more information, see
[Working with Limit Increase Requests]."""), short_help=cli_util.override('limits_increase.limits_increase_root_group.short_help', """Limits Increase API"""))
@cli_util.help_option_group
def limits_increase_root_group():
    pass


@click.command(cli_util.override('limits_increase.limits_increase_item_request_collection_group.command_name', 'limits-increase-item-request-collection'), cls=CommandGroupWithAlias, help="""Collection of property summaries for limit increase items within the indicated limit increase request.""")
@cli_util.help_option_group
def limits_increase_item_request_collection_group():
    pass


@click.command(cli_util.override('limits_increase.limits_increase_item_request_group.command_name', 'limits-increase-item-request'), cls=CommandGroupWithAlias, help="""The properties that define a limit increase item in a limit increase request. For information about limit increase requests, see [Working with Limit Increase Requests].""")
@cli_util.help_option_group
def limits_increase_item_request_group():
    pass


@click.command(cli_util.override('limits_increase.limits_increase_request_group.command_name', 'limits-increase-request'), cls=CommandGroupWithAlias, help="""The properties that define a limit increase request. For information about limit increase requests, see [Working with Limit Increase Requests].""")
@cli_util.help_option_group
def limits_increase_request_group():
    pass


@click.command(cli_util.override('limits_increase.limits_increase_question_collection_group.command_name', 'limits-increase-question-collection'), cls=CommandGroupWithAlias, help="""Collection of questions to be asked for certain limits. Example questions include database version for some limits in Autonomous AI Database or email domain for some limits in Email Delivery. For more information, see [Creating a Limit Increase Request].""")
@cli_util.help_option_group
def limits_increase_question_collection_group():
    pass


limits_increase_root_group.add_command(limits_increase_item_request_collection_group)
limits_increase_root_group.add_command(limits_increase_item_request_group)
limits_increase_root_group.add_command(limits_increase_request_group)
limits_increase_root_group.add_command(limits_increase_question_collection_group)


@limits_increase_item_request_group.command(name=cli_util.override('limits_increase.cancel_limits_increase_item_request.command_name', 'cancel'), help=u"""Withdraws the specified item from the limit increase request. For more information, see [Withdrawing an Item from a Limit Increase Request]. \n[Command Reference](cancelLimitsIncreaseItemRequest)""")
@cli_util.option('--limits-increase-item-request-id', required=True, help=u"""The [OCID] of the limit increase request.""")
@cli_util.option('--if-match', help=u"""This value (etag) should be passed when you want to ensure that no-one else has changed the value while you're making an update. To get the current etag, make a GET call and read the current etag header. If GET returns 404, and you still want to ensure that noone else has executed a SET operation, pass the following header instead: `if-none-match: *`""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "SUCCEEDED", "CANCELED", "FAILED"]), multiple=True, help="""This operation creates, modifies or deletes a resource that has a defined lifecycle state. Specify this option to perform the action and then wait until the resource reaches a given lifecycle state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state FAILED would return on whichever lifecycle state is reached first. If timeout is reached, a return code of 2 is returned. For any other error, a return code of 1 is returned.""")
@cli_util.option('--max-wait-seconds', type=click.INT, help="""The maximum time to wait for the resource to reach the lifecycle state defined by --wait-for-state. Defaults to 1200 seconds.""")
@cli_util.option('--wait-interval-seconds', type=click.INT, help="""Check every --wait-interval-seconds to see whether the resource has reached the lifecycle state defined by --wait-for-state. Defaults to 30 seconds.""")
@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': 'limits_increase', 'class': 'LimitsIncreaseItemRequest'})
@cli_util.wrap_exceptions
def cancel_limits_increase_item_request(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, limits_increase_item_request_id, if_match):

    if isinstance(limits_increase_item_request_id, six.string_types) and len(limits_increase_item_request_id.strip()) == 0:
        raise click.UsageError('Parameter --limits-increase-item-request-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('limits_increase', 'limits_increase', ctx)
    result = client.cancel_limits_increase_item_request(
        limits_increase_item_request_id=limits_increase_item_request_id,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_limits_increase_item_request') and callable(getattr(client, 'get_limits_increase_item_request')):
            try:
                wait_period_kwargs = {}
                if max_wait_seconds is not None:
                    wait_period_kwargs['max_wait_seconds'] = max_wait_seconds
                if wait_interval_seconds is not None:
                    wait_period_kwargs['max_interval_seconds'] = wait_interval_seconds

                click.echo('Action completed. Waiting until the resource has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_limits_increase_item_request(result.data.id), 'lifecycle_state', wait_for_state, **wait_period_kwargs)
            except oci.exceptions.MaximumWaitTimeExceeded as e:
                # If we fail, we should show an error, but we should still provide the information to the customer
                click.echo('Failed to wait until the resource entered the specified state. Outputting last known resource state', file=sys.stderr)
                cli_util.render_response(result, ctx)
                sys.exit(2)
            except Exception:
                click.echo('Encountered error while waiting for resource to enter the specified state. Outputting last known resource state', file=sys.stderr)
                cli_util.render_response(result, ctx)
                raise
        else:
            click.echo('Unable to wait for the resource to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@limits_increase_request_group.command(name=cli_util.override('limits_increase.cancel_limits_increase_request.command_name', 'cancel'), help=u"""Withdraws the specified limit increase request. For more information, see [Withdrawing a Limit Increase Request]. \n[Command Reference](cancelLimitsIncreaseRequest)""")
@cli_util.option('--limits-increase-request-id', required=True, help=u"""The [OCID] of the limit increase request.""")
@cli_util.option('--if-match', help=u"""This value (etag) should be passed when you want to ensure that no-one else has changed the value while you're making an update. To get the current etag, make a GET call and read the current etag header. If GET returns 404, and you still want to ensure that noone else has executed a SET operation, pass the following header instead: `if-none-match: *`""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "SUCCEEDED", "CANCELED", "PARTIALLY_SUCCEEDED", "FAILED"]), multiple=True, help="""This operation creates, modifies or deletes a resource that has a defined lifecycle state. Specify this option to perform the action and then wait until the resource reaches a given lifecycle state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state FAILED would return on whichever lifecycle state is reached first. If timeout is reached, a return code of 2 is returned. For any other error, a return code of 1 is returned.""")
@cli_util.option('--max-wait-seconds', type=click.INT, help="""The maximum time to wait for the resource to reach the lifecycle state defined by --wait-for-state. Defaults to 1200 seconds.""")
@cli_util.option('--wait-interval-seconds', type=click.INT, help="""Check every --wait-interval-seconds to see whether the resource has reached the lifecycle state defined by --wait-for-state. Defaults to 30 seconds.""")
@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': 'limits_increase', 'class': 'LimitsIncreaseRequest'})
@cli_util.wrap_exceptions
def cancel_limits_increase_request(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, limits_increase_request_id, if_match):

    if isinstance(limits_increase_request_id, six.string_types) and len(limits_increase_request_id.strip()) == 0:
        raise click.UsageError('Parameter --limits-increase-request-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('limits_increase', 'limits_increase', ctx)
    result = client.cancel_limits_increase_request(
        limits_increase_request_id=limits_increase_request_id,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_limits_increase_request') and callable(getattr(client, 'get_limits_increase_request')):
            try:
                wait_period_kwargs = {}
                if max_wait_seconds is not None:
                    wait_period_kwargs['max_wait_seconds'] = max_wait_seconds
                if wait_interval_seconds is not None:
                    wait_period_kwargs['max_interval_seconds'] = wait_interval_seconds

                click.echo('Action completed. Waiting until the resource has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_limits_increase_request(result.data.id), 'lifecycle_state', wait_for_state, **wait_period_kwargs)
            except oci.exceptions.MaximumWaitTimeExceeded as e:
                # If we fail, we should show an error, but we should still provide the information to the customer
                click.echo('Failed to wait until the resource entered the specified state. Outputting last known resource state', file=sys.stderr)
                cli_util.render_response(result, ctx)
                sys.exit(2)
            except Exception:
                click.echo('Encountered error while waiting for resource to enter the specified state. Outputting last known resource state', file=sys.stderr)
                cli_util.render_response(result, ctx)
                raise
        else:
            click.echo('Unable to wait for the resource to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@limits_increase_request_group.command(name=cli_util.override('limits_increase.create_limits_increase_request.command_name', 'create'), help=u"""Creates a limit increase request in the specified compartment. For more information, see [Creating a Limit Increase Request]. \n[Command Reference](createLimitsIncreaseRequest)""")
@cli_util.option('--display-name', required=True, help=u"""The user-friendly name of the limit increase request. Avoid entering confidential information.""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment for the new limit increase request. Note: The tenancy is the root compartment.""")
@cli_util.option('--justification', required=True, help=u"""Reason for the limit increase request.""")
@cli_util.option('--limits-increase-item-requests', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""List of items in the limit increase request.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--subscription-id', help=u"""The [OCID] of the tenancy subscription for the limit increase request.""")
@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('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "SUCCEEDED", "CANCELED", "PARTIALLY_SUCCEEDED", "FAILED"]), multiple=True, help="""This operation creates, modifies or deletes a resource that has a defined lifecycle state. Specify this option to perform the action and then wait until the resource reaches a given lifecycle state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state FAILED would return on whichever lifecycle state is reached first. If timeout is reached, a return code of 2 is returned. For any other error, a return code of 1 is returned.""")
@cli_util.option('--max-wait-seconds', type=click.INT, help="""The maximum time to wait for the resource to reach the lifecycle state defined by --wait-for-state. Defaults to 1200 seconds.""")
@cli_util.option('--wait-interval-seconds', type=click.INT, help="""Check every --wait-interval-seconds to see whether the resource has reached the lifecycle state defined by --wait-for-state. Defaults to 30 seconds.""")
@json_skeleton_utils.get_cli_json_input_option({'limits-increase-item-requests': {'module': 'limits_increase', 'class': 'list[CreateLimitsIncreaseItemRequestDetails]'}, 'freeform-tags': {'module': 'limits_increase', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'limits_increase', '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={'limits-increase-item-requests': {'module': 'limits_increase', 'class': 'list[CreateLimitsIncreaseItemRequestDetails]'}, 'freeform-tags': {'module': 'limits_increase', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'limits_increase', 'class': 'dict(str, dict(str, object))'}}, output_type={'module': 'limits_increase', 'class': 'LimitsIncreaseRequest'})
@cli_util.wrap_exceptions
def create_limits_increase_request(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, display_name, compartment_id, justification, limits_increase_item_requests, subscription_id, freeform_tags, defined_tags):

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

    _details = {}
    _details['displayName'] = display_name
    _details['compartmentId'] = compartment_id
    _details['justification'] = justification
    _details['limitsIncreaseItemRequests'] = cli_util.parse_json_parameter("limits_increase_item_requests", limits_increase_item_requests)

    if subscription_id is not None:
        _details['subscriptionId'] = subscription_id

    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('limits_increase', 'limits_increase', ctx)
    result = client.create_limits_increase_request(
        create_limits_increase_request_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_limits_increase_request') and callable(getattr(client, 'get_limits_increase_request')):
            try:
                wait_period_kwargs = {}
                if max_wait_seconds is not None:
                    wait_period_kwargs['max_wait_seconds'] = max_wait_seconds
                if wait_interval_seconds is not None:
                    wait_period_kwargs['max_interval_seconds'] = wait_interval_seconds

                click.echo('Action completed. Waiting until the resource has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_limits_increase_request(result.data.id), 'lifecycle_state', wait_for_state, **wait_period_kwargs)
            except oci.exceptions.MaximumWaitTimeExceeded as e:
                # If we fail, we should show an error, but we should still provide the information to the customer
                click.echo('Failed to wait until the resource entered the specified state. Outputting last known resource state', file=sys.stderr)
                cli_util.render_response(result, ctx)
                sys.exit(2)
            except Exception:
                click.echo('Encountered error while waiting for resource to enter the specified state. Outputting last known resource state', file=sys.stderr)
                cli_util.render_response(result, ctx)
                raise
        else:
            click.echo('Unable to wait for the resource to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@limits_increase_request_group.command(name=cli_util.override('limits_increase.delete_limits_increase_request.command_name', 'delete'), help=u"""Deletes the specified limit increase request. For more information, see [Deleting a Limit Increase Request]. \n[Command Reference](deleteLimitsIncreaseRequest)""")
@cli_util.option('--limits-increase-request-id', required=True, help=u"""The [OCID] of the limit increase request.""")
@cli_util.option('--if-match', help=u"""This value (etag) should be passed when you want to ensure that no-one else has changed the value while you're making an update. To get the current etag, make a GET call and read the current etag header. If GET returns 404, and you still want to ensure that noone else has executed a SET operation, pass the following header instead: `if-none-match: *`""")
@cli_util.confirm_delete_option
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "SUCCEEDED", "CANCELED", "PARTIALLY_SUCCEEDED", "FAILED"]), multiple=True, help="""This operation creates, modifies or deletes a resource that has a defined lifecycle state. Specify this option to perform the action and then wait until the resource reaches a given lifecycle state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state FAILED would return on whichever lifecycle state is reached first. If timeout is reached, a return code of 2 is returned. For any other error, a return code of 1 is returned.""")
@cli_util.option('--max-wait-seconds', type=click.INT, help="""The maximum time to wait for the resource to reach the lifecycle state defined by --wait-for-state. Defaults to 1200 seconds.""")
@cli_util.option('--wait-interval-seconds', type=click.INT, help="""Check every --wait-interval-seconds to see whether the resource has reached the lifecycle state defined by --wait-for-state. Defaults to 30 seconds.""")
@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_limits_increase_request(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, limits_increase_request_id, if_match):

    if isinstance(limits_increase_request_id, six.string_types) and len(limits_increase_request_id.strip()) == 0:
        raise click.UsageError('Parameter --limits-increase-request-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('limits_increase', 'limits_increase', ctx)
    result = client.delete_limits_increase_request(
        limits_increase_request_id=limits_increase_request_id,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_limits_increase_request') and callable(getattr(client, 'get_limits_increase_request')):
            try:
                wait_period_kwargs = {}
                if max_wait_seconds is not None:
                    wait_period_kwargs['max_wait_seconds'] = max_wait_seconds
                if wait_interval_seconds is not None:
                    wait_period_kwargs['max_interval_seconds'] = wait_interval_seconds

                click.echo('Action completed. Waiting until the resource has entered state: {}'.format(wait_for_state), file=sys.stderr)
                oci.wait_until(client, client.get_limits_increase_request(limits_increase_request_id), 'lifecycle_state', wait_for_state, succeed_on_not_found=True, **wait_period_kwargs)
            except oci.exceptions.ServiceError as e:
                # We make an initial service call so we can pass the result to oci.wait_until(), however if we are waiting on the
                # outcome of a delete operation it is possible that the resource is already gone and so the initial service call
                # will result in an exception that reflects a HTTP 404. In this case, we can exit with success (rather than raising
                # the exception) since this would have been the behaviour in the waiter anyway (as for delete we provide the argument
                # succeed_on_not_found=True to the waiter).
                #
                # Any non-404 should still result in the exception being thrown.
                if e.status == 404:
                    pass
                else:
                    raise
            except oci.exceptions.MaximumWaitTimeExceeded as e:
                # If we fail, we should show an error, but we should still provide the information to the customer
                click.echo('Failed to wait until the resource entered the specified state. Please retrieve the resource to find its current state', file=sys.stderr)
                cli_util.render_response(result, ctx)
                sys.exit(2)
            except Exception:
                click.echo('Encountered error while waiting for resource to enter the specified state. Outputting last known resource state', file=sys.stderr)
                cli_util.render_response(result, ctx)
                raise
        else:
            click.echo('Unable to wait for the resource to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@limits_increase_item_request_group.command(name=cli_util.override('limits_increase.get_limits_increase_item_request.command_name', 'get'), help=u"""Gets the specified item from the limit increase request. For more information, see [Getting Details for a Limit Increase Request]. \n[Command Reference](getLimitsIncreaseItemRequest)""")
@cli_util.option('--limits-increase-item-request-id', required=True, help=u"""The [OCID] of the limit increase request.""")
@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': 'limits_increase', 'class': 'LimitsIncreaseItemRequest'})
@cli_util.wrap_exceptions
def get_limits_increase_item_request(ctx, from_json, limits_increase_item_request_id):

    if isinstance(limits_increase_item_request_id, six.string_types) and len(limits_increase_item_request_id.strip()) == 0:
        raise click.UsageError('Parameter --limits-increase-item-request-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('limits_increase', 'limits_increase', ctx)
    result = client.get_limits_increase_item_request(
        limits_increase_item_request_id=limits_increase_item_request_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@limits_increase_request_group.command(name=cli_util.override('limits_increase.get_limits_increase_request.command_name', 'get'), help=u"""Gets the specified limit increase request. For more information, see [Getting Details for a Limit Increase Request]. \n[Command Reference](getLimitsIncreaseRequest)""")
@cli_util.option('--limits-increase-request-id', required=True, help=u"""The [OCID] of the limit increase request.""")
@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': 'limits_increase', 'class': 'LimitsIncreaseRequest'})
@cli_util.wrap_exceptions
def get_limits_increase_request(ctx, from_json, limits_increase_request_id):

    if isinstance(limits_increase_request_id, six.string_types) and len(limits_increase_request_id.strip()) == 0:
        raise click.UsageError('Parameter --limits-increase-request-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('limits_increase', 'limits_increase', ctx)
    result = client.get_limits_increase_request(
        limits_increase_request_id=limits_increase_request_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@limits_increase_item_request_collection_group.command(name=cli_util.override('limits_increase.list_limits_increase_item_requests.command_name', 'list-limits-increase-item-requests'), help=u"""Lists items in the specified limit increase request. For more information, see [Getting Details for a Limit Increase Request]. \n[Command Reference](listLimitsIncreaseItemRequests)""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the parent compartment. Note: The tenancy is the root compartment.""")
@cli_util.option('--service', help=u"""Name of service that owns the limit.""")
@cli_util.option('--lifecycle-state', help=u"""Lifecycle state of the limit increase request.""")
@cli_util.option('--limits-increase-request-id', help=u"""The [OCID] of the limit increase request.""")
@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order to use, either 'asc' or 'desc'. By default, it is ascending.""")
@cli_util.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["timeCreated"]), help=u"""The field to sort by. You can specify only one sort order. The default order for `timeCreated` is descending.""")
@cli_util.option('--limit', type=click.INT, help=u"""Maximum number of items returned in a page.""")
@cli_util.option('--page', help=u"""The next page token.""")
@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': 'limits_increase', 'class': 'LimitsIncreaseItemRequestCollection'})
@cli_util.wrap_exceptions
def list_limits_increase_item_requests(ctx, from_json, all_pages, page_size, compartment_id, service, lifecycle_state, limits_increase_request_id, sort_order, sort_by, limit, page):

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

    kwargs = {}
    if service is not None:
        kwargs['service'] = service
    if lifecycle_state is not None:
        kwargs['lifecycle_state'] = lifecycle_state
    if limits_increase_request_id is not None:
        kwargs['limits_increase_request_id'] = limits_increase_request_id
    if sort_order is not None:
        kwargs['sort_order'] = sort_order
    if sort_by is not None:
        kwargs['sort_by'] = sort_by
    if limit is not None:
        kwargs['limit'] = limit
    if page is not None:
        kwargs['page'] = page
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('limits_increase', 'limits_increase', ctx)
    if all_pages:
        if page_size:
            kwargs['limit'] = page_size

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


@limits_increase_question_collection_group.command(name=cli_util.override('limits_increase.list_limits_increase_questions.command_name', 'list-limits-increase-questions'), help=u"""Gets the fields for the specified service and limit name. Service name is required if limit name is provided. If limit name is not provided, returns all questions for the specified service. If service name is not provided, returns all available questions. For more information, see [Creating a Limit Increase Request]. \n[Command Reference](listLimitsIncreaseQuestions)""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the parent compartment. Note: The tenancy is the root compartment.""")
@cli_util.option('--service-name', help=u"""The name of the service.""")
@cli_util.option('--limit-name', help=u"""The name of the limit.""")
@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order to use, either 'asc' or 'desc'. By default, it is ascending.""")
@cli_util.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["serviceName", "limitName"]), help=u"""The field to sort by. Both fields will sort alphabetically""")
@cli_util.option('--limit', type=click.INT, help=u"""Maximum number of items returned in a page.""")
@cli_util.option('--page', help=u"""The next page token.""")
@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': 'limits_increase', 'class': 'LimitsIncreaseQuestionCollection'})
@cli_util.wrap_exceptions
def list_limits_increase_questions(ctx, from_json, all_pages, page_size, compartment_id, service_name, limit_name, sort_order, sort_by, limit, page):

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

    kwargs = {}
    if service_name is not None:
        kwargs['service_name'] = service_name
    if limit_name is not None:
        kwargs['limit_name'] = limit_name
    if sort_order is not None:
        kwargs['sort_order'] = sort_order
    if sort_by is not None:
        kwargs['sort_by'] = sort_by
    if limit is not None:
        kwargs['limit'] = limit
    if page is not None:
        kwargs['page'] = page
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('limits_increase', 'limits_increase', ctx)
    if all_pages:
        if page_size:
            kwargs['limit'] = page_size

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


@limits_increase_request_group.command(name=cli_util.override('limits_increase.list_limits_increase_requests.command_name', 'list'), help=u"""Lists limit increase requests in the specified compartment. For more information, see [Listing Limit Increase Requests]. \n[Command Reference](listLimitsIncreaseRequests)""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the parent compartment. Note: The tenancy is the root compartment.""")
@cli_util.option('--lifecycle-state', help=u"""Lifecycle state of the limit increase request.""")
@cli_util.option('--display-name', help=u"""A filter to return only the resources that match the entire display name specified.""")
@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order to use, either 'asc' or 'desc'. By default, it is ascending.""")
@cli_util.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["timeCreated", "displayName"]), help=u"""The field to sort by. You can specify only one sort order. The default order for `timeCreated` is descending. The default order for `displayName` is ascending.""")
@cli_util.option('--limit', type=click.INT, help=u"""Maximum number of items returned in a page.""")
@cli_util.option('--page', help=u"""The next page token.""")
@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': 'limits_increase', 'class': 'LimitsIncreaseRequestCollection'})
@cli_util.wrap_exceptions
def list_limits_increase_requests(ctx, from_json, all_pages, page_size, compartment_id, lifecycle_state, display_name, sort_order, sort_by, limit, page):

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

    kwargs = {}
    if lifecycle_state is not None:
        kwargs['lifecycle_state'] = lifecycle_state
    if display_name is not None:
        kwargs['display_name'] = display_name
    if sort_order is not None:
        kwargs['sort_order'] = sort_order
    if sort_by is not None:
        kwargs['sort_by'] = sort_by
    if limit is not None:
        kwargs['limit'] = limit
    if page is not None:
        kwargs['page'] = page
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('limits_increase', 'limits_increase', ctx)
    if all_pages:
        if page_size:
            kwargs['limit'] = page_size

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


@limits_increase_request_group.command(name=cli_util.override('limits_increase.patch_limits_increase_request.command_name', 'patch'), help=u"""Adds one or more comments to the specified limit increase request. For more information, see [Adding Comments to a Limit Increase Request]. \n[Command Reference](patchLimitsIncreaseRequest)""")
@cli_util.option('--limits-increase-request-id', required=True, help=u"""The [OCID] of the limit increase request.""")
@cli_util.option('--items', type=custom_types.CLI_COMPLEX_TYPE, help=u"""List of patch instructions for adding comments.

This option is a JSON list with items of type PatchInstruction.  For documentation on PatchInstruction please see our API reference: https://docs.oracle.com/en-us/iaas/api/#/en/limitsincrease/20251101/datatypes/PatchInstruction.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--if-match', help=u"""This value (etag) should be passed when you want to ensure that no-one else has changed the value while you're making an update. To get the current etag, make a GET call and read the current etag header. If GET returns 404, and you still want to ensure that noone else has executed a SET operation, pass the following header instead: `if-none-match: *`""")
@json_skeleton_utils.get_cli_json_input_option({'items': {'module': 'limits_increase', 'class': 'list[PatchInstruction]'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'items': {'module': 'limits_increase', 'class': 'list[PatchInstruction]'}}, output_type={'module': 'limits_increase', 'class': 'LimitsIncreaseRequest'})
@cli_util.wrap_exceptions
def patch_limits_increase_request(ctx, from_json, limits_increase_request_id, items, if_match):

    if isinstance(limits_increase_request_id, six.string_types) and len(limits_increase_request_id.strip()) == 0:
        raise click.UsageError('Parameter --limits-increase-request-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'])

    _details = {}

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

    client = cli_util.build_client('limits_increase', 'limits_increase', ctx)
    result = client.patch_limits_increase_request(
        limits_increase_request_id=limits_increase_request_id,
        patch_limits_increase_request_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@limits_increase_request_group.command(name=cli_util.override('limits_increase.update_limits_increase_request.command_name', 'update'), help=u"""Updates the limit increase request. For more information, see [Updating a Limit Increase Request]. \n[Command Reference](updateLimitsIncreaseRequest)""")
@cli_util.option('--limits-increase-request-id', required=True, help=u"""The [OCID] of the limit increase request.""")
@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"""This value (etag) should be passed when you want to ensure that no-one else has changed the value while you're making an update. To get the current etag, make a GET call and read the current etag header. If GET returns 404, and you still want to ensure that noone else has executed a SET operation, pass the following header instead: `if-none-match: *`""")
@cli_util.option('--force', help="""Perform update without prompting for confirmation.""", is_flag=True)
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "SUCCEEDED", "CANCELED", "PARTIALLY_SUCCEEDED", "FAILED"]), multiple=True, help="""This operation creates, modifies or deletes a resource that has a defined lifecycle state. Specify this option to perform the action and then wait until the resource reaches a given lifecycle state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state FAILED would return on whichever lifecycle state is reached first. If timeout is reached, a return code of 2 is returned. For any other error, a return code of 1 is returned.""")
@cli_util.option('--max-wait-seconds', type=click.INT, help="""The maximum time to wait for the resource to reach the lifecycle state defined by --wait-for-state. Defaults to 1200 seconds.""")
@cli_util.option('--wait-interval-seconds', type=click.INT, help="""Check every --wait-interval-seconds to see whether the resource has reached the lifecycle state defined by --wait-for-state. Defaults to 30 seconds.""")
@json_skeleton_utils.get_cli_json_input_option({'freeform-tags': {'module': 'limits_increase', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'limits_increase', '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': 'limits_increase', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'limits_increase', 'class': 'dict(str, dict(str, object))'}}, output_type={'module': 'limits_increase', 'class': 'LimitsIncreaseRequest'})
@cli_util.wrap_exceptions
def update_limits_increase_request(ctx, from_json, force, wait_for_state, max_wait_seconds, wait_interval_seconds, limits_increase_request_id, freeform_tags, defined_tags, if_match):

    if isinstance(limits_increase_request_id, six.string_types) and len(limits_increase_request_id.strip()) == 0:
        raise click.UsageError('Parameter --limits-increase-request-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
    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)

    client = cli_util.build_client('limits_increase', 'limits_increase', ctx)
    result = client.update_limits_increase_request(
        limits_increase_request_id=limits_increase_request_id,
        update_limits_increase_request_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_limits_increase_request') and callable(getattr(client, 'get_limits_increase_request')):
            try:
                wait_period_kwargs = {}
                if max_wait_seconds is not None:
                    wait_period_kwargs['max_wait_seconds'] = max_wait_seconds
                if wait_interval_seconds is not None:
                    wait_period_kwargs['max_interval_seconds'] = wait_interval_seconds

                click.echo('Action completed. Waiting until the resource has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_limits_increase_request(result.data.id), 'lifecycle_state', wait_for_state, **wait_period_kwargs)
            except oci.exceptions.MaximumWaitTimeExceeded as e:
                # If we fail, we should show an error, but we should still provide the information to the customer
                click.echo('Failed to wait until the resource entered the specified state. Outputting last known resource state', file=sys.stderr)
                cli_util.render_response(result, ctx)
                sys.exit(2)
            except Exception:
                click.echo('Encountered error while waiting for resource to enter the specified state. Outputting last known resource state', file=sys.stderr)
                cli_util.render_response(result, ctx)
                raise
        else:
            click.echo('Unable to wait for the resource to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)
