Skip to content

Configuration

immichpy.client.generated.configuration.Configuration

Configuration(host: Optional[str] = None, api_key: Optional[Dict[str, str]] = None, api_key_prefix: Optional[Dict[str, str]] = None, username: Optional[str] = None, password: Optional[str] = None, access_token: Optional[str] = None, server_index: Optional[int] = None, server_variables: Optional[ServerVariablesT] = None, server_operation_index: Optional[Dict[int, int]] = None, server_operation_variables: Optional[Dict[int, ServerVariablesT]] = None, ignore_operation_servers: bool = False, ssl_ca_cert: Optional[str] = None, retries: Optional[Union[int, RetryOptionsBase]] = None, trace_configs: Optional[List[TraceConfig]] = None, tcp_connector_limit_per_host: Optional[int] = None, client_session_kwargs: Optional[Dict[str, Any]] = None, ca_cert_data: Optional[Union[str, bytes]] = None, cert_file: Optional[str] = None, key_file: Optional[str] = None, verify_ssl: bool = True, assert_hostname: Optional[bool] = None, tls_server_name: Optional[str] = None, connection_pool_maxsize: Optional[int] = None, proxy: Optional[str] = None, proxy_headers: Optional[Any] = None, safe_chars_for_path_param: str = '', client_side_validation: bool = True, socket_options: Optional[Any] = None, datetime_format: str = '%Y-%m-%dT%H:%M:%S.%f%z', date_format: str = '%Y-%m-%d', *, debug: Optional[bool] = None)

This class contains various settings of the API client.

:param host: Base url.
:param ignore_operation_servers
  Boolean to ignore operation servers for the API client.
  Config will use `host` as the base url regardless of the operation servers.
:param api_key: Dict to store API key(s).
  Each entry in the dict specifies an API key.
  The dict key is the name of the security scheme in the OAS specification.
  The dict value is the API key secret.
:param api_key_prefix: Dict to store API prefix (e.g. Bearer).
  The dict key is the name of the security scheme in the OAS specification.
  The dict value is an API key prefix when generating the auth data.
:param username: Username for HTTP basic authentication.
:param password: Password for HTTP basic authentication.
:param access_token: Access token.
:param server_index: Index to servers configuration.
:param server_variables: Mapping with string values to replace variables in
  templated server configuration. The validation of enums is performed for
  variables with defined enum values before.
:param server_operation_index: Mapping from operation ID to an index to server
  configuration.
:param server_operation_variables: Mapping from operation ID to a mapping with
  string values to replace variables in templated server configuration.
  The validation of enums is performed for variables with defined enum
  values before.
:param verify_ssl: bool - Set this to false to skip verifying SSL certificate
  when calling API from https server.
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
  in PEM format.
:param retries: int | aiohttp_retry.RetryOptionsBase - Retry configuration.
:param trace_configs: list of aiohttp.TraceConfig instances forwarded to
  aiohttp.ClientSession for tracing/instrumentation (e.g. OpenTelemetry).
:param tcp_connector_limit_per_host: Per-host concurrency cap forwarded to
  aiohttp.TCPConnector(limit_per_host=...). None leaves aiohttp's default (0 = unlimited).
:param client_session_kwargs: Extra keyword arguments merged into
  aiohttp.ClientSession(**kwargs) (e.g. json_serialize=orjson.dumps,
  cookie_jar=aiohttp.DummyCookieJar()).
:param ca_cert_data: verify the peer using concatenated CA certificate data
  in PEM (str) or DER (bytes) format.
:param cert_file: the path to a client certificate file, for mTLS.
:param key_file: the path to a client key file, for mTLS.
:param assert_hostname: Set this to True/False to enable/disable SSL hostname verification.
:param tls_server_name: SSL/TLS Server Name Indication (SNI). Set this to the SNI value expected by the server.
:param connection_pool_maxsize: Connection pool max size. None in the constructor is coerced to 100 for async and cpu_count * 5 for sync.
:param proxy: Proxy URL.
:param proxy_headers: Proxy headers.
:param safe_chars_for_path_param: Safe characters for path parameter encoding.
:param client_side_validation: Enable client-side validation. Default True.
:param socket_options: Options to pass down to the underlying urllib3 socket.
:param datetime_format: Datetime format string for serialization.
:param date_format: Date format string for serialization.

:Example:

API Key Authentication Example.
Given the following security scheme in the OpenAPI specification:
  components:
    securitySchemes:
      cookieAuth:         # name for the security scheme
        type: apiKey
        in: cookie
        name: JSESSIONID  # cookie name

You can programmatically set the cookie:

conf = generated.Configuration( api_key={'cookieAuth': 'abc123'} api_key_prefix={'cookieAuth': 'JSESSIONID'} )

The following cookie will be added to the HTTP request:
   Cookie: JSESSIONID abc123

Constructor

Source code in immichpy/client/generated/configuration.py
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
def __init__(
    self,
    host: Optional[str] = None,
    api_key: Optional[Dict[str, str]] = None,
    api_key_prefix: Optional[Dict[str, str]] = None,
    username: Optional[str] = None,
    password: Optional[str] = None,
    access_token: Optional[str] = None,
    server_index: Optional[int] = None,
    server_variables: Optional[ServerVariablesT] = None,
    server_operation_index: Optional[Dict[int, int]] = None,
    server_operation_variables: Optional[Dict[int, ServerVariablesT]] = None,
    ignore_operation_servers: bool = False,
    ssl_ca_cert: Optional[str] = None,
    retries: Optional[Union[int, aiohttp_retry.RetryOptionsBase]] = None,
    trace_configs: Optional[List[aiohttp.TraceConfig]] = None,
    tcp_connector_limit_per_host: Optional[int] = None,
    client_session_kwargs: Optional[Dict[str, Any]] = None,
    ca_cert_data: Optional[Union[str, bytes]] = None,
    cert_file: Optional[str] = None,
    key_file: Optional[str] = None,
    verify_ssl: bool = True,
    assert_hostname: Optional[bool] = None,
    tls_server_name: Optional[str] = None,
    connection_pool_maxsize: Optional[int] = None,
    proxy: Optional[str] = None,
    proxy_headers: Optional[Any] = None,
    safe_chars_for_path_param: str = "",
    client_side_validation: bool = True,
    socket_options: Optional[Any] = None,
    datetime_format: str = "%Y-%m-%dT%H:%M:%S.%f%z",
    date_format: str = "%Y-%m-%d",
    *,
    debug: Optional[bool] = None,
) -> None:
    """Constructor"""
    self._base_path = (
        "https://raw.githubusercontent.com/api" if host is None else host
    )
    """Default Base url
    """
    self.server_index = 0 if server_index is None and host is None else server_index
    self.server_operation_index = server_operation_index or {}
    """Default server index
    """
    self.server_variables = server_variables or {}
    self.server_operation_variables = server_operation_variables or {}
    """Default server variables
    """
    self.ignore_operation_servers = ignore_operation_servers
    """Ignore operation servers
    """
    self.temp_folder_path = None
    """Temp file folder for downloading files
    """
    # Authentication Settings
    self.api_key = {}
    if api_key:
        self.api_key = api_key
    """dict to store API key(s)
    """
    self.api_key_prefix = {}
    if api_key_prefix:
        self.api_key_prefix = api_key_prefix
    """dict to store API prefix (e.g. Bearer)
    """
    self.refresh_api_key_hook = None
    """function hook to refresh API key if expired
    """
    self.username = username
    """Username for HTTP basic authentication
    """
    self.password = password
    """Password for HTTP basic authentication
    """
    self.access_token = access_token
    """Access token
    """
    self.logger = {}
    """Logging Settings
    """
    self.logger["package_logger"] = logging.getLogger("generated")
    self.logger_format = "%(asctime)s %(levelname)s %(message)s"
    """Log format
    """
    self.logger_stream_handler = None
    """Log stream handler
    """
    self.logger_file_handler: Optional[FileHandler] = None
    """Log file handler
    """
    self.logger_file = None
    """Debug file location
    """
    if debug is not None:
        self.debug = debug
    else:
        self.__debug = False
    """Debug switch
    """

    self.verify_ssl = verify_ssl
    """SSL/TLS verification
       Set this to false to skip verifying SSL certificate when calling API
       from https server.
    """
    self.ssl_ca_cert = ssl_ca_cert
    """Set this to customize the certificate file to verify the peer.
    """
    self.ca_cert_data = ca_cert_data
    """Set this to verify the peer using PEM (str) or DER (bytes)
       certificate data.
    """
    self.cert_file = cert_file
    """client certificate file
    """
    self.key_file = key_file
    """client key file
    """
    self.assert_hostname = assert_hostname
    """Set this to True/False to enable/disable SSL hostname verification.
    """
    self.tls_server_name = tls_server_name
    """SSL/TLS Server Name Indication (SNI)
       Set this to the SNI value expected by the server.
    """

    self.connection_pool_maxsize = (
        connection_pool_maxsize if connection_pool_maxsize is not None else 100
    )
    """This value is passed to the aiohttp to limit simultaneous connections.
       None in the constructor is coerced to default 100.
    """

    self.proxy = proxy
    """Proxy URL
    """
    self.proxy_headers = proxy_headers
    """Proxy headers
    """
    self.safe_chars_for_path_param = safe_chars_for_path_param
    """Safe chars for path_param
    """
    self.retries = retries
    """Retry configuration
    """
    self.trace_configs = trace_configs
    """aiohttp.TraceConfig list forwarded to ClientSession for tracing.
    """
    self.tcp_connector_limit_per_host = tcp_connector_limit_per_host
    """Per-host concurrency cap forwarded to TCPConnector.
    """
    self.client_session_kwargs = client_session_kwargs
    """Extra kwargs merged into aiohttp.ClientSession(**kwargs).

    """
    # Enable client side validation
    self.client_side_validation = client_side_validation

    self.socket_options = socket_options
    """Options to pass down to the underlying urllib3 socket
    """

    self.datetime_format = datetime_format
    """datetime format
    """

    self.date_format = date_format
    """date format
    """

access_token instance-attribute

access_token = access_token

Access token

assert_hostname instance-attribute

assert_hostname = assert_hostname

Set this to True/False to enable/disable SSL hostname verification.

ca_cert_data instance-attribute

ca_cert_data = ca_cert_data

Set this to verify the peer using PEM (str) or DER (bytes) certificate data.

cert_file instance-attribute

cert_file = cert_file

client certificate file

client_session_kwargs instance-attribute

client_session_kwargs = client_session_kwargs

Extra kwargs merged into aiohttp.ClientSession(**kwargs).

connection_pool_maxsize instance-attribute

connection_pool_maxsize = connection_pool_maxsize if connection_pool_maxsize is not None else 100

This value is passed to the aiohttp to limit simultaneous connections. None in the constructor is coerced to default 100.

date_format instance-attribute

date_format = date_format

date format

datetime_format instance-attribute

datetime_format = datetime_format

datetime format

debug property writable

debug: bool

Debug status

Parameters:

Name Type Description Default
value

The debug status, True or False.

required

host property writable

host: str

Return generated host.

ignore_operation_servers instance-attribute

ignore_operation_servers = ignore_operation_servers

Ignore operation servers

key_file instance-attribute

key_file = key_file

client key file

logger instance-attribute

logger = {}

Logging Settings

logger_file property writable

logger_file: Optional[str]

The logger file.

If the logger_file is None, then add stream handler and remove file handler. Otherwise, add file handler and remove stream handler.

Parameters:

Name Type Description Default
value

The logger_file path.

required

logger_file_handler instance-attribute

logger_file_handler: Optional[FileHandler] = None

Log file handler

logger_format property writable

logger_format: str

The logger format.

The logger_formatter will be updated when sets logger_format.

Parameters:

Name Type Description Default
value

The format string.

required

logger_stream_handler instance-attribute

logger_stream_handler = None

Log stream handler

password instance-attribute

password = password

Password for HTTP basic authentication

proxy instance-attribute

proxy = proxy

Proxy URL

proxy_headers instance-attribute

proxy_headers = proxy_headers

Proxy headers

refresh_api_key_hook instance-attribute

refresh_api_key_hook = None

function hook to refresh API key if expired

retries instance-attribute

retries = retries

Retry configuration

safe_chars_for_path_param instance-attribute

safe_chars_for_path_param = safe_chars_for_path_param

Safe chars for path_param

server_operation_index instance-attribute

server_operation_index = server_operation_index or {}

Default server index

server_operation_variables instance-attribute

server_operation_variables = server_operation_variables or {}

Default server variables

socket_options instance-attribute

socket_options = socket_options

Options to pass down to the underlying urllib3 socket

ssl_ca_cert instance-attribute

ssl_ca_cert = ssl_ca_cert

Set this to customize the certificate file to verify the peer.

tcp_connector_limit_per_host instance-attribute

tcp_connector_limit_per_host = tcp_connector_limit_per_host

Per-host concurrency cap forwarded to TCPConnector.

temp_folder_path instance-attribute

temp_folder_path = None

Temp file folder for downloading files

tls_server_name instance-attribute

tls_server_name = tls_server_name

SSL/TLS Server Name Indication (SNI) Set this to the SNI value expected by the server.

trace_configs instance-attribute

trace_configs = trace_configs

aiohttp.TraceConfig list forwarded to ClientSession for tracing.

username instance-attribute

username = username

Username for HTTP basic authentication

verify_ssl instance-attribute

verify_ssl = verify_ssl

SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server.

auth_settings

auth_settings() -> AuthSettings

Gets Auth Settings dict for api client.

Returns:

Type Description
AuthSettings

The Auth Settings information dict.

Source code in immichpy/client/generated/configuration.py
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
def auth_settings(self) -> AuthSettings:
    """Gets Auth Settings dict for api client.

    :return: The Auth Settings information dict.
    """
    auth: AuthSettings = {}
    if self.access_token is not None:
        auth["bearer"] = {
            "type": "bearer",
            "in": "header",
            "format": "JWT",
            "key": "Authorization",
            "value": "Bearer " + self.access_token,
        }
    if "cookie" in self.api_key:
        auth["cookie"] = {
            "type": "api_key",
            "in": "cookie",
            "key": "immich_access_token",
            "value": self.get_api_key_with_prefix(
                "cookie",
            ),
        }
    if "api_key" in self.api_key:
        auth["api_key"] = {
            "type": "api_key",
            "in": "header",
            "key": "x-api-key",
            "value": self.get_api_key_with_prefix(
                "api_key",
            ),
        }
    return auth

get_api_key_with_prefix

get_api_key_with_prefix(identifier: str, alias: Optional[str] = None) -> Optional[str]

Gets API key (with prefix if set).

Parameters:

Name Type Description Default
identifier str

The identifier of apiKey.

required
alias Optional[str]

The alternative identifier of apiKey.

None

Returns:

Type Description
Optional[str]

The token for api key authentication.

Source code in immichpy/client/generated/configuration.py
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
def get_api_key_with_prefix(
    self, identifier: str, alias: Optional[str] = None
) -> Optional[str]:
    """Gets API key (with prefix if set).

    :param identifier: The identifier of apiKey.
    :param alias: The alternative identifier of apiKey.
    :return: The token for api key authentication.
    """
    if self.refresh_api_key_hook is not None:
        self.refresh_api_key_hook(self)
    key = self.api_key.get(
        identifier, self.api_key.get(alias) if alias is not None else None
    )
    if key:
        prefix = self.api_key_prefix.get(
            identifier,
            self.api_key_prefix.get(alias) if alias is not None else None,
        )
        if prefix:
            return "%s %s" % (prefix, key)
        else:
            return key

    return None

get_basic_auth_token

get_basic_auth_token() -> Optional[str]

Gets HTTP basic authentication header (string).

Returns:

Type Description
Optional[str]

The token for basic HTTP authentication.

Source code in immichpy/client/generated/configuration.py
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
def get_basic_auth_token(self) -> Optional[str]:
    """Gets HTTP basic authentication header (string).

    :return: The token for basic HTTP authentication.
    """
    username = ""
    if self.username is not None:
        username = self.username
    password = ""
    if self.password is not None:
        password = self.password

    return "Basic " + base64.b64encode(
        (username + ":" + password).encode("utf-8")
    ).decode("utf-8")

get_default classmethod

get_default() -> Self

Return the default configuration.

This method returns newly created, based on default constructor, object of Configuration class or returns a copy of default configuration.

Returns:

Type Description
Self

The configuration object.

Source code in immichpy/client/generated/configuration.py
427
428
429
430
431
432
433
434
435
436
437
438
439
@classmethod
def get_default(cls) -> Self:
    """Return the default configuration.

    This method returns newly created, based on default constructor,
    object of Configuration class or returns a copy of default
    configuration.

    :return: The configuration object.
    """
    if cls._default is None:
        cls._default = cls()
    return cls._default

get_default_copy classmethod

get_default_copy() -> Self

Deprecated. Please use get_default instead.

Deprecated. Please use get_default instead.

Returns:

Type Description
Self

The configuration object.

Source code in immichpy/client/generated/configuration.py
417
418
419
420
421
422
423
424
425
@classmethod
def get_default_copy(cls) -> Self:
    """Deprecated. Please use `get_default` instead.

    Deprecated. Please use `get_default` instead.

    :return: The configuration object.
    """
    return cls.get_default()

get_host_from_settings

get_host_from_settings(index: Optional[int], variables: Optional[ServerVariablesT] = None, servers: Optional[List[HostSetting]] = None) -> str

Gets host URL based on the index and variables

Parameters:

Name Type Description Default
index Optional[int]

array index of the host settings

required
variables Optional[ServerVariablesT]

hash of variable and the corresponding value

None
servers Optional[List[HostSetting]]

an array of host settings or None

None

Returns:

Type Description
str

URL based on host settings

Source code in immichpy/client/generated/configuration.py
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
def get_host_from_settings(
    self,
    index: Optional[int],
    variables: Optional[ServerVariablesT] = None,
    servers: Optional[List[HostSetting]] = None,
) -> str:
    """Gets host URL based on the index and variables
    :param index: array index of the host settings
    :param variables: hash of variable and the corresponding value
    :param servers: an array of host settings or None
    :return: URL based on host settings
    """
    if index is None:
        return self._base_path

    variables = {} if variables is None else variables
    servers = self.get_host_settings() if servers is None else servers

    try:
        server = servers[index]
    except IndexError:
        raise ValueError(
            "Invalid index {0} when selecting the host settings. "
            "Must be less than {1}".format(index, len(servers))
        )

    url = server["url"]

    # go through variables and replace placeholders
    for variable_name, variable in server.get("variables", {}).items():
        used_value = variables.get(variable_name, variable["default_value"])

        if (
            "enum_values" in variable
            and variable["enum_values"]
            and used_value not in variable["enum_values"]
        ):
            raise ValueError(
                "The variable `{0}` in the host URL has invalid value "
                "{1}. Must be {2}.".format(
                    variable_name, variables[variable_name], variable["enum_values"]
                )
            )

        url = url.replace("{" + variable_name + "}", used_value)

    return url

get_host_settings

get_host_settings() -> List[HostSetting]

Gets an array of host settings

Returns:

Type Description
List[HostSetting]

An array of host settings

Source code in immichpy/client/generated/configuration.py
615
616
617
618
619
620
621
622
623
624
625
def get_host_settings(self) -> List[HostSetting]:
    """Gets an array of host settings

    :return: An array of host settings
    """
    return [
        {
            "url": "https://raw.githubusercontent.com/api",
            "description": "No description provided",
        }
    ]

set_default classmethod

set_default(default: Optional[Self]) -> None

Set default instance of configuration.

It stores default configuration, which can be returned by get_default_copy method.

Parameters:

Name Type Description Default
default Optional[Self]

object of Configuration

required
Source code in immichpy/client/generated/configuration.py
406
407
408
409
410
411
412
413
414
415
@classmethod
def set_default(cls, default: Optional[Self]) -> None:
    """Set default instance of configuration.

    It stores default configuration, which can be
    returned by get_default_copy method.

    :param default: object of Configuration
    """
    cls._default = default

to_debug_report

to_debug_report() -> str

Gets the essential information for debugging.

Returns:

Type Description
str

The report for debugging.

Source code in immichpy/client/generated/configuration.py
602
603
604
605
606
607
608
609
610
611
612
613
def to_debug_report(self) -> str:
    """Gets the essential information for debugging.

    :return: The report for debugging.
    """
    return (
        "Python SDK Debug Report:\n"
        "OS: {env}\n"
        "Python Version: {pyversion}\n"
        "Version of the API: 3.2.2\n"
        "SDK Package Version: 1.0.0".format(env=sys.platform, pyversion=sys.version)
    )