Exemple #1
0
def update_backup(ctx, from_json, force, backup_id, display_name, description, retention_in_days, freeform_tags, defined_tags, if_match):

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

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

    _details = {}

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

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

    if retention_in_days is not None:
        _details['retentionInDays'] = retention_in_days

    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('mysql', 'db_backups', ctx)
    result = client.update_backup(
        backup_id=backup_id,
        update_backup_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)
Exemple #2
0
def summarize_attention_log_counts(ctx, from_json, managed_database_id,
                                   time_greater_than_or_equal_to,
                                   time_less_than_or_equal_to, urgency_filter,
                                   group_by, type_filter, log_search_text,
                                   is_regular_expression, page, limit):

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

    kwargs = {}
    if time_greater_than_or_equal_to is not None:
        kwargs['time_greater_than_or_equal_to'] = time_greater_than_or_equal_to
    if time_less_than_or_equal_to is not None:
        kwargs['time_less_than_or_equal_to'] = time_less_than_or_equal_to
    if urgency_filter is not None:
        kwargs['urgency_filter'] = urgency_filter
    if group_by is not None:
        kwargs['group_by'] = group_by
    if type_filter is not None:
        kwargs['type_filter'] = type_filter
    if log_search_text is not None:
        kwargs['log_search_text'] = log_search_text
    if is_regular_expression is not None:
        kwargs['is_regular_expression'] = is_regular_expression
    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('database_management', 'diagnosability',
                                   ctx)
    result = client.summarize_attention_log_counts(
        managed_database_id=managed_database_id, **kwargs)
    cli_util.render_response(result, ctx)
Exemple #3
0
def stop_oda_instance(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, oda_instance_id, if_match):

    if isinstance(oda_instance_id, six.string_types) and len(oda_instance_id.strip()) == 0:
        raise click.UsageError('Parameter --oda-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('oda', 'oda', ctx)
    result = client.stop_oda_instance(
        oda_instance_id=oda_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

                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)
def update_auto_scaling_configuration(ctx, from_json, force, auto_scaling_configuration_id, defined_tags, display_name, freeform_tags, is_enabled, cool_down_in_seconds, if_match):

    if isinstance(auto_scaling_configuration_id, six.string_types) and len(auto_scaling_configuration_id.strip()) == 0:
        raise click.UsageError('Parameter --auto-scaling-configuration-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 defined_tags is not None:
        details['definedTags'] = cli_util.parse_json_parameter("defined_tags", defined_tags)

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

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

    if is_enabled is not None:
        details['isEnabled'] = is_enabled

    if cool_down_in_seconds is not None:
        details['coolDownInSeconds'] = cool_down_in_seconds

    client = cli_util.build_client('auto_scaling', ctx)
    result = client.update_auto_scaling_configuration(
        auto_scaling_configuration_id=auto_scaling_configuration_id,
        update_auto_scaling_configuration_details=details,
        **kwargs
    )
    cli_util.render_response(result, ctx)
Exemple #5
0
def approve_access_request(ctx, from_json, access_request_id, approver_comment,
                           audit_type, additional_message,
                           time_of_user_creation, if_match):

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

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

    _details = {}

    if approver_comment is not None:
        _details['approverComment'] = approver_comment

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

    if additional_message is not None:
        _details['additionalMessage'] = additional_message

    if time_of_user_creation is not None:
        _details['timeOfUserCreation'] = time_of_user_creation

    client = cli_util.build_client('operator_access_control',
                                   'access_requests', ctx)
    result = client.approve_access_request(
        access_request_id=access_request_id,
        approve_access_request_details=_details,
        **kwargs)
    cli_util.render_response(result, ctx)
Exemple #6
0
def update_tag_namespace_description(ctx, **kwargs):
    tag_namespace_id = kwargs['tag_namespace_id']
    description = kwargs.get('description')
    freeform_tags = kwargs.get('freeform_tags')
    defined_tags = kwargs.get('defined_tags')

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

    if not kwargs.get('force'):
        if freeform_tags or defined_tags:
            if not click.confirm(
                    "WARNING: Updates to freeform-tags and defined-tags will replace any existing values. Are you sure you want to continue?"
            ):
                ctx.abort()

    service_kwargs = {}
    details = {}

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

    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('identity', 'identity', ctx)
    result = client.update_tag_namespace(tag_namespace_id=tag_namespace_id,
                                         update_tag_namespace_details=details,
                                         **service_kwargs)
    cli_util.render_response(result, ctx)
Exemple #7
0
def update_configuration(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, compartment_id, retention_period_days):

    kwargs = {}

    details = {}

    if retention_period_days is not None:
        details['retentionPeriodDays'] = retention_period_days

    client = cli_util.build_client('audit', ctx)
    result = client.update_configuration(
        compartment_id=compartment_id,
        update_configuration_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

                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)
Exemple #8
0
def list_work_request_logs(ctx, from_json, all_pages, page_size, work_request_id, page, limit):

    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
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('oce_instance', 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)
def update_auto_scaling_policy_update_threshold_policy_details(ctx, from_json, force, auto_scaling_configuration_id, auto_scaling_policy_id, display_name, capacity, rules, if_match):

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

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

    kwargs = {}
    if if_match is not None:
        kwargs['if_match'] = if_match
    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 capacity is not None:
        details['capacity'] = cli_util.parse_json_parameter("capacity", capacity)

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

    details['policyType'] = 'threshold'

    client = cli_util.build_client('auto_scaling', ctx)
    result = client.update_auto_scaling_policy(
        auto_scaling_configuration_id=auto_scaling_configuration_id,
        auto_scaling_policy_id=auto_scaling_policy_id,
        update_auto_scaling_policy_details=details,
        **kwargs
    )
    cli_util.render_response(result, ctx)
Exemple #10
0
def update_config(ctx, from_json, force, apm_domain_id, config_id, config_type,
                  freeform_tags, defined_tags, if_match, opc_dry_run):

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

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

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

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

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

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.update_config(apm_domain_id=apm_domain_id,
                                  config_id=config_id,
                                  update_config_details=_details,
                                  **kwargs)
    cli_util.render_response(result, ctx)
Exemple #11
0
def update_filter_group(ctx, from_json, force, announcement_subscription_id,
                        filter_group_name, filters, if_match):

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

    if isinstance(filter_group_name, six.string_types) and len(
            filter_group_name.strip()) == 0:
        raise click.UsageError(
            'Parameter --filter-group-name cannot be whitespace or empty string'
        )
    if not force:
        if filters:
            if not click.confirm(
                    "WARNING: Updates to filters 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['filters'] = cli_util.parse_json_parameter("filters", filters)

    client = cli_util.build_client('announcements_service',
                                   'announcement_subscription', ctx)
    result = client.update_filter_group(
        announcement_subscription_id=announcement_subscription_id,
        filter_group_name=filter_group_name,
        update_filter_group_details=_details,
        **kwargs)
    cli_util.render_response(result, ctx)
Exemple #12
0
def change_transfer_job_compartment(ctx, from_json, transfer_job_id,
                                    compartment_id, if_match):

    if isinstance(transfer_job_id, six.string_types) and len(
            transfer_job_id.strip()) == 0:
        raise click.UsageError(
            'Parameter --transfer-job-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('dts', 'transfer_job', ctx)
    result = client.change_transfer_job_compartment(
        transfer_job_id=transfer_job_id,
        change_transfer_job_compartment_details=_details,
        **kwargs)
    cli_util.render_response(result, ctx)
Exemple #13
0
def list_reports(ctx, from_json, all_pages, report_type, date, compartment_id, page):

    kwargs = {}
    if page is not None:
        kwargs['page'] = page
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('marketplace', 'marketplace', ctx)
    if all_pages:
        result = cli_util.list_call_get_all_results(
            client.list_reports,
            report_type=report_type,
            date=date,
            compartment_id=compartment_id,
            **kwargs
        )
    else:
        result = client.list_reports(
            report_type=report_type,
            date=date,
            compartment_id=compartment_id,
            **kwargs
        )
    cli_util.render_response(result, ctx)
Exemple #14
0
def get_agreement(ctx, from_json, listing_id, package_version, agreement_id, compartment_id):

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

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

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

    kwargs = {}
    if compartment_id is not None:
        kwargs['compartment_id'] = compartment_id
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('marketplace', 'marketplace', ctx)
    result = client.get_agreement(
        listing_id=listing_id,
        package_version=package_version,
        agreement_id=agreement_id,
        **kwargs
    )
    cli_util.render_response(result, ctx)
def delete_database(ctx, **kwargs):
    client = cli_util.build_client('database', ctx)

    # get the db-home for this database
    response = client.get_database(kwargs['database_id'])
    db_home_id = response.data.db_home_id
    compartment_id = response.data.compartment_id

    # we only want to delete this single database, but the only API
    # available deletes the entire db-home, so check to make sure
    # this is the only database in the db-home before deleting
    response = client.get_db_home(db_home_id)
    response = client.list_databases(compartment_id, db_home_id)
    if len(response.data) != 1:
        click.echo(
            message=
            "Cannot delete a DB Home which contains multiple databases through the CLI. Please use the console to delete this database.",
            file=sys.stderr)
        sys.exit(1)

    # delete DbHome
    response = client.delete_db_home(db_home_id)
    cli_util.render_response(response, ctx)
Exemple #16
0
def search_resources(ctx, from_json, type, matching_context_type, limit, page, tenant_id):

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

    _details = {}
    _details['type'] = type

    if matching_context_type is not None:
        _details['matchingContextType'] = matching_context_type

    client = cli_util.build_client('resource_search', 'resource_search', ctx)
    result = client.search_resources(
        search_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)
Exemple #17
0
def list_events(ctx, from_json, all_pages, compartment_id, start_time, end_time, page):

    kwargs = {}
    if page is not None:
        kwargs['page'] = page
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('audit', ctx)
    if all_pages:
        result = cli_util.list_call_get_all_results(
            client.list_events,
            compartment_id=compartment_id,
            start_time=start_time,
            end_time=end_time,
            **kwargs
        )
    else:
        result = client.list_events(
            compartment_id=compartment_id,
            start_time=start_time,
            end_time=end_time,
            **kwargs
        )
    cli_util.render_response(result, ctx)
def pa_initialize_authentication(ctx, from_json, job_id, appliance_label, appliance_cert_fingerprint, appliance_ip,
                                 appliance_port, access_token, profile, appliance_profile):
    if isinstance(job_id, six.string_types) and len(job_id.strip()) == 0:
        raise click.UsageError('Parameter --job-id cannot be whitespace or empty string')

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

    # Do this for all the input arguments

    kwargs = {}

    click.echo("Retrieving the Appliance serial id from Oracle Cloud Infrastructure")
    # Get the Transfer Appliance serial number from the information received from CCP
    client = cli_util.build_client('dts', 'transfer_appliance', ctx)
    result = client.get_transfer_appliance(
        id=job_id,
        transfer_appliance_label=appliance_label,
        **kwargs
    )
    serial_number = result.data.serial_number
    pa_init_auth_helper(ctx, appliance_profile, appliance_cert_fingerprint, appliance_ip, appliance_port,
                        serial_number, access_token)
Exemple #19
0
def rover_node_action_set_key(ctx, from_json, rover_node_id, jwt, public_key, if_match):

    if isinstance(rover_node_id, six.string_types) and len(rover_node_id.strip()) == 0:
        raise click.UsageError('Parameter --rover-node-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 public_key is not None:
        _details['publicKey'] = public_key

    client = cli_util.build_client('rover', 'rover_node', ctx)
    result = client.rover_node_action_set_key(
        rover_node_id=rover_node_id,
        jwt=jwt,
        rover_node_action_set_key_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)
Exemple #20
0
def create_transfer_appliance_admin_credentials(ctx, from_json, id, transfer_appliance_label, public_key):

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

    if isinstance(transfer_appliance_label, six.string_types) and len(transfer_appliance_label.strip()) == 0:
        raise click.UsageError('Parameter --transfer-appliance-label cannot be whitespace or empty string')

    kwargs = {}

    details = {}

    if public_key is not None:
        details['publicKey'] = public_key

    client = cli_util.build_client('transfer_appliance', ctx)
    result = client.create_transfer_appliance_admin_credentials(
        id=id,
        transfer_appliance_label=transfer_appliance_label,
        admin_public_key=details,
        **kwargs
    )
    cli_util.render_response(result, ctx)
def attach_devices_to_transfer_package(ctx, from_json, id, transfer_package_label, device_labels):

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

    if isinstance(transfer_package_label, six.string_types) and len(transfer_package_label.strip()) == 0:
        raise click.UsageError('Parameter --transfer-package-label cannot be whitespace or empty string')

    kwargs = {}

    details = {}

    if device_labels is not None:
        details['deviceLabels'] = cli_util.parse_json_parameter("device_labels", device_labels)

    client = cli_util.build_client('transfer_package', ctx)
    result = client.attach_devices_to_transfer_package(
        id=id,
        transfer_package_label=transfer_package_label,
        attach_devices_details=details,
        **kwargs
    )
    cli_util.render_response(result, ctx)
Exemple #22
0
def list_available_regions(ctx, from_json, all_pages, subscription_id, page):

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

    kwargs = {}
    if page is not None:
        kwargs['page'] = page
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(
        ctx.obj['request_id'])
    client = cli_util.build_client('tenant_manager_control_plane',
                                   'subscription', ctx)
    if all_pages:
        result = cli_util.list_call_get_all_results(
            client.list_available_regions,
            subscription_id=subscription_id,
            **kwargs)
    else:
        result = client.list_available_regions(subscription_id=subscription_id,
                                               **kwargs)
    cli_util.render_response(result, ctx)
Exemple #23
0
def get_event_report(ctx, from_json, managed_instance_id, compartment_id,
                     latest_timestamp_less_than,
                     latest_timestamp_greater_than_or_equal_to):

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

    kwargs = {}
    if latest_timestamp_less_than is not None:
        kwargs['latest_timestamp_less_than'] = latest_timestamp_less_than
    if latest_timestamp_greater_than_or_equal_to is not None:
        kwargs[
            'latest_timestamp_greater_than_or_equal_to'] = latest_timestamp_greater_than_or_equal_to
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(
        ctx.obj['request_id'])
    client = cli_util.build_client('os_management', 'event', ctx)
    result = client.get_event_report(managed_instance_id=managed_instance_id,
                                     compartment_id=compartment_id,
                                     **kwargs)
    cli_util.render_response(result, ctx)
Exemple #24
0
def search_resources_free_text_search_details(ctx, from_json, text,
                                              matching_context_type, limit,
                                              page):

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

    details = {}
    details['text'] = text

    if matching_context_type is not None:
        details['matchingContextType'] = matching_context_type

    details['type'] = 'FreeText'

    client = cli_util.build_client('resource_search', ctx)
    result = client.search_resources(search_details=details, **kwargs)
    cli_util.render_response(result, ctx)
Exemple #25
0
def create_announcements_preference(ctx, from_json, type, preference_type, is_unsubscribed, compartment_id):

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

    _details = {}
    _details['type'] = type
    _details['preferenceType'] = preference_type

    if is_unsubscribed is not None:
        _details['isUnsubscribed'] = is_unsubscribed

    if compartment_id is not None:
        _details['compartmentId'] = compartment_id

    _details['type'] = 'CreateAnnouncementsPreferencesDetails'

    client = cli_util.build_client('announcements_service', 'announcements_preferences', ctx)
    result = client.create_announcements_preference(
        announcements_preference_details=_details,
        **kwargs
    )
    cli_util.render_response(result, ctx)
Exemple #26
0
def reactivate_tag(ctx, **kwargs):
    tag_namespace_id = kwargs['tag_namespace_id']
    tag_name = kwargs['tag_name']

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

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

    service_kwargs = {}
    details = {'isRetired': False}

    client = cli_util.build_client('identity', 'identity', ctx)
    result = client.update_tag(tag_namespace_id=tag_namespace_id,
                               tag_name=tag_name,
                               update_tag_details=details,
                               **service_kwargs)
    cli_util.render_response(result, ctx)
Exemple #27
0
def change_subscription_compartment(ctx, from_json, subscription_id,
                                    compartment_id, if_match):

    if isinstance(subscription_id, six.string_types) and len(
            subscription_id.strip()) == 0:
        raise click.UsageError(
            'Parameter --subscription-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('notification_data_plane', ctx)
    result = client.change_subscription_compartment(
        subscription_id=subscription_id,
        change_subscription_compartment_details=details,
        **kwargs)
    cli_util.render_response(result, ctx)
Exemple #28
0
def publish_message(ctx, from_json, topic_id, body, title, message_type):

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

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

    details = {}
    details['body'] = body

    if title is not None:
        details['title'] = title

    client = cli_util.build_client('notification_data_plane', ctx)
    result = client.publish_message(topic_id=topic_id,
                                    message_details=details,
                                    **kwargs)
    cli_util.render_response(result, ctx)
def list_work_requests(ctx, from_json, all_pages, page_size, compartment_id, page, limit, integration_instance_id):

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

    kwargs = {}
    if page is not None:
        kwargs['page'] = page
    if limit is not None:
        kwargs['limit'] = limit
    if integration_instance_id is not None:
        kwargs['integration_instance_id'] = integration_instance_id
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('integration_instance', 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)
Exemple #30
0
def list_work_requests(ctx, from_json, all_pages, page_size, compartment_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')

    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('tenant_manager_control_plane', 'work_request', 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)