Skip to content

pulpcore.cli.common.generic

pulpcore.cli.common.generic

pass_pulp_context = click.make_pass_decorator(PulpCLIContext) module-attribute

Decorator to make the Pulp context available to a command.

pass_view_set_context = click.make_pass_decorator(PulpViewSetContext) module-attribute

Decorator to make the nearest view set context available to a command.

pass_entity_context = click.make_pass_decorator(PulpEntityContext) module-attribute

Decorator to make the nearest entity context available to a command.

pass_acs_context = click.make_pass_decorator(PulpACSContext) module-attribute

Decorator to make the nearest ACS context available to a command.

pass_content_context = click.make_pass_decorator(PulpContentContext) module-attribute

Decorator to make the nearest content context available to a command.

pass_repository_context = click.make_pass_decorator(PulpRepositoryContext) module-attribute

Decorator to make the nearest repository context available to a command.

pass_repository_version_context = click.make_pass_decorator(PulpRepositoryVersionContext) module-attribute

Decorator to make the nearest repository version context available to a command.

load_string_callback = load_file_wrapper(lambda c, p, x: x) module-attribute

A reusable callback for text parameters.

It will read data from a file if their value starts with "@", otherwise use it unchanged.

load_json_callback = load_file_wrapper(json_callback) module-attribute

A reusable callback that will parse its value from json.

Will optionally read from a file prefixed with "@".

IncompatibleContext

Bases: UsageError

Exception to signal that an option or subcommand was used with an incompatible context.

ClickNoWait

Bases: ClickException

Exception raised when a user interrupts waiting for a task/taskgroup.

PulpCLIContext(api_root, api_kwargs, background_tasks, timeout, format, domain='default')

Bases: PulpContext

Subclass of the Context that overwrites the CLI specifics.

Parameters:

Name Type Description Default
api_root str

The base url (excluding "api/v3/") to the server's api.

required
api_kwargs Dict[str, Any]

Extra arguments to pass to the wrapped OpenAPI object.

required
background_tasks bool

Whether to wait for tasks. If True, all tasks triggered will immediately raise PulpNoWait.

required
timeout int

Limit of time (in seconds) to wait for unfinished tasks.

required
format str

The format to be used by output_result.

required
domain str

Name of the domain to interact with.

'default'

output_result(result)

Dump the provided result to the console using the selected renderer.

Parameters:

Name Type Description Default
result Any

JSON serializable data to be outputted.

required

PulpOption(*args, needs_plugins=None, allowed_with_contexts=None, **kwargs)

Bases: Option

Pulp-CLI specific subclass of click.Option.

The preferred way to use this is through the pulp_option factory.

int_or_empty(value)

Turns a string into an integer or keeps the empty string.

This is meant to be used as a click parameter type.

float_or_empty(value)

Turns a string into a float or keeps the empty string.

This is meant to be used as a click parameter type.

pulp_command(name=None, **kwargs)

Pulp command factory.

Creates a click compatible command that can be modified with needs_plugins and allowed_with_contexts. It allows rendering the docstring with the values of ENTITY and ENTITIES from the closest entity context.

pulp_group(name=None, **kwargs)

Pulp command group factory.

Creates a click compatible group command that selects subcommands based on allowed_with_contexts and creates PulpCommand subcommands by default.

load_file_wrapper(handler)

A wrapper that is used for chaining or decorating callbacks that manipulate input data.

When prefixed with "@", content will be read from a file instead of being taken from the command line.

json_callback(ctx, param, value)

A reusable callback that will parse its value from json.

pulp_option(*args, **kwargs)

Factory of PulpOption objects.

PulpOption provides extra features over click.Option, namely:

  1. Define version constrains.
  2. Support for template variables in the help message.
  3. Limit the use of options to certain entity contexts.

Examples:

Define version constrains and custom help message:

pulp_option(
    "--name",
    needs_plugins=[PluginRequirement("rpm", specifier=">=3.12.0")],
    help=_("Name of {entity}"),
    allowed_with_contexts=(PulpRpmRepositoryContext,),
)

list_command(**kwargs)

A factory that creates a list command.

show_command(**kwargs)

A factory that creates a show command.

create_command(**kwargs)

A factory that creates a create command.

update_command(**kwargs)

A factory that creates an update command.

destroy_command(**kwargs)

A factory that creates a destroy command.

version_command(**kwargs)

A factory that creates a repository version command group.

This group contains list, show, destroy and repair subcommands. If list_only=True is passed, only the list command will be instantiated. Repository lookup options can be provided in decorators.

label_command(**kwargs)

A factory that creates a label command group.

This group contains set, unset and show commands and acts on the nearest entity context. Pass options in as decorators to customize the entity lookup options.

role_command(**kwargs)

A factory that creates a (object) role command group.

This group contains my-permissions, list, add and remove. Pass options in as decorators to customize the entity lookup options.

repository_content_command(**kwargs)

A factory that creates a repository content command group.