Skip to main content

Python SDK Configuration

The Python SDK (Async or Sync) client can be configured using an instance of the Config class.

from infrahub_sdk import Config, InfrahubClient
config = Config(address="http://infrahub:8080", api_token="123-xyz-invalid-token")
client = InfrahubClient(config=config)

The following settings can be defined in the Config class

address

Description: The URL to use when connecting to Infrahub.
Type: string
Default value: http://localhost:8000
Environment variable: INFRAHUB_ADDRESS

api_token

Description: API token for authentication against Infrahub.
Type: string
Environment variable: INFRAHUB_API_TOKEN

echo_graphql_queries

Description: If set the GraphQL query and variables will be echoed to the screen
Type: boolean
Default value: False
Environment variable: INFRAHUB_ECHO_GRAPHQL_QUERIES

username

Description: Username for accessing Infrahub
Type: string
Environment variable: INFRAHUB_USERNAME

password

Description: Password for accessing Infrahub
Type: string
Environment variable: INFRAHUB_PASSWORD

default_branch

Description: Default branch to target if not specified for each request.
Type: string
Default value: main
Environment variable: INFRAHUB_DEFAULT_BRANCH

default_branch_from_git

Description: Indicates if the default Infrahub branch to target should come from the active branch in the local Git repository.
Type: boolean
Default value: False
Environment variable: INFRAHUB_DEFAULT_BRANCH_FROM_GIT

identifier

Description: Tracker identifier
Type: string
Environment variable: INFRAHUB_IDENTIFIER

insert_tracker

Description: Insert a tracker on queries to the server
Type: boolean
Default value: False
Environment variable: INFRAHUB_INSERT_TRACKER

max_concurrent_execution

Description: Max concurrent execution in batch mode
Type: integer
Default value: 5
Environment variable: INFRAHUB_MAX_CONCURRENT_EXECUTION

mode

Description: Default mode for the client
Type: object
Environment variable: INFRAHUB_MODE

pagination_size

Description: Page size for queries to the server
Type: integer
Default value: 50
Environment variable: INFRAHUB_PAGINATION_SIZE

retry_delay

Description: Number of seconds to wait until attempting a retry.
Type: integer
Default value: 5
Environment variable: INFRAHUB_RETRY_DELAY

retry_on_failure

Description: Retry operation in case of failure
Type: boolean
Default value: False
Environment variable: INFRAHUB_RETRY_ON_FAILURE

max_retry_duration

Description: Maximum duration until we stop attempting to retry if enabled.
Type: integer
Default value: 300
Environment variable: INFRAHUB_MAX_RETRY_DURATION

schema_converge_timeout

Description: Number of seconds to wait for schema to have converged
Type: integer
Default value: 60
Environment variable: INFRAHUB_SCHEMA_CONVERGE_TIMEOUT

store_merge

Description: When True, re-querying a node already in the client store updates only the fields that were fetched and preserves previously fetched attributes and relationships. When False, the latest query fully replaces the stored node, which can drop data fetched by earlier queries (the pre-1.23.0 behaviour).
Type: boolean
Default value: True
Environment variable: INFRAHUB_STORE_MERGE

timeout

Description: Default connection timeout in seconds
Type: integer
Default value: 60
Environment variable: INFRAHUB_TIMEOUT

transport

Description: Set an alternate transport using a predefined option
Type: object
Environment variable: INFRAHUB_TRANSPORT

proxy

Description: Proxy address
Type: string
Environment variable: INFRAHUB_PROXY

proxy_mounts

Description: Proxy mounts configuration
Type: object
Environment variable: INFRAHUB_PROXY_MOUNTS

marketplace_url

Description: Base URL for the Infrahub Marketplace.
Type: string
Default value: https://marketplace.infrahub.app
Environment variable: INFRAHUB_MARKETPLACE_URL

update_group_context

Description: Update GraphQL query groups
Type: boolean
Default value: False
Environment variable: INFRAHUB_UPDATE_GROUP_CONTEXT

tls_insecure

Description:
Indicates if TLS certificates are verified. Enabling this option will disable: CA verification, expiry date verification, hostname verification). Can be useful to test with self-signed certificates.
Type: boolean
Default value: False
Environment variable: INFRAHUB_TLS_INSECURE

tls_ca_file

Description: File path to CA cert or bundle in PEM format
Type: string
Environment variable: INFRAHUB_TLS_CA_FILE

recorder

Property: recorder

Description: Select builtin recorder for later replay.
Type: RecorderType
Default value: RecorderType.NONE

custom_recorder

Property: custom_recorder

Description: Provides a way to record responses from the Infrahub API
Type: Recorder (protocol)
Default value: NoRecorder.default

requester

Property: requester

Type: AsyncRequester
Default value: None

sync_requester

Property: sync_requester

Type: SyncRequester
Default value: None