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 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, entity_ctx: PulpEntityContext, name: str) -> None: entity = {"name": name} result = entity_ctx.create(body=entity) pulp_ctx.output_result(result)