def callback(pulp_ctx: PulpContext, entity_ctx: PulpEntityContext, **kwargs: Any) -> None: """ Update a {entity}. """ body: EntityDefinition = entity_ctx.preprocess_body(kwargs) entity_ctx.update(href=entity_ctx.pulp_href, body=body)
def callback(pulp_ctx: PulpContext, entity_ctx: PulpEntityContext, **kwargs: Any) -> None: """ Create a {entity}. """ body: EntityDefinition = entity_ctx.preprocess_body(kwargs) result = entity_ctx.create(body=body) if "created_resources" in result: entity_ctx.pulp_href = result["created_resources"][0] result = entity_ctx.entity pulp_ctx.output_result(result)
def create( pulp_ctx: PulpContext, remote_ctx: PulpEntityContext, name: str, url: str, requirements_file: Any, requirements: Optional[str], auth_url: Optional[str], token: Optional[str], **remote_options: Dict[str, Any], ) -> None: """ Creates a Collection or Role remote based on -t parameter e.g. pulp ansible remote -t role create ... """ body: EntityDefinition = {"name": name, "url": url} body.update( check_collection_options( remote_ctx=remote_ctx, requirements_file=requirements_file, requirements=requirements, auth_url=auth_url, token=token, )) if remote_options: removed_nulls = { k: v for k, v in remote_options.items() if v is not None } body.update(removed_nulls) result = remote_ctx.create(body=body) pulp_ctx.output_result(result)
def list_entities(pulp_ctx: PulpContext, entity_ctx: PulpEntityContext, limit: int, offset: int, **kwargs: Any) -> None: """ Show a list of entries """ parameters = {k: v for k, v in kwargs.items() if v is not None} result = entity_ctx.list(limit=limit, offset=offset, parameters=parameters) pulp_ctx.output_result(result)
def callback( pulp_ctx: PulpContext, entity_ctx: PulpEntityContext, limit: int, offset: int, **kwargs: Any ) -> None: """ Show the list of optionally filtered {entities}. """ parameters = {k: v for k, v in kwargs.items() if v is not None} result = entity_ctx.list(limit=limit, offset=offset, parameters=parameters) pulp_ctx.output_result(result)
def role_remove( pulp_ctx: PulpContext, entity_ctx: PulpEntityContext, role: str, users: List[str], groups: List[str], ) -> None: result = entity_ctx.remove_role(role, users, groups) pulp_ctx.output_result(result)
def update( pulp_ctx: PulpContext, remote_ctx: PulpEntityContext, name: str, url: Optional[str], requirements_file: Any, requirements: Optional[str], auth_url: Optional[str], token: Optional[str], **remote_options: Dict[str, Any], ) -> None: """ Use -t to specify the type of the remote you are updating e.g. pulp ansible remote -t role update ... """ body: EntityDefinition = dict() body.update( check_collection_options( remote_ctx=remote_ctx, requirements_file=requirements_file, requirements=requirements, auth_url=auth_url, token=token, )) if url: body["url"] = url if remote_options: removed_nulls = { k: v for k, v in remote_options.items() if v is not None } body.update(removed_nulls) remote = remote_ctx.find(name=name) remote_href = remote["pulp_href"] remote_ctx.update(remote_href, body=body) result = remote_ctx.show(remote_href) pulp_ctx.output_result(result)
def label_unset(entity_ctx: PulpEntityContext, key: str) -> None: """Remove a label with a given key""" href = entity_ctx.entity["pulp_href"] entity_ctx.unset_label(href, key)
def label_set(entity_ctx: PulpEntityContext, key: str, value: str) -> None: """Add or update a label""" href = entity_ctx.entity["pulp_href"] entity_ctx.set_label(href, key, value)
def callback(entity_ctx: PulpEntityContext) -> None: """ Destroy a {entity}. """ entity_ctx.delete(entity_ctx.pulp_href)
def destroy_by_href(entity_ctx: PulpEntityContext, href: str) -> None: """ Destroy an entry """ entity_ctx.delete(href)
def destroy_by_name(entity_ctx: PulpEntityContext, name: str) -> None: """ Destroy an entry """ href = entity_ctx.find(name=name)["pulp_href"] entity_ctx.delete(href)
def show_by_name(pulp_ctx: PulpContext, entity_ctx: PulpEntityContext, name: str) -> None: """Shows details of an entry""" href = entity_ctx.find(name=name)["pulp_href"] entity = entity_ctx.show(href) pulp_ctx.output_result(entity)
def role_list(pulp_ctx: PulpContext, entity_ctx: PulpEntityContext) -> None: result = entity_ctx.list_roles() pulp_ctx.output_result(result)
def my_permissions(pulp_ctx: PulpContext, entity_ctx: PulpEntityContext) -> None: result = entity_ctx.my_permissions() pulp_ctx.output_result(result)
def label_show(entity_ctx: PulpEntityContext, key: str) -> None: """Show the value for a particular label key""" href = entity_ctx.entity["pulp_href"] click.echo(entity_ctx.show_label(href, key))
def create(pulp_ctx: PulpContext, entity_ctx: PulpEntityContext, name: str) -> None: entity = {"name": name} result = entity_ctx.create(body=entity) pulp_ctx.output_result(result)
def show_by_href(pulp_ctx: PulpContext, entity_ctx: PulpEntityContext, href: str) -> None: """Shows details of an entry""" entity = entity_ctx.show(href) pulp_ctx.output_result(entity)