def sync( pulp_ctx: PulpContext, repository_ctx: PulpRepositoryContext, name: str, remote: Optional[str], ) -> None: """ If remote is not specified sync will try to use the default remote associated with the repository """ repository: EntityDefinition = repository_ctx.find(name=name) repository_href: str = repository["pulp_href"] body: EntityDefinition = dict() if remote: try: remote_href: str = PulpAnsibleCollectionRemoteContext( pulp_ctx).find(name=remote)["pulp_href"] except click.ClickException: remote_href = PulpAnsibleRoleRemoteContext(pulp_ctx).find( name=remote)["pulp_href"] body["remote"] = remote_href elif repository["remote"] is None: raise click.ClickException( f"Repository '{name}' does not have a default remote. Please specify with '--remote'." ) repository_ctx.sync( href=repository_href, body=body, )
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)
def sync( pulp_ctx: PulpContext, repository_ctx: PulpRepositoryContext, name: str, remote: Optional[str], mirror: Optional[bool], ) -> None: repository = repository_ctx.find(name=name) repository_href = repository["pulp_href"] body: Dict[str, Any] = {} if mirror: body["mirror"] = mirror if remote: remote_href: str = PulpRpmRemoteContext(pulp_ctx).find( name=remote)["pulp_href"] body["remote"] = remote_href elif repository["remote"] is None: raise click.ClickException( f"Repository '{name}' does not have a default remote. Please specify with '--remote'." ) repository_ctx.sync( href=repository_href, body=body, )
def sync( pulp_ctx: PulpContext, repository_ctx: PulpRepositoryContext, name: str, remote: Optional[str], ) -> None: if repository_ctx.SYNC_ID is None: raise click.ClickException("Repository type does not support sync.") repository = repository_ctx.find(name=name) repository_href = repository["pulp_href"] body = {} if remote: remote_href: str = PulpContainerRemoteContext(pulp_ctx).find( name=remote)["pulp_href"] body["remote"] = remote_href elif repository["remote"] is None: raise click.ClickException( f"Repository '{name}' does not have a default remote. Please specify with '--remote'." ) repository_ctx.sync( href=repository_href, body=body, )
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)