コード例 #1
0
ファイル: repository.py プロジェクト: evgeni/pulp-cli
def modify(
    pulp_ctx: PulpContext,
    repository_ctx: PulpRepositoryContext,
    add_content: List[Dict[str, str]],
    remove_content: List[Dict[str, str]],
    base_version: Optional[int],
) -> None:
    """Please use 'content modify' instead."""
    repository_href = repository_ctx.pulp_href

    base_version_href: Optional[str]
    if base_version is not None:
        base_version_href = f"{repository_href}versions/{base_version}/"
    else:
        base_version_href = None

    add_content_href = [
        PulpFileContentContext(pulp_ctx, entity=unit).pulp_href for unit in add_content
    ]
    remove_content_href = [
        PulpFileContentContext(pulp_ctx, entity=unit).pulp_href for unit in remove_content
    ]

    repository_ctx.modify(
        href=repository_href,
        add_content=add_content_href,
        remove_content=remove_content_href,
        base_version=base_version_href,
    )
コード例 #2
0
ファイル: content.py プロジェクト: melcorr/pulp-cli
def upload(
    pulp_ctx: PulpContext,
    entity_ctx: PulpFileContentContext,
    relative_path: str,
    file: IO[bytes],
    chunk_size: int,
) -> None:
    """Create a file content unit by uploading a file"""
    artifact_href = PulpArtifactContext(pulp_ctx).upload(file, chunk_size)
    content = {"relative_path": relative_path, "artifact": artifact_href}
    task = entity_ctx.create(body=content)
    result = entity_ctx.show(task["created_resources"][0])
    pulp_ctx.output_result(result)
コード例 #3
0
ファイル: content.py プロジェクト: melcorr/pulp-cli
def create(
    pulp_ctx: PulpContext,
    entity_ctx: PulpFileContentContext,
    relative_path: str,
    sha256: str,
) -> None:
    """Create a file content unit from an existing artifact"""
    artifact = PulpArtifactContext(pulp_ctx).find(sha256=sha256)
    content = {
        "relative_path": relative_path,
        "artifact": artifact["pulp_href"]
    }
    task = entity_ctx.create(body=content)
    result = entity_ctx.show(task["created_resources"][0])
    pulp_ctx.output_result(result)
コード例 #4
0
ファイル: repository.py プロジェクト: evgeni/pulp-cli
def remove(
    pulp_ctx: PulpContext,
    repository_ctx: PulpRepositoryContext,
    sha256: str,
    relative_path: str,
    base_version: Optional[int],
) -> None:
    """Please use 'content remove' instead."""
    repository_href = repository_ctx.pulp_href

    base_version_href: Optional[str]
    if base_version is not None:
        base_version_href = f"{repository_href}versions/{base_version}/"
    else:
        base_version_href = None

    content_href = PulpFileContentContext(
        pulp_ctx, entity={"sha256": sha256, "relative_path": relative_path}
    ).pulp_href

    repository_ctx.modify(
        href=repository_href,
        remove_content=[content_href],
        base_version=base_version_href,
    )
コード例 #5
0
ファイル: repository.py プロジェクト: ggainey/pulp-cli
def _content_callback(ctx: click.Context, param: click.Parameter,
                      value: Any) -> Any:
    if value:
        pulp_ctx = ctx.find_object(PulpContext)
        assert pulp_ctx is not None
        ctx.obj = PulpFileContentContext(pulp_ctx, entity=value)
    return value
コード例 #6
0
ファイル: repository.py プロジェクト: evgeni/pulp-cli
def _content_callback(ctx: click.Context, param: click.Parameter, value: Any) -> Optional[str]:
    if value:
        pulp_ctx: PulpContext = ctx.find_object(PulpContext)
        ctx.obj = PulpFileContentContext(pulp_ctx, entity=value)
    return str(value)
コード例 #7
0
def content(ctx: click.Context, pulp_ctx: PulpContext, content_type: str) -> None:
    if content_type == "file":
        ctx.obj = PulpFileContentContext(pulp_ctx)
    else:
        raise NotImplementedError()