Skip to content

Users Api Wrapped

immichpy.client.wrapper.users_api_wrapped.UsersApiWrapped

UsersApiWrapped(api_client=None)

Bases: UsersApi

Wrapper for the UsersApi that provides convenience methods.

Source code in immichpy/client/generated/api/users_api.py
51
52
53
54
def __init__(self, api_client=None) -> None:
    if api_client is None:
        api_client = ApiClient.get_default()
    self.api_client = api_client

get_profile_image_to_file async

get_profile_image_to_file(id: UUID, out_dir: Path, filename: str | None = None, show_progress: bool = False, **kwargs: Any) -> Path

Download a user's profile image and save it to a file.

Parameters:

Name Type Description Default
id UUID

The user ID.

required
out_dir Path

The directory to write the profile image to.

required
filename str | None

The filename to use. If not provided, we try to derive it from the headers or default to "profile-" + user_id.

None
show_progress bool

Whether to show a progress bar while downloading.

False
kwargs Any

Additional arguments to pass to the get_profile_image_without_preload_content method.

For exact request/response behavior, inspect UsersApi.get_profile_image_without_preload_content in the generated client.

{}
Source code in immichpy/client/wrapper/users_api_wrapped.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
async def get_profile_image_to_file(
    self,
    id: UUID,
    out_dir: Path,
    filename: str | None = None,
    show_progress: bool = False,
    **kwargs: Any,
) -> Path:
    """
    Download a user's profile image and save it to a file.

    :param id: The user ID.
    :param out_dir: The directory to write the profile image to.
    :param filename: The filename to use. If not provided, we try to derive it from the headers
        or default to "profile-" + user_id.
    :param show_progress: Whether to show a progress bar while downloading.
    :param kwargs: Additional arguments to pass to the `get_profile_image_without_preload_content` method.

    For exact request/response behavior, inspect `UsersApi.get_profile_image_without_preload_content`
    in the generated client.
    """
    out_dir.mkdir(parents=True, exist_ok=True)

    def make_request(extra_headers: HeadersType | None):
        return self.get_profile_image_without_preload_content(
            id=id,
            _headers=kwargs.get("_headers", {}) | (extra_headers or {}),
            **kwargs,
        )

    return await download_file(
        make_request=make_request,
        out_dir=out_dir,
        resolve_filename=lambda headers: resolve_output_filename(
            headers,
            name=filename,
            default_base=f"profile-{id}",
        ),
        show_progress=show_progress,
    )