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

Property: address

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

api_token

Property: api_token

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

echo_graphql_queries

Property: 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

Property: username

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

password

Property: password

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

default_branch

Property: 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

Property: 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

Property: identifier

Description: Tracker identifier
Type: string
Environment variable: INFRAHUB_IDENTIFIER

insert_tracker

Property: insert_tracker

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

max_concurrent_execution

Property: max_concurrent_execution

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

mode

Property: mode

Description: Default mode for the client
Type: string
Default value: default
Choices: default, tracking
Environment variable: INFRAHUB_MODE

pagination_size

Property: pagination_size

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

retry_delay

Property: 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

Property: retry_on_failure

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

timeout

Property: timeout

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

transport

Property: transport

Description: Set an alternate transport using a predefined option
Type: string
Default value: httpx
Choices: httpx, json
Environment variable: INFRAHUB_TRANSPORT

proxy

Property: proxy

Description: Proxy address
Type: string
Environment variable: INFRAHUB_PROXY

proxy_mounts

Property: proxy_mounts

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

update_group_context

Property: update_group_context

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

tls_insecure

Property: 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

Property: 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