예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
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)