def update_version( repo: Optional[str], package: Optional[str], version: Optional[str], is_operation_confirmed: Optional[bool] = False, ): username, headers = get_auth_header_and_username() if not username: return if not repo: repo = repositories_core.select_from_available_repo(subject=username) if not package: package = packages_core.select_from_available_packages( subject=username, repo=repo) if not version: version = files_core.select_from_available_versions(subject=username, repo=repo, package=package, filename=None) body = pydantic_to_prompt(model=VersionUpdateBodyModel) if not is_operation_confirmed and not is_operation_confirm(): return url = get_url(f"/packages/{username}/{repo}/{package}/versions/{version}") response = httpx.patch(url=url, json=body.dict(), headers=headers) response_handler(response=response, return_with_out_model=True)
def delete_repo(repo: Optional[str], is_operation_confirmed: Optional[bool] = False): username, headers = get_auth_header_and_username() if not username: return if not repo: repo = select_from_available_repo(subject=username) if not is_operation_confirmed and not is_operation_confirm(): return url: str = get_url(f"/repo/{username}/{repo}") response = httpx.delete(url=url, headers=headers) return response_handler(response, RepoDeleteResponseModel)
def update_repo(repo: Optional[str], is_operation_confirmed: Optional[bool] = False): username, headers = get_auth_header_and_username() if not username: return if not repo: repo = select_from_available_repo(subject=username) body = pydantic_to_prompt(model=RepoUpdateBodyModel) if not is_operation_confirmed and not is_operation_confirm(): return url: str = get_url(f"/repos/{username}/{repo}") response = httpx.patch(url=url, json=body.dict(), headers=headers) response_handler(response=response)
def delete_package( repo: Optional[str], package: Optional[str], is_operation_confirmed: Optional[bool] = False, ): username, headers = get_auth_header_and_username() if not username: exit(1) if not repo: repo = repositories_core.select_from_available_repo(subject=username) if not package: package = select_from_available_packages(subject=username, repo=repo) if not is_operation_confirmed and not is_operation_confirm(): exit(1) url = get_url(f"/packages/{username}/{repo}/{package}") response = httpx.delete(url=url, headers=headers) return response_handler(response=response, return_model=PackageDeleteResponseModel)
def update_package( repo: Optional[str], package: Optional[str], is_operation_confirmed: Optional[bool] = False, ): username, headers = get_auth_header_and_username() if not username: exit(1) if not repo: repo = repositories_core.select_from_available_repo(subject=username) if not package: package = select_from_available_packages(subject=username, repo=repo) body = pydantic_to_prompt(PackageUpdateBodyModel) if not is_operation_confirmed and not is_operation_confirm(): exit(1) url = get_url(f"/packages/{username}/{repo}/{package}") response = httpx.patch(url=url, json=body.dict(), headers=headers) response_handler(response=response)
def delete_version( repo: Optional[str], package: Optional[str], version: Optional[str], is_operation_confirmed: Optional[bool] = False, ): username, headers = get_auth_header_and_username() if not username: return if not repo: repo = repositories_core.select_from_available_repo(subject=username) if not package: package = packages_core.select_from_available_packages( subject=username, repo=repo) if not version: version = files_core.select_from_available_versions(subject=username, repo=repo, package=package, filename=None) if not is_operation_confirmed and not is_operation_confirm(): return url = get_url(f"/packages/{username}/{repo}/{package}/versions/{version}") response = httpx.delete(url=url, headers=headers) return response_handler(response=response)