# 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('datacc.datacc_root_group.command_name', 'datacc'), cls=CommandGroupWithAlias, help=cli_util.override('datacc.datacc_root_group.help', """API for Database Infrastructure Cloud@Customer Service. Use this API to manage Database Infrastructure VM clusters, Application VMs, and related resources."""), short_help=cli_util.override('datacc.datacc_root_group.short_help', """Database Infrastructure Cloud@Customer Service API"""))
@cli_util.help_option_group
def datacc_root_group():
    pass


@click.command(cli_util.override('datacc.infrastructure_scale_option_group.command_name', 'infrastructure-scale-option'), cls=CommandGroupWithAlias, help="""The available scale options for the infrastructure.""")
@cli_util.help_option_group
def infrastructure_scale_option_group():
    pass


@click.command(cli_util.override('datacc.maintenance_execution_group.command_name', 'maintenance-execution'), cls=CommandGroupWithAlias, help="""Details of a maintenance executions.""")
@cli_util.help_option_group
def maintenance_execution_group():
    pass


@click.command(cli_util.override('datacc.infrastructure_summary_group.command_name', 'infrastructure-summary'), cls=CommandGroupWithAlias, help="""Database Infrastructure resource summary.""")
@cli_util.help_option_group
def infrastructure_summary_group():
    pass


@click.command(cli_util.override('datacc.vm_cluster_network_group.command_name', 'vm-cluster-network'), cls=CommandGroupWithAlias, help="""Details of the VM cluster network on Database Infrastructure.""")
@cli_util.help_option_group
def vm_cluster_network_group():
    pass


@click.command(cli_util.override('datacc.infrastructure_group.command_name', 'infrastructure'), cls=CommandGroupWithAlias, help="""Details about Database Infrastructure resource.""")
@cli_util.help_option_group
def infrastructure_group():
    pass


@click.command(cli_util.override('datacc.vm_instance_group.command_name', 'vm-instance'), cls=CommandGroupWithAlias, help="""VM instance details.""")
@cli_util.help_option_group
def vm_instance_group():
    pass


@click.command(cli_util.override('datacc.work_request_error_group.command_name', 'work-request-error'), cls=CommandGroupWithAlias, help="""An error encountered while executing a work request.""")
@cli_util.help_option_group
def work_request_error_group():
    pass


@click.command(cli_util.override('datacc.maintenance_run_group.command_name', 'maintenance-run'), cls=CommandGroupWithAlias, help="""Details of a maintenance run.""")
@cli_util.help_option_group
def maintenance_run_group():
    pass


@click.command(cli_util.override('datacc.vm_instance_summary_group.command_name', 'vm-instance-summary'), cls=CommandGroupWithAlias, help="""VM instance on Database Infrastructure summary.""")
@cli_util.help_option_group
def vm_instance_summary_group():
    pass


@click.command(cli_util.override('datacc.work_request_log_entry_group.command_name', 'work-request-log-entry'), cls=CommandGroupWithAlias, help="""A log message from the execution of a work request.""")
@cli_util.help_option_group
def work_request_log_entry_group():
    pass


@click.command(cli_util.override('datacc.work_request_group.command_name', 'work-request'), cls=CommandGroupWithAlias, help="""Work request details.""")
@cli_util.help_option_group
def work_request_group():
    pass


@click.command(cli_util.override('datacc.vm_cluster_network_summary_group.command_name', 'vm-cluster-network-summary'), cls=CommandGroupWithAlias, help="""Summary of the VM cluster network on Database Infrastructure.""")
@cli_util.help_option_group
def vm_cluster_network_summary_group():
    pass


datacc_root_group.add_command(infrastructure_scale_option_group)
datacc_root_group.add_command(maintenance_execution_group)
datacc_root_group.add_command(infrastructure_summary_group)
datacc_root_group.add_command(vm_cluster_network_group)
datacc_root_group.add_command(infrastructure_group)
datacc_root_group.add_command(vm_instance_group)
datacc_root_group.add_command(work_request_error_group)
datacc_root_group.add_command(maintenance_run_group)
datacc_root_group.add_command(vm_instance_summary_group)
datacc_root_group.add_command(work_request_log_entry_group)
datacc_root_group.add_command(work_request_group)
datacc_root_group.add_command(vm_cluster_network_summary_group)


@infrastructure_group.command(name=cli_util.override('datacc.activate_infrastructure.command_name', 'activate'), help=u"""Activate an Database Infrastructure using the specified details. \n[Command Reference](activateInfrastructure)""")
@cli_util.option('--activation-zip-file', required=True, help=u"""The activation zip file.""")
@cli_util.option('--infrastructure-id', required=True, help=u"""The [OCID] of the Database Infrastructure.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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': 'datacc', 'class': 'Infrastructure'})
@cli_util.wrap_exceptions
def activate_infrastructure(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, activation_zip_file, infrastructure_id, if_match):

    if isinstance(infrastructure_id, six.string_types) and len(infrastructure_id.strip()) == 0:
        raise click.UsageError('Parameter --infrastructure-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 = {}
    _details['activationZipFile'] = activation_zip_file

    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.activate_infrastructure(
        infrastructure_id=infrastructure_id,
        activate_infrastructure_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@infrastructure_group.command(name=cli_util.override('datacc.change_infrastructure_compartment.command_name', 'change-compartment'), help=u"""Change the Database Infrastructure Cloud@Customer Compartment to the specified [OCID]. \n[Command Reference](changeInfrastructureCompartment)""")
@cli_util.option('--infrastructure-id', required=True, help=u"""The [OCID] of the Database Infrastructure.""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment to which the Database Infrastructure Cloud@Customer is moving.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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 change_infrastructure_compartment(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, infrastructure_id, compartment_id, if_match):

    if isinstance(infrastructure_id, six.string_types) and len(infrastructure_id.strip()) == 0:
        raise click.UsageError('Parameter --infrastructure-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 = {}
    _details['compartmentId'] = compartment_id

    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.change_infrastructure_compartment(
        infrastructure_id=infrastructure_id,
        change_infrastructure_compartment_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@vm_cluster_network_group.command(name=cli_util.override('datacc.change_vm_cluster_network_compartment.command_name', 'change-compartment'), help=u"""Change the VM cluster network Compartment to the specified [OCID]. \n[Command Reference](changeVmClusterNetworkCompartment)""")
@cli_util.option('--vm-cluster-network-id', required=True, help=u"""The [OCID] of the VM cluster network.""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment to which the VM cluster network is moving.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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 change_vm_cluster_network_compartment(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, vm_cluster_network_id, compartment_id, if_match):

    if isinstance(vm_cluster_network_id, six.string_types) and len(vm_cluster_network_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-cluster-network-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 = {}
    _details['compartmentId'] = compartment_id

    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.change_vm_cluster_network_compartment(
        vm_cluster_network_id=vm_cluster_network_id,
        change_vm_cluster_network_compartment_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@vm_instance_group.command(name=cli_util.override('datacc.change_vm_instance_compartment.command_name', 'change-compartment'), help=u"""Change the VM instance on Database Infrastructure Compartment to the specified [OCID]. \n[Command Reference](changeVmInstanceCompartment)""")
@cli_util.option('--vm-instance-id', required=True, help=u"""The [OCID] of the VM instance.""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment to which the VM instance is moving.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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 change_vm_instance_compartment(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, vm_instance_id, compartment_id, if_match):

    if isinstance(vm_instance_id, six.string_types) and len(vm_instance_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-instance-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 = {}
    _details['compartmentId'] = compartment_id

    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.change_vm_instance_compartment(
        vm_instance_id=vm_instance_id,
        change_vm_instance_compartment_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@infrastructure_group.command(name=cli_util.override('datacc.create_infrastructure.command_name', 'create'), help=u"""Create a Database Infrastructure using the specified details. \n[Command Reference](createInfrastructure)""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment.""")
@cli_util.option('--display-name', required=True, help=u"""The user-friendly name for the Database Infrastructure. The name does not need to be unique.""")
@cli_util.option('--system-model', required=True, type=custom_types.CliCaseInsensitiveChoice(["X11_HA_768", "X10_HA_512", "X8_HA_384"]), help=u"""Database Infrastructure System Model specification. The system model determines the model of the Database Infrastructure hardware to be used.""")
@cli_util.option('--shape', required=True, type=custom_types.CliCaseInsensitiveChoice(["SIX_SSDS", "TWELVE_SSDS", "EIGHTEEN_SSDS", "TWENTY_FOUR_SSDS"]), help=u"""The shape of the Database Infrastructure. The shape determines the amount of CPU, storage, and memory resources allocated to the instance.""")
@cli_util.option('--cloud-control-plane-server1', required=True, help=u"""The IP address for the first control plane server.""")
@cli_util.option('--cloud-control-plane-server2', required=True, help=u"""The IP address for the second control plane server.""")
@cli_util.option('--netmask', required=True, help=u"""The netmask for the control plane network.""")
@cli_util.option('--gateway', required=True, help=u"""The gateway for the control plane network.""")
@cli_util.option('--dns-servers', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of DNS server IP addresses. Maximum of 3 allowed.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--ntp-servers', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of NTP server IP addresses. Maximum of 3 allowed.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--description', help=u"""Database Infrastructure description.""")
@cli_util.option('--admin-networkcidr', help=u"""The CIDR block for the system network. The system network is a private network in Database Infrastructure and is not connected to your corporate network. The system network is used for storage (ASM) traffic, high-performance interconnect traffic and administration of infrastructure components.""")
@cli_util.option('--data-disk-percentage', type=click.INT, help=u"""Percentage of disk space assigned for DATA disk group. Remaining disk space will get assiged to RECO disk group""")
@cli_util.option('--contacts', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of contacts for the Database Infrastructure.

This option is a JSON list with items of type InfrastructureContact.  For documentation on InfrastructureContact please see our API reference: https://docs.oracle.com/en-us/iaas/api/#/en/baseinfra/20251101/datatypes/InfrastructureContact.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--client-bond-mode', type=custom_types.CliCaseInsensitiveChoice(["ACTIVE_BACKUP", "LACP"]), help=u"""The network bonding mode for Client networks for the Database Infrastructure.""")
@cli_util.option('--backup-bond-mode', type=custom_types.CliCaseInsensitiveChoice(["ACTIVE_BACKUP", "LACP"]), help=u"""The network bonding mode for Backup networks for the Database Infrastructure.""")
@cli_util.option('--cps-bond-mode', type=custom_types.CliCaseInsensitiveChoice(["ACTIVE_BACKUP", "LACP"]), help=u"""The network bonding mode for CPS networks for the Database Infrastructure.""")
@cli_util.option('--client-bond-iface', type=custom_types.CliCaseInsensitiveChoice(["BTBOND1", "BTBOND2", "BTBOND3", "BTBOND4", "BTBOND5", "BTBOND6"]), help=u"""The network bonding interface for client network for the Database Infrastructure.""")
@cli_util.option('--backup-bond-iface', type=custom_types.CliCaseInsensitiveChoice(["BTBOND1", "BTBOND2", "BTBOND3", "BTBOND4", "BTBOND5", "BTBOND6"]), help=u"""The network bonding interface for backup network for the Database Infrastructure.""")
@cli_util.option('--cps-bond-iface', type=custom_types.CliCaseInsensitiveChoice(["BTBOND1", "BTBOND2", "BTBOND3", "BTBOND4", "BTBOND5", "BTBOND6"]), help=u"""The network bonding interface for CPS network for the Database Infrastructure.""")
@cli_util.option('--acfs-size-in-gbs', help=u"""The amount of storage (in GB) in the DATA disk group that is reserved for creating local storage for VM Clusters and application VMs.""")
@cli_util.option('--corporate-proxy', help=u"""The corporate network proxy for access to the control plane network. Oracle recommends using an HTTPS proxy when possible for enhanced security.""")
@cli_util.option('--vlan-id', help=u"""The CPS network VLAN ID.""")
@cli_util.option('--maintenance-window', 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. This tag option 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", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the state defined by --wait-for-state. Defaults to 30 seconds.""")
@json_skeleton_utils.get_cli_json_input_option({'contacts': {'module': 'datacc', 'class': 'list[InfrastructureContact]'}, 'dns-servers': {'module': 'datacc', 'class': 'list[string]'}, 'ntp-servers': {'module': 'datacc', 'class': 'list[string]'}, 'maintenance-window': {'module': 'datacc', 'class': 'MaintenanceWindow'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'datacc', '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={'contacts': {'module': 'datacc', 'class': 'list[InfrastructureContact]'}, 'dns-servers': {'module': 'datacc', 'class': 'list[string]'}, 'ntp-servers': {'module': 'datacc', 'class': 'list[string]'}, 'maintenance-window': {'module': 'datacc', 'class': 'MaintenanceWindow'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}}, output_type={'module': 'datacc', 'class': 'Infrastructure'})
@cli_util.wrap_exceptions
def create_infrastructure(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, compartment_id, display_name, system_model, shape, cloud_control_plane_server1, cloud_control_plane_server2, netmask, gateway, dns_servers, ntp_servers, description, admin_networkcidr, data_disk_percentage, contacts, client_bond_mode, backup_bond_mode, cps_bond_mode, client_bond_iface, backup_bond_iface, cps_bond_iface, acfs_size_in_gbs, corporate_proxy, vlan_id, maintenance_window, freeform_tags, defined_tags):

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

    _details = {}
    _details['compartmentId'] = compartment_id
    _details['displayName'] = display_name
    _details['systemModel'] = system_model
    _details['shape'] = shape
    _details['cloudControlPlaneServer1'] = cloud_control_plane_server1
    _details['cloudControlPlaneServer2'] = cloud_control_plane_server2
    _details['netmask'] = netmask
    _details['gateway'] = gateway
    _details['dnsServers'] = cli_util.parse_json_parameter("dns_servers", dns_servers)
    _details['ntpServers'] = cli_util.parse_json_parameter("ntp_servers", ntp_servers)

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

    if admin_networkcidr is not None:
        _details['adminNetworkcidr'] = admin_networkcidr

    if data_disk_percentage is not None:
        _details['dataDiskPercentage'] = data_disk_percentage

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

    if client_bond_mode is not None:
        _details['clientNetworkBondingMode'] = client_bond_mode

    if backup_bond_mode is not None:
        _details['backupNetworkBondingMode'] = backup_bond_mode

    if cps_bond_mode is not None:
        _details['cpsNetworkBondingMode'] = cps_bond_mode

    if client_bond_iface is not None:
        _details['clientNetworkBondingInterface'] = client_bond_iface

    if backup_bond_iface is not None:
        _details['backupNetworkBondingInterface'] = backup_bond_iface

    if cps_bond_iface is not None:
        _details['cpsNetworkBondingInterface'] = cps_bond_iface

    if acfs_size_in_gbs is not None:
        _details['acfsFileSystemStorageInGbs'] = acfs_size_in_gbs

    if corporate_proxy is not None:
        _details['corporateProxy'] = corporate_proxy

    if vlan_id is not None:
        _details['vlanId'] = vlan_id

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

    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('datacc', 'baseinfra', ctx)
    result = client.create_infrastructure(
        create_infrastructure_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@vm_cluster_network_group.command(name=cli_util.override('datacc.create_vm_cluster_network.command_name', 'create'), help=u"""Create an VM cluster on Database Infrastructure network using the specified details. \n[Command Reference](createVmClusterNetwork)""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment containing the VM cluster network.""")
@cli_util.option('--infrastructure-id', required=True, help=u"""The [OCID] of the Database Infrastructure.""")
@cli_util.option('--display-name', required=True, help=u"""The user-friendly name for the VM cluster network. The name does not need to be unique.""")
@cli_util.option('--vm-networks', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""Details of the client and backup networks.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--node-count', type=click.INT, help=u"""Count of virtual machines in this VM cluster.""")
@cli_util.option('--scans', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The SCAN details.

This option is a JSON list with items of type ScanDetails.  For documentation on ScanDetails please see our API reference: https://docs.oracle.com/en-us/iaas/api/#/en/baseinfra/20251101/datatypes/ScanDetails.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--listener-port', type=click.INT, help=u"""The listener TCP/IP port.""")
@cli_util.option('--listener-port-ssl', type=click.INT, help=u"""The listener TCP/IP SSL port. Default is 2484.""")
@cli_util.option('--dns-servers', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of DNS server IP addresses. Maximum of 3 allowed.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--ntp-servers', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of NTP server IP addresses. Maximum of 3 allowed.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--consumer-type', type=custom_types.CliCaseInsensitiveChoice(["INSTANCE", "CLUSTER"]), help=u"""Consumer type for the VM cluster network.""")
@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. This tag option 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", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the state defined by --wait-for-state. Defaults to 30 seconds.""")
@json_skeleton_utils.get_cli_json_input_option({'scans': {'module': 'datacc', 'class': 'list[ScanDetails]'}, 'dns-servers': {'module': 'datacc', 'class': 'list[string]'}, 'ntp-servers': {'module': 'datacc', 'class': 'list[string]'}, 'vm-networks': {'module': 'datacc', 'class': 'list[VmNetworkDetails]'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'datacc', '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={'scans': {'module': 'datacc', 'class': 'list[ScanDetails]'}, 'dns-servers': {'module': 'datacc', 'class': 'list[string]'}, 'ntp-servers': {'module': 'datacc', 'class': 'list[string]'}, 'vm-networks': {'module': 'datacc', 'class': 'list[VmNetworkDetails]'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}}, output_type={'module': 'datacc', 'class': 'VmClusterNetwork'})
@cli_util.wrap_exceptions
def create_vm_cluster_network(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, compartment_id, infrastructure_id, display_name, vm_networks, node_count, scans, listener_port, listener_port_ssl, dns_servers, ntp_servers, consumer_type, freeform_tags, defined_tags):

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

    _details = {}
    _details['compartmentId'] = compartment_id
    _details['infrastructureId'] = infrastructure_id
    _details['displayName'] = display_name
    _details['vmNetworks'] = cli_util.parse_json_parameter("vm_networks", vm_networks)

    if node_count is not None:
        _details['nodeCount'] = node_count

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

    if listener_port is not None:
        _details['listenerPort'] = listener_port

    if listener_port_ssl is not None:
        _details['listenerPortSsl'] = listener_port_ssl

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

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

    if consumer_type is not None:
        _details['consumerType'] = consumer_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('datacc', 'baseinfra', ctx)
    result = client.create_vm_cluster_network(
        create_vm_cluster_network_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@vm_instance_group.command(name=cli_util.override('datacc.create_vm_instance.command_name', 'create'), help=u"""Create an VM instance on Database Infrastructure using the specified details. \n[Command Reference](createVmInstance)""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment containing the VM instance.""")
@cli_util.option('--infrastructure-id', required=True, help=u"""The [OCID] of the Database Infrastructure.""")
@cli_util.option('--cpus-enabled', required=True, type=click.INT, help=u"""The number of CPU cores enabled for each VM instance.""")
@cli_util.option('--ssh-public-keys', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""List of public key used for SSH access to the VM instance.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--display-name', help=u"""VM instance display name. This name does not have to be unique, and is changeable.""")
@cli_util.option('--description', help=u"""VM instance description.""")
@cli_util.option('--memory-size-in-gbs', help=u"""The memory to be allocated in GBs.""")
@cli_util.option('--boot-storage-size-in-gbs', help=u"""Boot storage memory to be allocated in GBs.""")
@cli_util.option('--data-storage-size-in-gbs', help=u"""Data storage to be allocated in GBs.""")
@cli_util.option('--image-id', help=u"""The [OCID] of the VM custom instance uploaded.""")
@cli_util.option('--server-id', help=u"""The [OCID] of the compute node on which VM instance should be launched.""")
@cli_util.option('--domain-name', help=u"""The domain name of the VM instance.""")
@cli_util.option('--time-zone', help=u"""The time zone to use for the VM instance.""")
@cli_util.option('--dns-servers', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of DNS server IP addresses. Maximum of 3 allowed.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--ntp-servers', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of NTP server IP addresses. Maximum of 3 allowed.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--hostname', help=u"""The host name of the instance.""")
@cli_util.option('--ip-address', help=u"""The IP address of the instance.""")
@cli_util.option('--netmask', help=u"""The netmask of the VM instance network.""")
@cli_util.option('--gateway', help=u"""The gateway IP address of the VM instance network""")
@cli_util.option('--vlan-id', help=u"""The network VLAN ID.""")
@cli_util.option('--userdata', help=u"""Base64-encoded data to be used by Cloud-Init to run custom scripts or provide custom Cloud-Init configuration. For information about how to take advantage of user data, see the [Cloud-Init Documentation].""")
@cli_util.option('--metadata', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Custom metadata key/value pairs which can be used to: - Provide information to [Cloud-Init] to be used for various system initialization tasks. - Provide additional information which is exposed inside the instance context and can be queried or referenced by user-data scripts for dynamic configuration.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--vm-network-id', help=u"""The [OCID] of the VM Network.""")
@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('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. This tag option exists for cross-compatibility only. Example: `{\"bar-key\": \"value\"}`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--system-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Usage of system tag keys. These predefined keys are scoped to namespaces. Example: `{ \"orcl-cloud\": { \"free-tier-retained\": \"true\" } }`""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the state defined by --wait-for-state. Defaults to 30 seconds.""")
@json_skeleton_utils.get_cli_json_input_option({'ssh-public-keys': {'module': 'datacc', 'class': 'list[string]'}, 'dns-servers': {'module': 'datacc', 'class': 'list[string]'}, 'ntp-servers': {'module': 'datacc', 'class': 'list[string]'}, 'metadata': {'module': 'datacc', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}, 'system-tags': {'module': 'datacc', '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={'ssh-public-keys': {'module': 'datacc', 'class': 'list[string]'}, 'dns-servers': {'module': 'datacc', 'class': 'list[string]'}, 'ntp-servers': {'module': 'datacc', 'class': 'list[string]'}, 'metadata': {'module': 'datacc', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}, 'system-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}}, output_type={'module': 'datacc', 'class': 'VmInstance'})
@cli_util.wrap_exceptions
def create_vm_instance(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, compartment_id, infrastructure_id, cpus_enabled, ssh_public_keys, display_name, description, memory_size_in_gbs, boot_storage_size_in_gbs, data_storage_size_in_gbs, image_id, server_id, domain_name, time_zone, dns_servers, ntp_servers, hostname, ip_address, netmask, gateway, vlan_id, userdata, metadata, vm_network_id, defined_tags, freeform_tags, system_tags):

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

    _details = {}
    _details['compartmentId'] = compartment_id
    _details['infrastructureId'] = infrastructure_id
    _details['cpusEnabled'] = cpus_enabled
    _details['sshPublicKeys'] = cli_util.parse_json_parameter("ssh_public_keys", ssh_public_keys)

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

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

    if memory_size_in_gbs is not None:
        _details['memorySizeInGBs'] = memory_size_in_gbs

    if boot_storage_size_in_gbs is not None:
        _details['bootStorageSizeInGBs'] = boot_storage_size_in_gbs

    if data_storage_size_in_gbs is not None:
        _details['dataStorageSizeInGBs'] = data_storage_size_in_gbs

    if image_id is not None:
        _details['imageId'] = image_id

    if server_id is not None:
        _details['serverId'] = server_id

    if domain_name is not None:
        _details['domainName'] = domain_name

    if time_zone is not None:
        _details['timeZone'] = time_zone

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

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

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

    if ip_address is not None:
        _details['ipAddress'] = ip_address

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

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

    if vlan_id is not None:
        _details['vlanId'] = vlan_id

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

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

    if vm_network_id is not None:
        _details['vmNetworkId'] = vm_network_id

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

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

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

    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.create_vm_instance(
        create_vm_instance_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@infrastructure_group.command(name=cli_util.override('datacc.delete_infrastructure.command_name', 'delete'), help=u"""Delete the Database Infrastructure that has the specified [OCID]. It must be called once the resource usage is complete. \n[Command Reference](deleteInfrastructure)""")
@cli_util.option('--infrastructure-id', required=True, help=u"""The [OCID] of the Database Infrastructure.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--is-force-delete', type=click.BOOL, help=u"""When set to `true`, infrastructure will be deleted even if it has dependent resources. If set to `false`, deletion will fail if the infrastructure has dependent resources. Default is `false`.""")
@cli_util.confirm_delete_option
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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_infrastructure(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, infrastructure_id, if_match, is_force_delete):

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

    kwargs = {}
    if if_match is not None:
        kwargs['if_match'] = if_match
    if is_force_delete is not None:
        kwargs['is_force_delete_infrastructure'] = is_force_delete
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.delete_infrastructure(
        infrastructure_id=infrastructure_id,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request entered the specified state. Please retrieve the work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@vm_cluster_network_group.command(name=cli_util.override('datacc.delete_vm_cluster_network.command_name', 'delete'), help=u"""Delete the VM cluster network on Database Infrastructure that has the specified [OCID]. It must be called once the resource usage is complete. \n[Command Reference](deleteVmClusterNetwork)""")
@cli_util.option('--vm-cluster-network-id', required=True, help=u"""The [OCID] of the VM cluster network.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.confirm_delete_option
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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_vm_cluster_network(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, vm_cluster_network_id, if_match):

    if isinstance(vm_cluster_network_id, six.string_types) and len(vm_cluster_network_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-cluster-network-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('datacc', 'baseinfra', ctx)
    result = client.delete_vm_cluster_network(
        vm_cluster_network_id=vm_cluster_network_id,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request entered the specified state. Please retrieve the work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@vm_instance_group.command(name=cli_util.override('datacc.delete_vm_instance.command_name', 'delete'), help=u"""Delete the VM instance on Database Infrastructure that has the specified [OCID]. It must be called once the resource usage is complete. \n[Command Reference](deleteVmInstance)""")
@cli_util.option('--vm-instance-id', required=True, help=u"""The [OCID] of the VM instance.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.confirm_delete_option
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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_vm_instance(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, vm_instance_id, if_match):

    if isinstance(vm_instance_id, six.string_types) and len(vm_instance_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-instance-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('datacc', 'baseinfra', ctx)
    result = client.delete_vm_instance(
        vm_instance_id=vm_instance_id,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request entered the specified state. Please retrieve the work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@infrastructure_group.command(name=cli_util.override('datacc.download_infrastructure_config_file.command_name', 'download-config-file'), help=u"""Downloads the configuration file for the specified Database Infrastructure Cloud@Customer. \n[Command Reference](downloadInfrastructureConfigFile)""")
@cli_util.option('--infrastructure-id', required=True, help=u"""The [OCID] of the Database Infrastructure.""")
@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 download_infrastructure_config_file(ctx, from_json, file, infrastructure_id):

    if isinstance(infrastructure_id, six.string_types) and len(infrastructure_id.strip()) == 0:
        raise click.UsageError('Parameter --infrastructure-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('datacc', 'baseinfra', ctx)
    result = client.download_infrastructure_config_file(
        infrastructure_id=infrastructure_id,
        **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()


@infrastructure_group.command(name=cli_util.override('datacc.download_infrastructure_validation_script.command_name', 'download-validation-script'), help=u"""Downloads the validation script for the specified Database Infrastructure Cloud@Customer. \n[Command Reference](downloadInfrastructureValidationScript)""")
@cli_util.option('--infrastructure-id', required=True, help=u"""The [OCID] of the Database Infrastructure.""")
@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 download_infrastructure_validation_script(ctx, from_json, file, infrastructure_id):

    if isinstance(infrastructure_id, six.string_types) and len(infrastructure_id.strip()) == 0:
        raise click.UsageError('Parameter --infrastructure-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('datacc', 'baseinfra', ctx)
    result = client.download_infrastructure_validation_script(
        infrastructure_id=infrastructure_id,
        **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()


@vm_cluster_network_group.command(name=cli_util.override('datacc.generate_recommended_vm_cluster_network.command_name', 'generate-recommended'), help=u"""Generates an VM cluster network configuration using the specified details. \n[Command Reference](generateRecommendedVmClusterNetwork)""")
@cli_util.option('--infrastructure-id', required=True, help=u"""The [OCID] of the Database Infrastructure.""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment containing the VM cluster network.""")
@cli_util.option('--display-name', required=True, help=u"""The user-friendly name for the VM cluster network. The name does not need to be unique.""")
@cli_util.option('--vm-networks', required=True, type=custom_types.CLI_COMPLEX_TYPE, help=u"""Details of the client and backup networks.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--node-count', type=click.INT, help=u"""Count of virtual machines in this VM cluster.""")
@cli_util.option('--listener-port', type=click.INT, help=u"""The listener TCP/IP port.""")
@cli_util.option('--listener-port-ssl', type=click.INT, help=u"""The listener TCP/IP SSL port. Default is 2484.""")
@cli_util.option('--dns-servers', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of DNS server IP addresses. Maximum of 3 allowed.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--ntp-servers', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of NTP server IP addresses. Maximum of 3 allowed.""" + 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('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. This tag option exists for cross-compatibility only. Example: `{\"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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the state defined by --wait-for-state. Defaults to 30 seconds.""")
@json_skeleton_utils.get_cli_json_input_option({'vm-networks': {'module': 'datacc', 'class': 'list[InfoVmNetworkDetails]'}, 'dns-servers': {'module': 'datacc', 'class': 'list[string]'}, 'ntp-servers': {'module': 'datacc', 'class': 'list[string]'}, 'defined-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'vm-networks': {'module': 'datacc', 'class': 'list[InfoVmNetworkDetails]'}, 'dns-servers': {'module': 'datacc', 'class': 'list[string]'}, 'ntp-servers': {'module': 'datacc', 'class': 'list[string]'}, 'defined-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}}, output_type={'module': 'datacc', 'class': 'CreateVmClusterNetworkDetails'})
@cli_util.wrap_exceptions
def generate_recommended_vm_cluster_network(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, infrastructure_id, compartment_id, display_name, vm_networks, node_count, listener_port, listener_port_ssl, dns_servers, ntp_servers, defined_tags, freeform_tags, if_match):

    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 = {}
    _details['infrastructureId'] = infrastructure_id
    _details['compartmentId'] = compartment_id
    _details['displayName'] = display_name
    _details['vmNetworks'] = cli_util.parse_json_parameter("vm_networks", vm_networks)

    if node_count is not None:
        _details['nodeCount'] = node_count

    if listener_port is not None:
        _details['listenerPort'] = listener_port

    if listener_port_ssl is not None:
        _details['listenerPortSsl'] = listener_port_ssl

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

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

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

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

    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.generate_recommended_vm_cluster_network(
        generate_recommended_vm_cluster_network_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@infrastructure_group.command(name=cli_util.override('datacc.get_infrastructure.command_name', 'get'), help=u"""Obtain the Database Infrastructure that has the specified [OCID]. \n[Command Reference](getInfrastructure)""")
@cli_util.option('--infrastructure-id', required=True, help=u"""The [OCID] of the Database Infrastructure.""")
@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': 'datacc', 'class': 'Infrastructure'})
@cli_util.wrap_exceptions
def get_infrastructure(ctx, from_json, infrastructure_id):

    if isinstance(infrastructure_id, six.string_types) and len(infrastructure_id.strip()) == 0:
        raise click.UsageError('Parameter --infrastructure-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('datacc', 'baseinfra', ctx)
    result = client.get_infrastructure(
        infrastructure_id=infrastructure_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@infrastructure_scale_option_group.command(name=cli_util.override('datacc.get_infrastructure_scale_option.command_name', 'get'), help=u"""Get the available scale options for the infrastructure that has the specified [OCID]. \n[Command Reference](getInfrastructureScaleOption)""")
@cli_util.option('--infrastructure-id', required=True, help=u"""The [OCID] of the Database Infrastructure.""")
@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': 'datacc', 'class': 'InfrastructureScaleOption'})
@cli_util.wrap_exceptions
def get_infrastructure_scale_option(ctx, from_json, infrastructure_id):

    if isinstance(infrastructure_id, six.string_types) and len(infrastructure_id.strip()) == 0:
        raise click.UsageError('Parameter --infrastructure-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('datacc', 'baseinfra', ctx)
    result = client.get_infrastructure_scale_option(
        infrastructure_id=infrastructure_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@maintenance_execution_group.command(name=cli_util.override('datacc.get_maintenance_execution.command_name', 'get'), help=u"""Gets information about the specified [OCID]. \n[Command Reference](getMaintenanceExecution)""")
@cli_util.option('--maintenance-execution-id', required=True, help=u"""The maintenance execution OCID.""")
@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': 'datacc', 'class': 'MaintenanceExecution'})
@cli_util.wrap_exceptions
def get_maintenance_execution(ctx, from_json, maintenance_execution_id):

    if isinstance(maintenance_execution_id, six.string_types) and len(maintenance_execution_id.strip()) == 0:
        raise click.UsageError('Parameter --maintenance-execution-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('datacc', 'baseinfra', ctx)
    result = client.get_maintenance_execution(
        maintenance_execution_id=maintenance_execution_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@maintenance_run_group.command(name=cli_util.override('datacc.get_maintenance_run.command_name', 'get'), help=u"""Gets information about the specified [OCID]. \n[Command Reference](getMaintenanceRun)""")
@cli_util.option('--maintenance-run-id', required=True, help=u"""The maintenance run OCID.""")
@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': 'datacc', 'class': 'MaintenanceRun'})
@cli_util.wrap_exceptions
def get_maintenance_run(ctx, from_json, maintenance_run_id):

    if isinstance(maintenance_run_id, six.string_types) and len(maintenance_run_id.strip()) == 0:
        raise click.UsageError('Parameter --maintenance-run-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('datacc', 'baseinfra', ctx)
    result = client.get_maintenance_run(
        maintenance_run_id=maintenance_run_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@vm_cluster_network_group.command(name=cli_util.override('datacc.get_vm_cluster_network.command_name', 'get'), help=u"""Obtain the VM cluster network on Database Infrastructure that has the specified [OCID]. \n[Command Reference](getVmClusterNetwork)""")
@cli_util.option('--vm-cluster-network-id', required=True, help=u"""The [OCID] of the VM cluster network.""")
@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': 'datacc', 'class': 'VmClusterNetwork'})
@cli_util.wrap_exceptions
def get_vm_cluster_network(ctx, from_json, vm_cluster_network_id):

    if isinstance(vm_cluster_network_id, six.string_types) and len(vm_cluster_network_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-cluster-network-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('datacc', 'baseinfra', ctx)
    result = client.get_vm_cluster_network(
        vm_cluster_network_id=vm_cluster_network_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@vm_instance_group.command(name=cli_util.override('datacc.get_vm_instance.command_name', 'get'), help=u"""Obtain the VM instance on Database Infrastructure that has the specified [OCID]. \n[Command Reference](getVmInstance)""")
@cli_util.option('--vm-instance-id', required=True, help=u"""The [OCID] of the VM instance.""")
@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': 'datacc', 'class': 'VmInstance'})
@cli_util.wrap_exceptions
def get_vm_instance(ctx, from_json, vm_instance_id):

    if isinstance(vm_instance_id, six.string_types) and len(vm_instance_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-instance-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('datacc', 'baseinfra', ctx)
    result = client.get_vm_instance(
        vm_instance_id=vm_instance_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@work_request_group.command(name=cli_util.override('datacc.get_work_request.command_name', 'get'), help=u"""Get the status of the work request having the specified work request [OCID]. \n[Command Reference](getWorkRequest)""")
@cli_util.option('--work-request-id', required=True, help=u"""The [OCID] of the asynchronous work 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': 'datacc', 'class': 'WorkRequest'})
@cli_util.wrap_exceptions
def get_work_request(ctx, from_json, work_request_id):

    if isinstance(work_request_id, six.string_types) and len(work_request_id.strip()) == 0:
        raise click.UsageError('Parameter --work-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('datacc', 'baseinfra', ctx)
    result = client.get_work_request(
        work_request_id=work_request_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)


@infrastructure_summary_group.command(name=cli_util.override('datacc.list_infrastructures.command_name', 'list'), help=u"""Obtain a list of Database Infrastructures. \n[Command Reference](listInfrastructures)""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment. For list operations, you may provide the tenant [OCID] in this field. When a tenant OCID is provided, it will be validated against the caller's tenant and then treated as tenant scope (compartmentId filtering is not applied).""")
@cli_util.option('--display-name', help=u"""A filter to return resources that match the entire display name given. The match is case sensitive.""")
@cli_util.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["CREATING", "REQUIRES_VALIDATION", "VALIDATING", "VALIDATION_FAILED", "REQUIRES_ACTIVATION", "ACTIVATING", "ACTIVE", "ACTIVATION_FAILED", "FAILED", "UPDATING", "DELETING", "DELETED", "DISCONNECTED", "MAINTENANCE_IN_PROGRESS"]), multiple=True, help=u"""A filter to return resources that match the specified lifecycle state.""")
@cli_util.option('--limit', type=click.INT, help=u"""The maximum number of items to return in a page.""")
@cli_util.option('--page', help=u"""The page token representing the page at which you want to start retrieving results. This token is usually retrieved from a previous list call.""")
@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order that you want to use, which is either `ASC` or `DESC`.""")
@cli_util.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["timeCreated", "displayName", "buildIdentifier"]), help=u"""The field by which you want to sort. You can provide only one type of sort order. The default order for `timeCreated` is descending. The default order for `displayName` is ascending. If no value is specified, then `timeCreated` is the default. When listing software images within the same `version`, using `sortBy=buildIdentifier` is recommended. `buildIdentifier` is a monotonically increasing, time-ordered string marker (yyyy-mm-dd-hh:mm:ss) stored with the image.""")
@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': 'datacc', 'class': 'InfrastructureCollection'})
@cli_util.wrap_exceptions
def list_infrastructures(ctx, from_json, all_pages, page_size, compartment_id, display_name, lifecycle_state, limit, page, sort_order, sort_by):

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

    kwargs = {}
    if display_name is not None:
        kwargs['display_name'] = display_name
    if lifecycle_state is not None and len(lifecycle_state) > 0:
        kwargs['lifecycle_state'] = lifecycle_state
    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
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    if all_pages:
        if page_size:
            kwargs['limit'] = page_size

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


@maintenance_execution_group.command(name=cli_util.override('datacc.list_maintenance_executions.command_name', 'list'), help=u"""Gets a list of the maintenance executions in the specified compartment. \n[Command Reference](listMaintenanceExecutions)""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment. For list operations, you may provide the tenant [OCID] in this field. When a tenant OCID is provided, it will be validated against the caller's tenant and then treated as tenant scope (compartmentId filtering is not applied).""")
@cli_util.option('--display-name', help=u"""A filter to return resources that match the entire display name given. The match is case sensitive.""")
@cli_util.option('--infrastructure-id', help=u"""The Database Infrastructure ID.""")
@cli_util.option('--target-resource-type', type=custom_types.CliCaseInsensitiveChoice(["DB_CC_INFRASTRUCTURE"]), help=u"""The type of the target resource.""")
@cli_util.option('--maintenance-type', type=custom_types.CliCaseInsensitiveChoice(["PLANNED", "UNPLANNED"]), help=u"""The maintenance type.""")
@cli_util.option('--maintenance-run-id', help=u"""The maintenance run OCID.""")
@cli_util.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["CREATING", "SCHEDULED", "IN_PROGRESS", "SUCCEEDED", "SKIPPED", "FAILED", "UPDATING", "DELETING", "DELETED", "CANCELED", "PARTIAL_SUCCESS"]), help=u"""A filter to return only resources that match the given lifecycle state exactly.""")
@cli_util.option('--maintenance-subtype', type=custom_types.CliCaseInsensitiveChoice(["YEARLY", "HALFYEARLY", "QUARTERLY", "MONTHLY", "DAILY", "HARDWARE", "CRITICAL", "INFRA_UPDATE", "CPS_SERVICES_UPDATE", "CPS_VM_UPDATE", "SECURITY_MONTHLY"]), help=u"""The sub-type of the maintenance run.""")
@cli_util.option('--time-accepted-less-than-or-equal-to', type=custom_types.CLI_DATETIME, help=u"""Filter maintenance run for before given time.""" + custom_types.CLI_DATETIME.VALID_DATETIME_CLI_HELP_MESSAGE)
@cli_util.option('--time-accepted-greater-than-or-equal-to', type=custom_types.CLI_DATETIME, help=u"""Filter maintenance run for after given time.""" + custom_types.CLI_DATETIME.VALID_DATETIME_CLI_HELP_MESSAGE)
@cli_util.option('--type', type=custom_types.CliCaseInsensitiveChoice(["NOTIFY", "EXECUTE"]), help=u"""The maintenance execution type.""")
@cli_util.option('--limit', type=click.INT, help=u"""The maximum number of items to return in a page.""")
@cli_util.option('--page', help=u"""The page token representing the page at which you want to start retrieving results. This token is usually retrieved from a previous list call.""")
@cli_util.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["timeCreated", "displayName", "buildIdentifier"]), help=u"""The field by which you want to sort. You can provide only one type of sort order. The default order for `timeCreated` is descending. The default order for `displayName` is ascending. If no value is specified, then `timeCreated` is the default. When listing software images within the same `version`, using `sortBy=buildIdentifier` is recommended. `buildIdentifier` is a monotonically increasing, time-ordered string marker (yyyy-mm-dd-hh:mm:ss) stored with the image.""")
@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order that you want to use, which is either `ASC` or `DESC`.""")
@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': 'datacc', 'class': 'MaintenanceExecutionCollection'})
@cli_util.wrap_exceptions
def list_maintenance_executions(ctx, from_json, all_pages, page_size, compartment_id, display_name, infrastructure_id, target_resource_type, maintenance_type, maintenance_run_id, lifecycle_state, maintenance_subtype, time_accepted_less_than_or_equal_to, time_accepted_greater_than_or_equal_to, type, limit, page, sort_by, sort_order):

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

    kwargs = {}
    if display_name is not None:
        kwargs['display_name'] = display_name
    if infrastructure_id is not None:
        kwargs['infrastructure_id'] = infrastructure_id
    if target_resource_type is not None:
        kwargs['target_resource_type'] = target_resource_type
    if maintenance_type is not None:
        kwargs['maintenance_type'] = maintenance_type
    if maintenance_run_id is not None:
        kwargs['maintenance_run_id'] = maintenance_run_id
    if lifecycle_state is not None:
        kwargs['lifecycle_state'] = lifecycle_state
    if maintenance_subtype is not None:
        kwargs['maintenance_subtype'] = maintenance_subtype
    if time_accepted_less_than_or_equal_to is not None:
        kwargs['time_accepted_less_than_or_equal_to'] = time_accepted_less_than_or_equal_to
    if time_accepted_greater_than_or_equal_to is not None:
        kwargs['time_accepted_greater_than_or_equal_to'] = time_accepted_greater_than_or_equal_to
    if type is not None:
        kwargs['type'] = type
    if limit is not None:
        kwargs['limit'] = limit
    if page is not None:
        kwargs['page'] = page
    if sort_by is not None:
        kwargs['sort_by'] = sort_by
    if sort_order is not None:
        kwargs['sort_order'] = sort_order
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    if all_pages:
        if page_size:
            kwargs['limit'] = page_size

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


@maintenance_run_group.command(name=cli_util.override('datacc.list_maintenance_runs.command_name', 'list'), help=u"""Gets a list of the maintenance runs in the specified compartment. \n[Command Reference](listMaintenanceRuns)""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment. For list operations, you may provide the tenant [OCID] in this field. When a tenant OCID is provided, it will be validated against the caller's tenant and then treated as tenant scope (compartmentId filtering is not applied).""")
@cli_util.option('--display-name', help=u"""A filter to return resources that match the entire display name given. The match is case sensitive.""")
@cli_util.option('--infrastructure-id', help=u"""The Database Infrastructure ID.""")
@cli_util.option('--target-resource-type', type=custom_types.CliCaseInsensitiveChoice(["DB_CC_INFRASTRUCTURE"]), help=u"""The type of the target resource.""")
@cli_util.option('--maintenance-type', type=custom_types.CliCaseInsensitiveChoice(["PLANNED", "UNPLANNED"]), help=u"""The maintenance type.""")
@cli_util.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["CREATING", "SCHEDULED", "IN_PROGRESS", "SUCCEEDED", "SKIPPED", "FAILED", "UPDATING", "DELETING", "DELETED", "CANCELED", "PARTIAL_SUCCESS"]), help=u"""A filter to return only resources that match the given lifecycle state exactly.""")
@cli_util.option('--maintenance-subtype', type=custom_types.CliCaseInsensitiveChoice(["YEARLY", "HALFYEARLY", "QUARTERLY", "MONTHLY", "DAILY", "HARDWARE", "CRITICAL", "INFRA_UPDATE", "CPS_SERVICES_UPDATE", "CPS_VM_UPDATE", "SECURITY_MONTHLY"]), help=u"""The sub-type of the maintenance run.""")
@cli_util.option('--time-accepted-less-than-or-equal-to', type=custom_types.CLI_DATETIME, help=u"""Filter maintenance run for before given time.""" + custom_types.CLI_DATETIME.VALID_DATETIME_CLI_HELP_MESSAGE)
@cli_util.option('--time-accepted-greater-than-or-equal-to', type=custom_types.CLI_DATETIME, help=u"""Filter maintenance run for after given time.""" + 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 in a page.""")
@cli_util.option('--page', help=u"""The page token representing the page at which you want to start retrieving results. This token is usually retrieved from a previous list call.""")
@cli_util.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["timeCreated", "displayName", "buildIdentifier"]), help=u"""The field by which you want to sort. You can provide only one type of sort order. The default order for `timeCreated` is descending. The default order for `displayName` is ascending. If no value is specified, then `timeCreated` is the default. When listing software images within the same `version`, using `sortBy=buildIdentifier` is recommended. `buildIdentifier` is a monotonically increasing, time-ordered string marker (yyyy-mm-dd-hh:mm:ss) stored with the image.""")
@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order that you want to use, which is either `ASC` or `DESC`.""")
@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': 'datacc', 'class': 'MaintenanceRunCollection'})
@cli_util.wrap_exceptions
def list_maintenance_runs(ctx, from_json, all_pages, page_size, compartment_id, display_name, infrastructure_id, target_resource_type, maintenance_type, lifecycle_state, maintenance_subtype, time_accepted_less_than_or_equal_to, time_accepted_greater_than_or_equal_to, limit, page, sort_by, sort_order):

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

    kwargs = {}
    if display_name is not None:
        kwargs['display_name'] = display_name
    if infrastructure_id is not None:
        kwargs['infrastructure_id'] = infrastructure_id
    if target_resource_type is not None:
        kwargs['target_resource_type'] = target_resource_type
    if maintenance_type is not None:
        kwargs['maintenance_type'] = maintenance_type
    if lifecycle_state is not None:
        kwargs['lifecycle_state'] = lifecycle_state
    if maintenance_subtype is not None:
        kwargs['maintenance_subtype'] = maintenance_subtype
    if time_accepted_less_than_or_equal_to is not None:
        kwargs['time_accepted_less_than_or_equal_to'] = time_accepted_less_than_or_equal_to
    if time_accepted_greater_than_or_equal_to is not None:
        kwargs['time_accepted_greater_than_or_equal_to'] = time_accepted_greater_than_or_equal_to
    if limit is not None:
        kwargs['limit'] = limit
    if page is not None:
        kwargs['page'] = page
    if sort_by is not None:
        kwargs['sort_by'] = sort_by
    if sort_order is not None:
        kwargs['sort_order'] = sort_order
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    if all_pages:
        if page_size:
            kwargs['limit'] = page_size

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


@vm_cluster_network_summary_group.command(name=cli_util.override('datacc.list_vm_cluster_networks.command_name', 'list'), help=u"""Obtain a list of VM cluster networks on Database Infrastructure. \n[Command Reference](listVmClusterNetworks)""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment. For list operations, you may provide the tenant [OCID] in this field. When a tenant OCID is provided, it will be validated against the caller's tenant and then treated as tenant scope (compartmentId filtering is not applied).""")
@cli_util.option('--display-name', help=u"""A filter to return resources that match the entire display name given. The match is case sensitive.""")
@cli_util.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["CREATING", "REQUIRES_VALIDATION", "VALIDATING", "VALIDATED", "VALIDATION_FAILED", "UPDATING", "ALLOCATED", "DELETING", "DELETED"]), multiple=True, help=u"""A filter to return resources that match the specified lifecycle state.""")
@cli_util.option('--is-scan-enabled', type=click.BOOL, help=u"""A filter to return VM cluster network resources that matches the specified value.""")
@cli_util.option('--limit', type=click.INT, help=u"""The maximum number of items to return in a page.""")
@cli_util.option('--page', help=u"""The page token representing the page at which you want to start retrieving results. This token is usually retrieved from a previous list call.""")
@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order that you want to use, which is either `ASC` or `DESC`.""")
@cli_util.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["timeCreated", "displayName", "buildIdentifier"]), help=u"""The field by which you want to sort. You can provide only one type of sort order. The default order for `timeCreated` is descending. The default order for `displayName` is ascending. If no value is specified, then `timeCreated` is the default. When listing software images within the same `version`, using `sortBy=buildIdentifier` is recommended. `buildIdentifier` is a monotonically increasing, time-ordered string marker (yyyy-mm-dd-hh:mm:ss) stored with the image.""")
@cli_util.option('--infrastructure-id', help=u"""The [OCID] of the Database Infrastructure.""")
@cli_util.option('--node-count', type=click.INT, help=u"""Count of virtual machines in this VM cluster.""")
@cli_util.option('--vm-network-consumer-type', type=custom_types.CliCaseInsensitiveChoice(["INSTANCE", "CLUSTER"]), help=u"""VM network consumer type.""")
@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': 'datacc', 'class': 'VmClusterNetworkCollection'})
@cli_util.wrap_exceptions
def list_vm_cluster_networks(ctx, from_json, all_pages, page_size, compartment_id, display_name, lifecycle_state, is_scan_enabled, limit, page, sort_order, sort_by, infrastructure_id, node_count, vm_network_consumer_type):

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

    kwargs = {}
    if display_name is not None:
        kwargs['display_name'] = display_name
    if lifecycle_state is not None and len(lifecycle_state) > 0:
        kwargs['lifecycle_state'] = lifecycle_state
    if is_scan_enabled is not None:
        kwargs['is_scan_enabled'] = is_scan_enabled
    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 infrastructure_id is not None:
        kwargs['infrastructure_id'] = infrastructure_id
    if node_count is not None:
        kwargs['node_count'] = node_count
    if vm_network_consumer_type is not None:
        kwargs['vm_network_consumer_type'] = vm_network_consumer_type
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    if all_pages:
        if page_size:
            kwargs['limit'] = page_size

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


@vm_instance_summary_group.command(name=cli_util.override('datacc.list_vm_instances.command_name', 'list'), help=u"""Obtain a list of VM instances. \n[Command Reference](listVmInstances)""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment. For list operations, you may provide the tenant [OCID] in this field. When a tenant OCID is provided, it will be validated against the caller's tenant and then treated as tenant scope (compartmentId filtering is not applied).""")
@cli_util.option('--display-name', help=u"""A filter to return resources that match the entire display name given. The match is case sensitive.""")
@cli_util.option('--lifecycle-state', type=custom_types.CliCaseInsensitiveChoice(["CREATING", "ACTIVE", "INACTIVE", "UPDATING", "DELETING", "DELETED"]), multiple=True, help=u"""A filter to return resources that match the specified lifecycle state.""")
@cli_util.option('--limit', type=click.INT, help=u"""The maximum number of items to return in a page.""")
@cli_util.option('--page', help=u"""The page token representing the page at which you want to start retrieving results. This token is usually retrieved from a previous list call.""")
@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order that you want to use, which is either `ASC` or `DESC`.""")
@cli_util.option('--sort-by', type=custom_types.CliCaseInsensitiveChoice(["timeCreated", "displayName", "buildIdentifier"]), help=u"""The field by which you want to sort. You can provide only one type of sort order. The default order for `timeCreated` is descending. The default order for `displayName` is ascending. If no value is specified, then `timeCreated` is the default. When listing software images within the same `version`, using `sortBy=buildIdentifier` is recommended. `buildIdentifier` is a monotonically increasing, time-ordered string marker (yyyy-mm-dd-hh:mm:ss) stored with the image.""")
@cli_util.option('--infrastructure-id', help=u"""The [OCID] of the Database Infrastructure.""")
@cli_util.option('--base-server-id', help=u"""The [OCID] of the Database Infrastructure Server Id.""")
@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': 'datacc', 'class': 'VmInstanceCollection'})
@cli_util.wrap_exceptions
def list_vm_instances(ctx, from_json, all_pages, page_size, compartment_id, display_name, lifecycle_state, limit, page, sort_order, sort_by, infrastructure_id, base_server_id):

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

    kwargs = {}
    if display_name is not None:
        kwargs['display_name'] = display_name
    if lifecycle_state is not None and len(lifecycle_state) > 0:
        kwargs['lifecycle_state'] = lifecycle_state
    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 infrastructure_id is not None:
        kwargs['infrastructure_id'] = infrastructure_id
    if base_server_id is not None:
        kwargs['base_server_id'] = base_server_id
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    if all_pages:
        if page_size:
            kwargs['limit'] = page_size

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


@work_request_error_group.command(name=cli_util.override('datacc.list_work_request_errors.command_name', 'list'), help=u"""View the list of errors for the work request that have the specified work request [OCID]. \n[Command Reference](listWorkRequestErrors)""")
@cli_util.option('--work-request-id', required=True, help=u"""The [OCID] of the asynchronous work request.""")
@cli_util.option('--page', help=u"""The page token representing the page at which you want to start retrieving results. This token is usually retrieved from a previous list call.""")
@cli_util.option('--limit', type=click.INT, help=u"""The maximum number of items to return in a page.""")
@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order that you want to use, which is either `ASC` or `DESC`.""")
@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': 'datacc', 'class': 'WorkRequestErrorCollection'})
@cli_util.wrap_exceptions
def list_work_request_errors(ctx, from_json, all_pages, page_size, work_request_id, page, limit, sort_order):

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

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

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

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


@work_request_log_entry_group.command(name=cli_util.override('datacc.list_work_request_logs.command_name', 'list'), help=u"""View the log entries for the work request that have the specified work request [OCID]. \n[Command Reference](listWorkRequestLogs)""")
@cli_util.option('--work-request-id', required=True, help=u"""The [OCID] of the asynchronous work request.""")
@cli_util.option('--page', help=u"""The page token representing the page at which you want to start retrieving results. This token is usually retrieved from a previous list call.""")
@cli_util.option('--limit', type=click.INT, help=u"""The maximum number of items to return in a page.""")
@cli_util.option('--sort-order', type=custom_types.CliCaseInsensitiveChoice(["ASC", "DESC"]), help=u"""The sort order that you want to use, which is either `ASC` or `DESC`.""")
@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': 'datacc', 'class': 'WorkRequestLogEntryCollection'})
@cli_util.wrap_exceptions
def list_work_request_logs(ctx, from_json, all_pages, page_size, work_request_id, page, limit, sort_order):

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

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

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

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


@work_request_group.command(name=cli_util.override('datacc.list_work_requests.command_name', 'list'), help=u"""View a list of work request details in the specified compartment. \n[Command Reference](listWorkRequests)""")
@cli_util.option('--compartment-id', required=True, help=u"""The [OCID] of the compartment. For list operations, you may provide the tenant [OCID] in this field. When a tenant OCID is provided, it will be validated against the caller's tenant and then treated as tenant scope (compartmentId filtering is not applied).""")
@cli_util.option('--resource-id', help=u"""The [OCID] of the work request resource.""")
@cli_util.option('--page', help=u"""The page token representing the page at which you want to start retrieving results. This token is usually retrieved from a previous list call.""")
@cli_util.option('--limit', type=click.INT, help=u"""The maximum number of items to return in a page.""")
@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': 'datacc', 'class': 'WorkRequestCollection'})
@cli_util.wrap_exceptions
def list_work_requests(ctx, from_json, all_pages, page_size, compartment_id, resource_id, page, limit):

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

    kwargs = {}
    if resource_id is not None:
        kwargs['resource_id'] = resource_id
    if page is not None:
        kwargs['page'] = page
    if limit is not None:
        kwargs['limit'] = limit
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    if all_pages:
        if page_size:
            kwargs['limit'] = page_size

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


@vm_instance_group.command(name=cli_util.override('datacc.migrate_vm_instance.command_name', 'migrate'), help=u"""Migrate the VM instance on Database Infrastructure that has the specified [OCID]. \n[Command Reference](migrateVmInstance)""")
@cli_util.option('--vm-instance-id', required=True, help=u"""The [OCID] of the VM instance.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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 migrate_vm_instance(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, vm_instance_id, if_match):

    if isinstance(vm_instance_id, six.string_types) and len(vm_instance_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-instance-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('datacc', 'baseinfra', ctx)
    result = client.migrate_vm_instance(
        vm_instance_id=vm_instance_id,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@maintenance_run_group.command(name=cli_util.override('datacc.reschedule_maintenance_run.command_name', 'reschedule'), help=u"""Reschedules the specified maintenance run by providing a new `timeScheduled` value. Only maintenance runs in eligible states may be rescheduled. \n[Command Reference](rescheduleMaintenanceRun)""")
@cli_util.option('--maintenance-run-id', required=True, help=u"""The maintenance run OCID.""")
@cli_util.option('--time-scheduled', required=True, type=custom_types.CLI_DATETIME, help=u"""The new date and time for the scheduled maintenance run.""" + custom_types.CLI_DATETIME.VALID_DATETIME_CLI_HELP_MESSAGE)
@cli_util.option('--reason', help=u"""The reason for rescheduling the maintenance run.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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': 'datacc', 'class': 'MaintenanceRun'})
@cli_util.wrap_exceptions
def reschedule_maintenance_run(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, maintenance_run_id, time_scheduled, reason, if_match):

    if isinstance(maintenance_run_id, six.string_types) and len(maintenance_run_id.strip()) == 0:
        raise click.UsageError('Parameter --maintenance-run-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 = {}
    _details['timeScheduled'] = time_scheduled

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

    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.reschedule_maintenance_run(
        maintenance_run_id=maintenance_run_id,
        reschedule_maintenance_run_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@vm_instance_group.command(name=cli_util.override('datacc.restart_vm_instance.command_name', 'restart'), help=u"""Restart the VM instance on Database Infrastructure that has the specified [OCID]. \n[Command Reference](restartVmInstance)""")
@cli_util.option('--vm-instance-id', required=True, help=u"""The [OCID] of the VM instance.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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 restart_vm_instance(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, vm_instance_id, if_match):

    if isinstance(vm_instance_id, six.string_types) and len(vm_instance_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-instance-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('datacc', 'baseinfra', ctx)
    result = client.restart_vm_instance(
        vm_instance_id=vm_instance_id,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@infrastructure_group.command(name=cli_util.override('datacc.scale_infrastructure_storage.command_name', 'scale-infrastructure-storage'), help=u"""Scale storage for the specified infrastructure using the specified details. \n[Command Reference](scaleInfrastructureStorage)""")
@cli_util.option('--infrastructure-id', required=True, help=u"""The [OCID] of the Database Infrastructure.""")
@cli_util.option('--ssd-configuration-requested', type=custom_types.CliCaseInsensitiveChoice(["SIX_SSDS", "TWELVE_SSDS", "EIGHTEEN_SSDS", "TWENTY_FOUR_SSDS"]), help=u"""The scale option to be selected for the infrastructure.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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 scale_infrastructure_storage(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, infrastructure_id, ssd_configuration_requested, if_match):

    if isinstance(infrastructure_id, six.string_types) and len(infrastructure_id.strip()) == 0:
        raise click.UsageError('Parameter --infrastructure-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 ssd_configuration_requested is not None:
        _details['ssdConfigurationRequested'] = ssd_configuration_requested

    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.scale_infrastructure_storage(
        infrastructure_id=infrastructure_id,
        scale_infrastructure_storage_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@vm_instance_group.command(name=cli_util.override('datacc.scale_vm_instance.command_name', 'scale'), help=u"""Scale the VM instance on Database Infrastructure that has the specified [OCID]. \n[Command Reference](scaleVmInstance)""")
@cli_util.option('--vm-instance-id', required=True, help=u"""The [OCID] of the VM instance.""")
@cli_util.option('--memory-size-in-gbs', help=u"""The memory to be allocated in GBs.""")
@cli_util.option('--cpus-enabled', type=click.INT, help=u"""The number of CPU cores to be enabled for VM instance.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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 scale_vm_instance(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, vm_instance_id, memory_size_in_gbs, cpus_enabled, if_match):

    if isinstance(vm_instance_id, six.string_types) and len(vm_instance_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-instance-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 memory_size_in_gbs is not None:
        _details['memorySizeInGBs'] = memory_size_in_gbs

    if cpus_enabled is not None:
        _details['cpusEnabled'] = cpus_enabled

    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.scale_vm_instance(
        vm_instance_id=vm_instance_id,
        scale_vm_instance_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@vm_instance_group.command(name=cli_util.override('datacc.start_vm_instance.command_name', 'start'), help=u"""Start the VM instance on Database Infrastructure that has the specified [OCID]. \n[Command Reference](startVmInstance)""")
@cli_util.option('--vm-instance-id', required=True, help=u"""The [OCID] of the VM instance.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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 start_vm_instance(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, vm_instance_id, if_match):

    if isinstance(vm_instance_id, six.string_types) and len(vm_instance_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-instance-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('datacc', 'baseinfra', ctx)
    result = client.start_vm_instance(
        vm_instance_id=vm_instance_id,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@vm_instance_group.command(name=cli_util.override('datacc.stop_vm_instance.command_name', 'stop'), help=u"""Stop the VM instance on Database Infrastructure that has the specified [OCID]. \n[Command Reference](stopVmInstance)""")
@cli_util.option('--vm-instance-id', required=True, help=u"""The [OCID] of the VM instance.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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 stop_vm_instance(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, vm_instance_id, if_match):

    if isinstance(vm_instance_id, six.string_types) and len(vm_instance_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-instance-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('datacc', 'baseinfra', ctx)
    result = client.stop_vm_instance(
        vm_instance_id=vm_instance_id,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@infrastructure_group.command(name=cli_util.override('datacc.update_infrastructure.command_name', 'update'), help=u"""Update the Database Infrastructure that has the specified [OCID]. \n[Command Reference](updateInfrastructure)""")
@cli_util.option('--infrastructure-id', required=True, help=u"""The [OCID] of the Database Infrastructure.""")
@cli_util.option('--display-name', help=u"""The user-friendly name for the Database Infrastructure. The name does not need to be unique.""")
@cli_util.option('--description', help=u"""Database Infrastructure description.""")
@cli_util.option('--system-model', type=custom_types.CliCaseInsensitiveChoice(["X11_HA_768", "X10_HA_512", "X8_HA_384"]), help=u"""Database Infrastructure System Model specification. The system model determines the model of the Database Infrastructure hardware to be used.""")
@cli_util.option('--shape', type=custom_types.CliCaseInsensitiveChoice(["SIX_SSDS", "TWELVE_SSDS", "EIGHTEEN_SSDS", "TWENTY_FOUR_SSDS"]), help=u"""The shape of the Database Infrastructure. The shape determines the amount of CPU, storage, and memory resources allocated to the instance.""")
@cli_util.option('--cloud-control-plane-server1', help=u"""The IP address for the first control plane server.""")
@cli_util.option('--cloud-control-plane-server2', help=u"""The IP address for the second control plane server.""")
@cli_util.option('--netmask', help=u"""The netmask for the control plane network.""")
@cli_util.option('--gateway', help=u"""The gateway for the control plane network.""")
@cli_util.option('--admin-networkcidr', help=u"""The CIDR block for the system network. The system network is a private network in Database Infrastructure and is not connected to your corporate network. The system network is used for storage (ASM) traffic, high-performance interconnect traffic and administration of infrastructure components.""")
@cli_util.option('--data-disk-percentage', type=click.INT, help=u"""Percentage of disk space assigned for DATA disk group. Remaining disk space will get assiged to RECO disk group""")
@cli_util.option('--contacts', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of contacts for the Database Infrastructure.

This option is a JSON list with items of type InfrastructureContact.  For documentation on InfrastructureContact please see our API reference: https://docs.oracle.com/en-us/iaas/api/#/en/baseinfra/20251101/datatypes/InfrastructureContact.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--dns-servers', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of DNS server IP addresses. Maximum of 3 allowed.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--ntp-servers', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of NTP server IP addresses. Maximum of 3 allowed.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--client-bond-mode', type=custom_types.CliCaseInsensitiveChoice(["ACTIVE_BACKUP", "LACP"]), help=u"""The network bonding mode for Client networks for the Database Infrastructure.""")
@cli_util.option('--backup-bond-mode', type=custom_types.CliCaseInsensitiveChoice(["ACTIVE_BACKUP", "LACP"]), help=u"""The network bonding mode for Backup networks for the Database Infrastructure.""")
@cli_util.option('--cps-bond-mode', type=custom_types.CliCaseInsensitiveChoice(["ACTIVE_BACKUP", "LACP"]), help=u"""The network bonding mode for CPS networks for the Database Infrastructure.""")
@cli_util.option('--client-bond-iface', type=custom_types.CliCaseInsensitiveChoice(["BTBOND1", "BTBOND2", "BTBOND3", "BTBOND4", "BTBOND5", "BTBOND6"]), help=u"""The network bonding interface for client network for the Database Infrastructure.""")
@cli_util.option('--backup-bond-iface', type=custom_types.CliCaseInsensitiveChoice(["BTBOND1", "BTBOND2", "BTBOND3", "BTBOND4", "BTBOND5", "BTBOND6"]), help=u"""The network bonding interface for backup network for the Database Infrastructure.""")
@cli_util.option('--cps-bond-iface', type=custom_types.CliCaseInsensitiveChoice(["BTBOND1", "BTBOND2", "BTBOND3", "BTBOND4", "BTBOND5", "BTBOND6"]), help=u"""The network bonding interface for CPS network for the Database Infrastructure.""")
@cli_util.option('--acfs-size-in-gbs', help=u"""The amount of storage (in GB) in the DATA disk group that is reserved for creating local storage for VM Clusters and application VMs.""")
@cli_util.option('--corporate-proxy', help=u"""The corporate network proxy for access to the control plane network. Oracle recommends using an HTTPS proxy when possible for enhanced security.""")
@cli_util.option('--vlan-id', help=u"""The CPS network VLAN ID.""")
@cli_util.option('--maintenance-window', type=custom_types.CLI_COMPLEX_TYPE, help=u"""""" + 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('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. This tag option exists for cross-compatibility only. Example: `{\"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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@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", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the state defined by --wait-for-state. Defaults to 30 seconds.""")
@json_skeleton_utils.get_cli_json_input_option({'contacts': {'module': 'datacc', 'class': 'list[InfrastructureContact]'}, 'dns-servers': {'module': 'datacc', 'class': 'list[string]'}, 'ntp-servers': {'module': 'datacc', 'class': 'list[string]'}, 'maintenance-window': {'module': 'datacc', 'class': 'MaintenanceWindow'}, 'defined-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'contacts': {'module': 'datacc', 'class': 'list[InfrastructureContact]'}, 'dns-servers': {'module': 'datacc', 'class': 'list[string]'}, 'ntp-servers': {'module': 'datacc', 'class': 'list[string]'}, 'maintenance-window': {'module': 'datacc', 'class': 'MaintenanceWindow'}, 'defined-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}}, output_type={'module': 'datacc', 'class': 'Infrastructure'})
@cli_util.wrap_exceptions
def update_infrastructure(ctx, from_json, force, wait_for_state, max_wait_seconds, wait_interval_seconds, infrastructure_id, display_name, description, system_model, shape, cloud_control_plane_server1, cloud_control_plane_server2, netmask, gateway, admin_networkcidr, data_disk_percentage, contacts, dns_servers, ntp_servers, client_bond_mode, backup_bond_mode, cps_bond_mode, client_bond_iface, backup_bond_iface, cps_bond_iface, acfs_size_in_gbs, corporate_proxy, vlan_id, maintenance_window, defined_tags, freeform_tags, if_match):

    if isinstance(infrastructure_id, six.string_types) and len(infrastructure_id.strip()) == 0:
        raise click.UsageError('Parameter --infrastructure-id cannot be whitespace or empty string')
    if not force:
        if contacts or dns_servers or ntp_servers or maintenance_window or defined_tags or freeform_tags:
            if not click.confirm("WARNING: Updates to contacts and dns-servers and ntp-servers and maintenance-window and defined-tags and freeform-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 display_name is not None:
        _details['displayName'] = display_name

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

    if system_model is not None:
        _details['systemModel'] = system_model

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

    if cloud_control_plane_server1 is not None:
        _details['cloudControlPlaneServer1'] = cloud_control_plane_server1

    if cloud_control_plane_server2 is not None:
        _details['cloudControlPlaneServer2'] = cloud_control_plane_server2

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

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

    if admin_networkcidr is not None:
        _details['adminNetworkcidr'] = admin_networkcidr

    if data_disk_percentage is not None:
        _details['dataDiskPercentage'] = data_disk_percentage

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

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

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

    if client_bond_mode is not None:
        _details['clientNetworkBondingMode'] = client_bond_mode

    if backup_bond_mode is not None:
        _details['backupNetworkBondingMode'] = backup_bond_mode

    if cps_bond_mode is not None:
        _details['cpsNetworkBondingMode'] = cps_bond_mode

    if client_bond_iface is not None:
        _details['clientNetworkBondingInterface'] = client_bond_iface

    if backup_bond_iface is not None:
        _details['backupNetworkBondingInterface'] = backup_bond_iface

    if cps_bond_iface is not None:
        _details['cpsNetworkBondingInterface'] = cps_bond_iface

    if acfs_size_in_gbs is not None:
        _details['acfsFileSystemStorageInGbs'] = acfs_size_in_gbs

    if corporate_proxy is not None:
        _details['corporateProxy'] = corporate_proxy

    if vlan_id is not None:
        _details['vlanId'] = vlan_id

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

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

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

    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.update_infrastructure(
        infrastructure_id=infrastructure_id,
        update_infrastructure_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@maintenance_run_group.command(name=cli_util.override('datacc.update_maintenance_run.command_name', 'update'), help=u"""Update maintenance run attributes. \n[Command Reference](updateMaintenanceRun)""")
@cli_util.option('--patching-mode', required=True, type=custom_types.CliCaseInsensitiveChoice(["ROLLING", "NONROLLING"]), help=u"""Database Infrastructure patching mode, either \"ROLLING\" or \"NONROLLING\". Default value is ROLLING.""")
@cli_util.option('--custom-action-timeout-in-mins', required=True, type=click.INT, help=u"""Determines the amount of time the system will wait before the start of each compute server patching operation. Supported values are 15 to 120 minutes.""")
@cli_util.option('--maintenance-run-id', required=True, help=u"""The maintenance run OCID.""")
@cli_util.option('--is-custom-action-timeout-enabled', type=click.BOOL, help=u"""If true, enables configuration of customActionTimeoutInMins for this maintenance run update request.""")
@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('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. This tag option exists for cross-compatibility only. Example: `{\"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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@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", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the state defined by --wait-for-state. Defaults to 30 seconds.""")
@json_skeleton_utils.get_cli_json_input_option({'defined-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'defined-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}}, output_type={'module': 'datacc', 'class': 'MaintenanceRun'})
@cli_util.wrap_exceptions
def update_maintenance_run(ctx, from_json, force, wait_for_state, max_wait_seconds, wait_interval_seconds, patching_mode, custom_action_timeout_in_mins, maintenance_run_id, is_custom_action_timeout_enabled, defined_tags, freeform_tags, if_match):

    if isinstance(maintenance_run_id, six.string_types) and len(maintenance_run_id.strip()) == 0:
        raise click.UsageError('Parameter --maintenance-run-id cannot be whitespace or empty string')
    if not force:
        if defined_tags or freeform_tags:
            if not click.confirm("WARNING: Updates to defined-tags and freeform-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 = {}
    _details['patchingMode'] = patching_mode
    _details['customActionTimeoutInMins'] = custom_action_timeout_in_mins

    if is_custom_action_timeout_enabled is not None:
        _details['isCustomActionTimeoutEnabled'] = is_custom_action_timeout_enabled

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

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

    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.update_maintenance_run(
        maintenance_run_id=maintenance_run_id,
        update_maintenance_run_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@vm_cluster_network_group.command(name=cli_util.override('datacc.update_vm_cluster_network.command_name', 'update'), help=u"""Update the VM cluster network on Database Infrastructure that has the specified [OCID]. \n[Command Reference](updateVmClusterNetwork)""")
@cli_util.option('--vm-cluster-network-id', required=True, help=u"""The [OCID] of the VM cluster network.""")
@cli_util.option('--display-name', help=u"""The user-friendly name for the VM cluster network. The name does not need to be unique.""")
@cli_util.option('--scans', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The SCAN details.

This option is a JSON list with items of type ScanDetails.  For documentation on ScanDetails please see our API reference: https://docs.oracle.com/en-us/iaas/api/#/en/baseinfra/20251101/datatypes/ScanDetails.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--listener-port', type=click.INT, help=u"""The listener TCP/IP port.""")
@cli_util.option('--listener-port-ssl', type=click.INT, help=u"""The listener TCP/IP SSL port. Default is 2484.""")
@cli_util.option('--dns-servers', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of DNS server IP addresses. Maximum of 3 allowed.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--ntp-servers', type=custom_types.CLI_COMPLEX_TYPE, help=u"""The list of NTP server IP addresses. Maximum of 3 allowed.""" + custom_types.cli_complex_type.COMPLEX_TYPE_HELP)
@cli_util.option('--vm-networks', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Details of the client and backup networks.

This option is a JSON list with items of type VmNetworkDetails.  For documentation on VmNetworkDetails please see our API reference: https://docs.oracle.com/en-us/iaas/api/#/en/baseinfra/20251101/datatypes/VmNetworkDetails.""" + 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. This tag option 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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@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", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the state defined by --wait-for-state. Defaults to 30 seconds.""")
@json_skeleton_utils.get_cli_json_input_option({'scans': {'module': 'datacc', 'class': 'list[ScanDetails]'}, 'dns-servers': {'module': 'datacc', 'class': 'list[string]'}, 'ntp-servers': {'module': 'datacc', 'class': 'list[string]'}, 'vm-networks': {'module': 'datacc', 'class': 'list[VmNetworkDetails]'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'datacc', '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={'scans': {'module': 'datacc', 'class': 'list[ScanDetails]'}, 'dns-servers': {'module': 'datacc', 'class': 'list[string]'}, 'ntp-servers': {'module': 'datacc', 'class': 'list[string]'}, 'vm-networks': {'module': 'datacc', 'class': 'list[VmNetworkDetails]'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}, 'defined-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}}, output_type={'module': 'datacc', 'class': 'VmClusterNetwork'})
@cli_util.wrap_exceptions
def update_vm_cluster_network(ctx, from_json, force, wait_for_state, max_wait_seconds, wait_interval_seconds, vm_cluster_network_id, display_name, scans, listener_port, listener_port_ssl, dns_servers, ntp_servers, vm_networks, freeform_tags, defined_tags, if_match):

    if isinstance(vm_cluster_network_id, six.string_types) and len(vm_cluster_network_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-cluster-network-id cannot be whitespace or empty string')
    if not force:
        if scans or dns_servers or ntp_servers or vm_networks or freeform_tags or defined_tags:
            if not click.confirm("WARNING: Updates to scans and dns-servers and ntp-servers and vm-networks and 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 display_name is not None:
        _details['displayName'] = display_name

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

    if listener_port is not None:
        _details['listenerPort'] = listener_port

    if listener_port_ssl is not None:
        _details['listenerPortSsl'] = listener_port_ssl

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

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

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

    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('datacc', 'baseinfra', ctx)
    result = client.update_vm_cluster_network(
        vm_cluster_network_id=vm_cluster_network_id,
        update_vm_cluster_network_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@vm_instance_group.command(name=cli_util.override('datacc.update_vm_instance.command_name', 'update'), help=u"""Update the VM instance on Database Infrastructure that has the specified [OCID]. \n[Command Reference](updateVmInstance)""")
@cli_util.option('--vm-instance-id', required=True, help=u"""The [OCID] of the VM instance.""")
@cli_util.option('--description', help=u"""VM instance description.""")
@cli_util.option('--display-name', help=u"""VM instance display name. This name does not have to be unique, and is changeable.""")
@cli_util.option('--data-storage-size-in-gbs', help=u"""Data storage to be allocated in GBs.""")
@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('--freeform-tags', type=custom_types.CLI_COMPLEX_TYPE, help=u"""Simple key-value pair that is applied without any predefined name, type or scope. This tag option exists for cross-compatibility only. Example: `{\"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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@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", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the state defined by --wait-for-state. Defaults to 30 seconds.""")
@json_skeleton_utils.get_cli_json_input_option({'defined-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}})
@cli_util.help_option
@click.pass_context
@json_skeleton_utils.json_skeleton_generation_handler(input_params_to_complex_types={'defined-tags': {'module': 'datacc', 'class': 'dict(str, dict(str, object))'}, 'freeform-tags': {'module': 'datacc', 'class': 'dict(str, string)'}}, output_type={'module': 'datacc', 'class': 'VmInstance'})
@cli_util.wrap_exceptions
def update_vm_instance(ctx, from_json, force, wait_for_state, max_wait_seconds, wait_interval_seconds, vm_instance_id, description, display_name, data_storage_size_in_gbs, defined_tags, freeform_tags, if_match):

    if isinstance(vm_instance_id, six.string_types) and len(vm_instance_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-instance-id cannot be whitespace or empty string')
    if not force:
        if defined_tags or freeform_tags:
            if not click.confirm("WARNING: Updates to defined-tags and freeform-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 description is not None:
        _details['description'] = description

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

    if data_storage_size_in_gbs is not None:
        _details['dataStorageSizeInGBs'] = data_storage_size_in_gbs

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

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

    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.update_vm_instance(
        vm_instance_id=vm_instance_id,
        update_vm_instance_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@infrastructure_group.command(name=cli_util.override('datacc.validate_infrastructure.command_name', 'validate'), help=u"""Validate an Database Infrastructure using the specified details. \n[Command Reference](validateInfrastructure)""")
@cli_util.option('--validation-zip-file', required=True, help=u"""The validation zip file.""")
@cli_util.option('--infrastructure-id', required=True, help=u"""The [OCID] of the Database Infrastructure.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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': 'datacc', 'class': 'Infrastructure'})
@cli_util.wrap_exceptions
def validate_infrastructure(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, validation_zip_file, infrastructure_id, if_match):

    if isinstance(infrastructure_id, six.string_types) and len(infrastructure_id.strip()) == 0:
        raise click.UsageError('Parameter --infrastructure-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 = {}
    _details['validationZipFile'] = validation_zip_file

    client = cli_util.build_client('datacc', 'baseinfra', ctx)
    result = client.validate_infrastructure(
        infrastructure_id=infrastructure_id,
        validate_infrastructure_details=_details,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)


@vm_cluster_network_group.command(name=cli_util.override('datacc.validate_vm_cluster_network.command_name', 'validate'), help=u"""Validates an VM cluster network on Database Infrastructure. \n[Command Reference](validateVmClusterNetwork)""")
@cli_util.option('--vm-cluster-network-id', required=True, help=u"""The [OCID] of the VM cluster network.""")
@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 is updated or deleted only if the Etag that you provide matches the current Etag value for the resource.""")
@cli_util.option('--wait-for-state', type=custom_types.CliCaseInsensitiveChoice(["ACCEPTED", "IN_PROGRESS", "FAILED", "SUCCEEDED", "CANCELING", "CANCELED", "WAITING"]), multiple=True, help="""This operation asynchronously creates, modifies or deletes a resource and uses a work request to track the progress of the operation. Specify this option to perform the action and then wait until the work request reaches a certain state. Multiple states can be specified, returning on the first state. For example, --wait-for-state ACCEPTED --wait-for-state WAITING 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 work request to reach the 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 work request has reached the 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 validate_vm_cluster_network(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, vm_cluster_network_id, if_match):

    if isinstance(vm_cluster_network_id, six.string_types) and len(vm_cluster_network_id.strip()) == 0:
        raise click.UsageError('Parameter --vm-cluster-network-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('datacc', 'baseinfra', ctx)
    result = client.validate_vm_cluster_network(
        vm_cluster_network_id=vm_cluster_network_id,
        **kwargs
    )
    if wait_for_state:

        if hasattr(client, 'get_work_request') and callable(getattr(client, 'get_work_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
                if 'opc-work-request-id' not in result.headers:
                    click.echo('Encountered error while waiting for work request to enter the specified state. Outputting last known resource state')
                    cli_util.render_response(result, ctx)
                    return

                click.echo('Action completed. Waiting until the work request has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_work_request(result.headers['opc-work-request-id']), 'status', 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 work request 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 work request 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 work request to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)
