SQL Connection Model

Smarter API SQL Connection Manifest Constants.

Smarter API Manifest - SqlConnection.spec.

class smarter.apps.connection.manifest.models.sql_connection.spec.Connection(*, dbEngine, hostname, port=None, database, username=None, password=None, timeout=30, useSsl=False, sslCert=None, sslKey=None, sslCa=None, proxyHost=None, proxyPort=None, proxyUsername=None, proxyPassword=None, sshKnownHosts=None, poolSize=5, maxOverflow=10, authenticationMethod='none')[source]

Bases: SmarterBasePydanticModel

Smarter API - generic SQL Connection class.

authenticationMethod: str
database: str
dbEngine: str
hostname: str
maxOverflow: int
model_config = {'arbitrary_types_allowed': True, 'from_attributes': True, 'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Return type:

None

password: str | None
poolSize: int
port: int | None
proxyHost: str | None
proxyPassword: str | None
proxyPort: int | None
proxyUsername: str | None
sshKnownHosts: str | None
sslCa: str | None
sslCert: str | None
sslKey: str | None
timeout: int
useSsl: bool
username: str | None
classmethod validate_authentication_method(v)[source]

Validate that authenticationMethod is one of the supported authentication methods.

Parameters:

v – The authentication method.

Return type:

str

Returns:

The authentication method, unchanged.

Raises:

SAMValidationError – if it is not in DBMSAuthenticationMethods.all().

classmethod validate_database(v)[source]

Validate that database is a clean string.

Parameters:

v – The database name.

Return type:

str

Returns:

The database name, unchanged.

Raises:

SAMValidationError – if it is not a clean string.

classmethod validate_db_engine(v)[source]

Validate that dbEngine is one of the supported Django database backends.

Parameters:

v – The database engine.

Return type:

str

Returns:

The database engine, unchanged.

Raises:

SAMValidationError – if it is not in DbEngines.all().

classmethod validate_host(v)[source]

Validate that hostname is a clean string.

Parameters:

v – The database host.

Return type:

str

Returns:

The host, unchanged.

Raises:

SAMValidationError – if it is not a clean string.

classmethod validate_max_overflow(v)[source]

Validate that maxOverflow, when set, is 0 or greater.

Parameters:

v – The maximum pool overflow, or None.

Return type:

int | None

Returns:

The maximum overflow, unchanged.

Raises:

SAMValidationError – if it is negative.

classmethod validate_password(v)[source]

Accept password as is: it is the name of a Secret, not the password itself.

Parameters:

v – The name of the Secret that holds the password.

Return type:

str

Returns:

The value, unchanged.

classmethod validate_pool_size(v)[source]

Validate that poolSize, when set, is greater than 0.

Parameters:

v – The connection pool size, or None.

Return type:

int | None

Returns:

The pool size, unchanged.

Raises:

SAMValidationError – if it is not greater than 0.

classmethod validate_port(v, values)[source]

Default port from the database engine when it is missing, and validate its range.

Parameters:
  • v – The port, or None.

  • values – The values of the model’s other fields, used to look up dbEngine.

Return type:

int | None

Returns:

The port, or the default port of the database engine when the port is None and the engine has one.

Raises:

SAMValidationError – if the port is not between 1 and 65535.

classmethod validate_proxy_host(v)[source]

Validate that proxyHost, when set, is a valid domain.

Parameters:

v – The proxy host, or None.

Return type:

str | None

Returns:

The proxy host, unchanged.

Raises:

SAMValidationError – if it is not a valid domain.

classmethod validate_proxy_port(v)[source]

Validate that proxyPort, when set, is between 1 and 65535.

Parameters:

v – The proxy port, or None.

Return type:

int | None

Returns:

The proxy port, unchanged.

Raises:

SAMValidationError – if it is out of range.

classmethod validate_ssh_known_hosts(v)[source]

Accept sshKnownHosts as is.

Parameters:

v – The SSH known hosts, or None.

Return type:

str | None

Returns:

The value, unchanged.

classmethod validate_ssl_fields(v)[source]

Accept sslCert, sslKey and sslCa as is.

Parameters:

v – The SSL certificate, key or CA, or None.

Return type:

str | None

Returns:

The value, unchanged.

classmethod validate_timeout(v)[source]

Default timeout when it is missing or 0, and validate that it is positive.

Parameters:

v – The timeout in seconds, or None.

Return type:

int

Returns:

The timeout, or SqlConnection.DBMS_DEFAULT_TIMEOUT when it is falsy.

Raises:

SAMValidationError – if the timeout is not greater than 0.

classmethod validate_use_ssl(v)[source]

Validate that useSsl is a boolean.

Parameters:

v – Whether to use SSL.

Return type:

bool

Returns:

The value, unchanged.

Raises:

SAMValidationError – if it is not a boolean.

classmethod validate_username(v)[source]

Validate that username, when set, is a clean string.

Parameters:

v – The username, or None.

Return type:

str | None

Returns:

The username, unchanged.

Raises:

SAMValidationError – if it is not a clean string.

class smarter.apps.connection.manifest.models.sql_connection.spec.SAMSqlConnectionSpec(*, connection)[source]

Bases: AbstractSAMSpecBase

Smarter API Sql Connection Manifest Connection.spec.

class_identifier: ClassVar[str] = 'SqlConnection.spec'
connection: Connection
model_config = {'arbitrary_types_allowed': True, 'from_attributes': True, 'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Return type:

None

Smarter API SqlConnection Manifest.

class smarter.apps.connection.manifest.models.sql_connection.model.SAMSqlConnection(*, apiVersion, kind, metadata, spec, status=None)[source]

Bases: SAMConnectionCommon

Smarter API Manifest - SqlConnection Model.

class_identifier: ClassVar[str] = 'SqlConnection'
metadata: SAMConnectionCommonMetadata
model_config = {'arbitrary_types_allowed': True, 'from_attributes': True, 'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Return type:

None

spec: SAMSqlConnectionSpec
status: SAMConnectionCommonStatus | None