Skip to content

pulp_cli.generic

pulp_cli.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: str, api_kwargs: t.Dict[str, t.Any], background_tasks: bool, timeout: int, format: str, domain: str = 'default', username: t.Optional[str] = None, password: t.Optional[str] = None, oauth2_client_id: t.Optional[str] = None, oauth2_client_secret: t.Optional[str] = None)

Bases: PulpContext

Subclass of the Context that overwrites the CLI specifics.

Parameters:

  • api_root (str) –

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

  • api_kwargs (Dict[str, Any]) –

    Extra arguments to pass to the wrapped OpenAPI object.

  • background_tasks (bool) –

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

  • timeout (int) –

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

  • format (str) –

    The format to be used by output_result.

  • domain (str, default: 'default' ) –

    Name of the domain to interact with.

output_result(result: t.Any) -> None

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

Parameters:

  • result (Any) –

    JSON serializable data to be outputted.

PulpOption(*args: t.Any, needs_plugins: t.Optional[t.List[PluginRequirement]] = None, allowed_with_contexts: t.Optional[t.Tuple[t.Type[PulpEntityContext]]] = None, **kwargs: t.Any)

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: str) -> t.Union[str, int]

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: str) -> t.Union[str, float]

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: t.Optional[str] = None, **kwargs: t.Any) -> t.Callable[[_AnyCallable], PulpCommand]

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: t.Optional[str] = None, **kwargs: t.Any) -> t.Callable[[_AnyCallable], PulpGroup]

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: t.Callable[[click.Context, click.Parameter, str], t.Any]) -> t.Any

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: click.Context, param: click.Parameter, value: t.Optional[str]) -> t.Any

A reusable callback that will parse its value from json.

pulp_option(*args: t.Any, **kwargs: t.Any) -> t.Callable[[FC], FC]

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: t.Any) -> click.Command

A factory that creates a list command.

show_command(**kwargs: t.Any) -> click.Command

A factory that creates a show command.

create_command(**kwargs: t.Any) -> click.Command

A factory that creates a create command.

update_command(**kwargs: t.Any) -> click.Command

A factory that creates an update command.

destroy_command(**kwargs: t.Any) -> click.Command

A factory that creates a destroy command.

version_command(**kwargs: t.Any) -> click.Command

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: t.Any) -> click.Command

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: t.Any) -> click.Command

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: t.Any) -> click.Group

A factory that creates a repository content command group.