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 add_device() -> None: username, header = get_auth_header_and_username() if not username: return url = get_url("/devices/") body = pydantic_to_prompt(model=CreateDeviceModel) response = httpx.post(url=url, json=body.dict(), headers=header) response_handler(response=response, return_model=DeviceCreateResponseModel)
def create_repo(): username, headers = get_auth_header_and_username() if not username: return body = pydantic_to_prompt(model=RepoCreateBodyModel) url: str = get_url(f"/repos/{username}/{body.name}") response = httpx.post(url=url, json=body.dict(), headers=headers) response_handler(response, RepoCreateResponseModel)
def create_package(repo: Optional[str]): username, headers = get_auth_header_and_username() if not username: return if not repo: repo = repositories_core.select_from_available_repo(subject=username) body = pydantic_to_prompt(model=PackageCreateBodyModel) url = get_url(f"/packages/{username}/{repo}") response = httpx.post(url=url, json=body.dict(), headers=headers) return response_handler(response=response)
def update_device(mac_address: str, is_operation_confirmed: bool = False) -> None: username, header = get_auth_header_and_username() if not username: return url = get_url("/devices/{mac_address}") body = pydantic_to_prompt(model=UpdateDeviceModel) if not is_operation_confirmed and not is_operation_confirm(): return response = httpx.patch(url=url, json=body.dict(), headers=header) response_handler(response=response, return_model=DeviceModel)
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 create_version(repo: Optional[str], package: Optional[str]): 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) body = pydantic_to_prompt(model=VersionCreateBodyModel) url = get_url(f"/packages/{username}/{repo}/{package}/versions") response = httpx.post(url=url, json=body.dict(), headers=headers) response_handler(response=response, return_with_out_model=True)
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)