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, Any]] = None, ca_cert_data: Optional[Union[str, bytes]] = None, cert_file: Optional[str] = None, key_file: Optional[str] = None, *, 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 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 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.

: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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
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
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, Any]] = None,
    ca_cert_data: Optional[Union[str, bytes]] = None,
    cert_file: Optional[str] = None,
    key_file: Optional[str] = None,
    *,
    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 = True
    """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 = None
    """Set this to True/False to enable/disable SSL hostname verification.
    """
    self.tls_server_name = None
    """SSL/TLS Server Name Indication (SNI)
       Set this to the SNI value expected by the server.
    """

    self.connection_pool_maxsize = 100
    """This value is passed to the aiohttp to limit simultaneous connections.
       Default values is 100, None means no-limit.
    """

    self.proxy: Optional[str] = None
    """Proxy URL
    """
    self.proxy_headers = None
    """Proxy headers
    """
    self.safe_chars_for_path_param = ""
    """Safe chars for path_param
    """
    self.retries = retries
    """Retry configuration
    """
    # Enable client side validation
    self.client_side_validation = True

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

    self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
    """datetime format
    """

    self.date_format = "%Y-%m-%d"
    """date format
    """

access_token instance-attribute

access_token = access_token

Access token

assert_hostname instance-attribute

assert_hostname = None

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

connection_pool_maxsize instance-attribute

connection_pool_maxsize = 100

This value is passed to the aiohttp to limit simultaneous connections. Default values is 100, None means no-limit.

date_format instance-attribute

date_format = '%Y-%m-%d'

date format

datetime_format instance-attribute

datetime_format = '%Y-%m-%dT%H:%M:%S.%f%z'

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: Optional[str] = None

Proxy URL

proxy_headers instance-attribute

proxy_headers = None

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

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 = None

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.

temp_folder_path instance-attribute

temp_folder_path = None

Temp file folder for downloading files

tls_server_name instance-attribute

tls_server_name = None

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

username instance-attribute

username = username

Username for HTTP basic authentication

verify_ssl instance-attribute

verify_ssl = True

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
518
519
520
521
522
523
524
525
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 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
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
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)
        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
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
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
380
381
382
383
384
385
386
387
388
389
390
391
392
@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
370
371
372
373
374
375
376
377
378
@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
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
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
565
566
567
568
569
570
571
572
573
574
575
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
359
360
361
362
363
364
365
366
367
368
@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
552
553
554
555
556
557
558
559
560
561
562
563
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: 2.7.5\n"
        "SDK Package Version: 1.0.0".format(env=sys.platform, pyversion=sys.version)
    )