Esempio n. 1
0
def create_instance_agent_command(ctx, from_json, compartment_id,
                                  execution_time_out_in_seconds, target,
                                  content, display_name):

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

    _details = {}
    _details['compartmentId'] = compartment_id
    _details['executionTimeOutInSeconds'] = execution_time_out_in_seconds
    _details['target'] = cli_util.parse_json_parameter("target", target)
    _details['content'] = cli_util.parse_json_parameter("content", content)

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

    client = cli_util.build_client('compute_instance_agent',
                                   'compute_instance_agent', ctx)
    result = client.create_instance_agent_command(
        create_instance_agent_command_details=_details, **kwargs)
    cli_util.render_response(result, ctx)
Esempio n. 2
0
def get_rover_node_certificate_extended(ctx, **kwargs):
    rover_node_id = kwargs['node_id']
    output_file_path = kwargs['output_file_path']

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

    if isinstance(output_file_path, six.string_types) and len(output_file_path.strip()) == 0:
        raise click.UsageError('Parameter --output-file-path 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('rover', 'rover_node', ctx)
    result = client.get_rover_node_certificate(
        rover_node_id=rover_node_id,
        **kwargs
    )

    crt_data = cli_util.to_dict(result.data)
    with open(output_file_path, "w") as f:
        for key, val in crt_data.items():
            f.write(str(key) + str(val))
Esempio n. 3
0
def change_sender_compartment(ctx, from_json, sender_id, compartment_id,
                              if_match):

    if isinstance(sender_id, six.string_types) and len(sender_id.strip()) == 0:
        raise click.UsageError(
            'Parameter --sender-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('email', ctx)
    result = client.change_sender_compartment(
        sender_id=sender_id,
        change_sender_compartment_details=details,
        **kwargs)
    cli_util.render_response(result, ctx)
Esempio n. 4
0
def get_package(ctx, from_json, listing_id, package_version, 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')

    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_package(listing_id=listing_id,
                                package_version=package_version,
                                **kwargs)
    cli_util.render_response(result, ctx)
Esempio n. 5
0
def generate_session_token(ctx, from_json, scopes, packaging_config_id,
                           time_expires, asset_ids):

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

    _details = {}
    _details['scopes'] = cli_util.parse_json_parameter("scopes", scopes)
    _details['packagingConfigId'] = packaging_config_id

    if time_expires is not None:
        _details['timeExpires'] = time_expires

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

    client = cli_util.build_client('media_services', 'media_stream', ctx)
    result = client.generate_session_token(
        generate_session_token_details=_details, **kwargs)
    cli_util.render_response(result, ctx)
Esempio n. 6
0
def decrypt(ctx, from_json, ciphertext, key_id, associated_data,
            logging_context):

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

    _details = {}
    _details['ciphertext'] = ciphertext
    _details['keyId'] = key_id

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

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

    client = cli_util.build_client('key_management', 'kms_crypto', ctx)
    result = client.decrypt(decrypt_data_details=_details, **kwargs)
    cli_util.render_response(result, ctx)
Esempio n. 7
0
def list_shapes(ctx, from_json, all_pages, page_size, compartment_id, 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 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('rover', 'shape', ctx)
    if all_pages:
        if page_size:
            kwargs['limit'] = page_size

        result = cli_util.list_call_get_all_results(
            client.list_shapes,
            compartment_id=compartment_id,
            **kwargs
        )
    elif limit is not None:
        result = cli_util.list_call_get_up_to_limit(
            client.list_shapes,
            limit,
            page_size,
            compartment_id=compartment_id,
            **kwargs
        )
    else:
        result = client.list_shapes(
            compartment_id=compartment_id,
            **kwargs
        )
    cli_util.render_response(result, ctx)
Esempio n. 8
0
def encrypt(ctx, from_json, key_id, plaintext, associated_data,
            logging_context):

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

    details = {}
    details['keyId'] = key_id
    details['plaintext'] = plaintext

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

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

    client = cli_util.build_client('kms_crypto', ctx)
    result = client.encrypt(encrypt_data_details=details, **kwargs)
    cli_util.render_response(result, ctx)
Esempio n. 9
0
def list_transfer_jobs(ctx, from_json, all_pages, page_size, compartment_id, lifecycle_state, display_name, limit, page):

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

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

        result = cli_util.list_call_get_all_results(
            client.list_transfer_jobs,
            compartment_id=compartment_id,
            **kwargs
        )
    elif limit is not None:
        result = cli_util.list_call_get_up_to_limit(
            client.list_transfer_jobs,
            limit,
            page_size,
            compartment_id=compartment_id,
            **kwargs
        )
    else:
        result = client.list_transfer_jobs(
            compartment_id=compartment_id,
            **kwargs
        )
    cli_util.render_response(result, ctx)
Esempio n. 10
0
def search_logs(ctx, from_json, time_start, time_end, search_query,
                is_return_field_info, 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['timeStart'] = time_start
    _details['timeEnd'] = time_end
    _details['searchQuery'] = search_query

    if is_return_field_info is not None:
        _details['isReturnFieldInfo'] = is_return_field_info

    client = cli_util.build_client('loggingsearch', 'log_search', ctx)
    result = client.search_logs(search_logs_details=_details, **kwargs)
    cli_util.render_response(result, ctx)
Esempio n. 11
0
def create_config_create_metric_group_details(ctx, from_json, apm_domain_id,
                                              display_name, filter_id, metrics,
                                              freeform_tags, defined_tags,
                                              namespace, dimensions,
                                              opc_dry_run):

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

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

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

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

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

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

    _details['configType'] = 'METRIC_GROUP'

    client = cli_util.build_client('apm_config', 'config', ctx)
    result = client.create_config(apm_domain_id=apm_domain_id,
                                  create_config_details=_details,
                                  **kwargs)
    cli_util.render_response(result, ctx)
Esempio n. 12
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)
Esempio n. 13
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', '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)
Esempio n. 14
0
def approve_organization_tenancy_for_transfer(ctx, from_json, compartment_id,
                                              organization_tenancy_id,
                                              if_match):

    if isinstance(organization_tenancy_id, six.string_types) and len(
            organization_tenancy_id.strip()) == 0:
        raise click.UsageError(
            'Parameter --organization-tenancy-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('tenant_manager_control_plane',
                                   'organization', ctx)
    result = client.approve_organization_tenancy_for_transfer(
        compartment_id=compartment_id,
        organization_tenancy_id=organization_tenancy_id,
        **kwargs)
    cli_util.render_response(result, ctx)
Esempio n. 15
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)
def get_job_logs_extended(ctx, job_id, type, level_greater_than_or_equal_to, sort_order, limit, page, timestamp_greater_than_or_equal_to, timestamp_less_than_or_equal_to, all_pages, **kwargs):

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

    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')

    kwargs = {}
    if type is not None and len(type) > 0:
        kwargs['type'] = type
    if level_greater_than_or_equal_to is not None:
        kwargs['level_greater_than_or_equal_to'] = level_greater_than_or_equal_to
    if sort_order is not None:
        kwargs['sort_order'] = sort_order
    if limit is not None:
        kwargs['limit'] = limit
    if page is not None:
        kwargs['page'] = page
    if timestamp_greater_than_or_equal_to is not None:
        kwargs['timestamp_greater_than_or_equal_to'] = timestamp_greater_than_or_equal_to
    if timestamp_less_than_or_equal_to is not None:
        kwargs['timestamp_less_than_or_equal_to'] = timestamp_less_than_or_equal_to
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('resource_manager', 'resource_manager', ctx)

    if all_pages:
        result = cli_util.list_call_get_all_results(
            client.get_job_logs,
            job_id=job_id,
            **kwargs
        )
    # GetJobLogs operation already has built in support for limit
    else:
        result = client.get_job_logs(
            job_id=job_id,
            **kwargs
        )
    cli_util.render_response(result, ctx)
Esempio n. 17
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)
Esempio n. 18
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)
Esempio n. 19
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)
Esempio n. 20
0
def delete_data_safe_private_endpoint(ctx, from_json, wait_for_state, max_wait_seconds, wait_interval_seconds, data_safe_private_endpoint_id, if_match):

    if isinstance(data_safe_private_endpoint_id, six.string_types) and len(data_safe_private_endpoint_id.strip()) == 0:
        raise click.UsageError('Parameter --data-safe-private-endpoint-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('data_safe', 'data_safe', ctx)
    result = client.delete_data_safe_private_endpoint(
        data_safe_private_endpoint_id=data_safe_private_endpoint_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. 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)
Esempio n. 21
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)
Esempio n. 22
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('data_safe', 'data_safe', 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)
Esempio n. 23
0
def list_access_request_histories(ctx, from_json, all_pages, page_size, access_request_id, limit, page):

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

    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 limit is not None:
        kwargs['limit'] = limit
    if page is not None:
        kwargs['page'] = page
    kwargs['opc_request_id'] = cli_util.use_or_generate_request_id(ctx.obj['request_id'])
    client = cli_util.build_client('operator_access_control', 'access_requests', ctx)
    if all_pages:
        if page_size:
            kwargs['limit'] = page_size

        result = cli_util.list_call_get_all_results(
            client.list_access_request_histories,
            access_request_id=access_request_id,
            **kwargs
        )
    elif limit is not None:
        result = cli_util.list_call_get_up_to_limit(
            client.list_access_request_histories,
            limit,
            page_size,
            access_request_id=access_request_id,
            **kwargs
        )
    else:
        result = client.list_access_request_histories(
            access_request_id=access_request_id,
            **kwargs
        )
    cli_util.render_response(result, ctx)
Esempio n. 24
0
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)
Esempio n. 25
0
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)
Esempio n. 26
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)
Esempio n. 27
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)
Esempio n. 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)
Esempio n. 29
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)
Esempio n. 30
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)