Example #1
0
def update(
    pulp_ctx: PulpContext,
    repository_ctx: PulpRepositoryContext,
    description: Optional[str],
    remote: Optional[str],
) -> None:
    repository = repository_ctx.entity
    repository_href = repository_ctx.pulp_href

    if description is not None:
        if description == "":
            # unset the description
            description = None
        if description != repository["description"]:
            repository["description"] = description

    if remote is not None:
        if remote == "":
            # unset the remote
            repository["remote"] = ""
        elif remote:
            remote_href: str = PulpFileRemoteContext(pulp_ctx, entity={"name": remote}).pulp_href
            repository["remote"] = remote_href

    repository_ctx.update(repository_href, body=repository)
Example #2
0
def update(
    pulp_ctx: PulpContext,
    repository_ctx: PulpRepositoryContext,
    name: str,
    description: Optional[str],
    remote: Optional[str],
) -> None:
    repository = repository_ctx.find(name=name)
    repository_href = repository["pulp_href"]

    if description is not None:
        if description == "":
            # unset the description
            description = None
        if description != repository["description"]:
            repository["description"] = description

    if remote is not None:
        if remote == "":
            # unset the remote
            repository["remote"] = ""
        elif remote:
            remote_href: str = PulpContainerRemoteContext(pulp_ctx).find(
                name=remote)["pulp_href"]
            repository["remote"] = remote_href

    repository_ctx.update(repository_href, body=repository)
Example #3
0
def update(
    pulp_ctx: PulpContext,
    repository_ctx: PulpRepositoryContext,
    name: str,
    description: Optional[str],
    remote: Optional[str],
) -> None:
    """
    The description and remote can both be unset using an empty string

    e.g. pulp ansible repository update --name foo --description ""
    """
    repository: EntityDefinition = repository_ctx.find(name=name)

    if description is not None:
        if description == "":
            # unset the description
            description = None
        if description != repository["description"]:
            repository["description"] = description

    if remote is not None:
        if remote == "":
            # unset the remote
            remote_href: str = ""
        else:
            try:
                remote_href = PulpAnsibleCollectionRemoteContext(
                    pulp_ctx).find(name=remote)["pulp_href"]
            except click.ClickException:
                remote_href = PulpAnsibleRoleRemoteContext(pulp_ctx).find(
                    name=remote)["pulp_href"]

        repository["remote"] = remote_href

    repository_ctx.update(repository["pulp_href"], body=repository)
    result = repository_ctx.show(repository["pulp_href"])
    pulp_ctx.output_result(result)