px_core.core

Core SDK types — context, logging, versioning.

Module Contents

Classes

SdkTaskExecution

Opaque SDK handle — no Python attributes; pass through only.

SslContext

Opaque SDK handle — no Python attributes; pass through only.

ProximieContext

Provides key settings, services and functionality for components and classes throughout the Proximie SDK.

PxLogger

The SDK logger, which allows an application-provided delegate to handle logging output from the SDK.

PxSdkVersion

The version of the Proximie SDK, following the [Semantic Versioning](https://semver.org/) convention.

RemoteEnvironment

Details for connecting to a remote Proximie services environment

class px_core.core.SdkTaskExecution

Opaque SDK handle — no Python attributes; pass through only.

class px_core.core.SslContext

Opaque SDK handle — no Python attributes; pass through only.

class px_core.core.ProximieContext

Provides key settings, services and functionality for components and classes throughout the Proximie SDK.

An application will typically create a ProximieContext at initialisation time, and provide it to other SDK objects as and when they are created.

Creation

ProximieContext objects are created using the static create methods, which return shared pointers that are passed to other SDK objects.

static create_no_ssl() ProximieContext

Create a Proximie content with no SSL support

static create() ProximieContext

Create a ProximieContext with a default SSL context

static create(sslContext: SslContext) ProximieContext

Create a ProximieContext with a provided SSL context

static create(sslCertPath: str) ProximieContext

Convenience creation of a ProximieContext with a path to the SSL certificates, which is used to create an SSL context using makeSslContext

SSL context managed by the ProximieContext

property has_ssl_context: bool
ssl_context() SslContext

Obtain the SSL context managed by the ProximieContext It is an error to obtain the SSL context if none was supplied when the ProximieContext was created.

Callers may check using ProximieContext.hasSslContext.

User agent string

The ProximieContext defines the default user agent string used when the SDK makes HTTP calls. If not set by the application, a default SDK user agent string is used.

user_agent() str

Obtain the current user agent string

set_user_agent(prefix: str) None

Set the current user agent string

UUID generation

uuid() str

Generate a UUID value

uuid_str() str

Generate a UUID as a string value

class px_core.core.PxLogger

The SDK logger, which allows an application-provided delegate to handle logging output from the SDK.

class LogSeverity

Bases: enum.IntEnum

Severity levels ranging from least severe to most.

TRACE: int = 0
DEBUG: int = 1
INFO: int = 2
WARNING: int = 3
ERROR: int = 4
FATAL: int = 5
class LogMeta

Contains additional logging metadata that the logging delegate may use

property timestamp: str | int
class ILoggerDelegate

The interface required by a logging delegate

handle_log(level: PxLogger.LogSeverity, message: str, data: PxLogger.LogMeta) None

The implementation of this function should handle the logging output for the application. The log level is provided to allow the delegate to customise its output and/or targets.

Logger access and delegation

static get() PxLogger

Provide access to the PxLogger instance

set_delegate(delegate: PxLogger.ILoggerDelegate) None

Sets the delegate logging handler for SDK logging

set_delegate(delegate: PxLogger.ILoggerDelegate, severityLevel: PxLogger.LogSeverity) None

Sets the delegate logging handler, with severity level, for SDK logging

use_std_output_delegate() None

Sets the logging delegate to use standard outputs

use_std_output_delegate(withSeverity: PxLogger.LogSeverity) None

Sets the logging delegate, with severity level, to use standard outputs

severity_level(level: PxLogger.LogSeverity) None

Set the current logger severity level

static severity_label(sev: PxLogger.LogSeverity) str

Return a human-readable string for a given severity level

static escape_format(message: str) str

Format a given message with escapes

static timestamp() str

Returns a timestamp string for the current time

static timestamp(when: str | int) str

Returns a timestamp string for a given timestamp

Logging functions

test_severity(level: PxLogger.LogSeverity) bool

The logger can be asked whether a given severity is of interest.

Callers can call this function to check before going ahead with building the message to be logged out (e.g. if this is a non-trivial operation).

log(level: PxLogger.LogSeverity, message: str) None

Log the message string if the severity is high enough

log(level: PxLogger.LogSeverity, lazy: Callable[[], str]) None

Lazy-evaluation logging, where the severity is checked before obtaining the message string value

The lazy evaluation function is only called if the given severity is high enough

Parameters:
  • level (PxLogger.LogSeverity) – Log level for the message

  • lazy (Callable[[], str]) – A functor to return the message content

class px_core.core.PxSdkVersion

The version of the Proximie SDK, following the [Semantic Versioning](https://semver.org/) convention.

class SemVer

A semantic versioning version with MAJOR.MINOR.PATCH version elements.

property major: int
property minor: int
property patch: int
static semver() PxSdkVersion.SemVer

Obtain the current SDK version as a SemVer value

static version() str

Obtain the current SDK version as a string

class px_core.core.RemoteEnvironment

Details for connecting to a remote Proximie services environment

Helpers

static from_domain(domain: str) RemoteEnvironment

Helper to create an environment for a given domain

Typically a domain (e.g. “proximie.net”) is used to create the various host URLs for a remote environment. This helper takes a domain string and prepends the default prefixes to create a RemoteEnvironment object.

static replace_url_pattern(pattern: str, value: str) str

Helper to replace a single {} in a given pattern string.

Parameters:
  • pattern (str) – Source pattern, with a {} to be replaced.

  • value (str) – The value to replace the {} token with.

Returns:

A string where the pattern’s {} was replaced with the value.

property session_host: str
property global_api: str
property regional_api: str