sym.sdk.resource

Tools for describing Sym Resources.

Classes

SRN

Sym Resource Name (SRN) is a unique identifier for a Sym Resource.

SymBaseResource

The base class that all Sym SDK models inherit from.

SymResource

A piece of infrastructure provisioned with Sym's Terraform provider.

Exceptions

InvalidSRNError

Raised when an invalid SRN is supplied.

InvalidSlugError

Raised when a component of a SRN is an invalid slug.

InvalidVersionError

Raised when a SRN has an invalid version.

MissingComponentError

Raised when a component of a SRN is missing.

MultipleErrors

Raised when a SRN has multiple validation errors.

TrailingSeparatorError

Raised when a SRN contains a trailing separator.

exception sym.sdk.resource.InvalidSRNError(srn: str, hint: Optional[str] = None)

Bases: sym.sdk.errors.SymSDKError

Raised when an invalid SRN is supplied.

format_slack() str

Returns a string representation of this error formatted for display in Slack-compatible markdown.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception sym.sdk.resource.InvalidSlugError(srn: str, component: str, value: str)

Bases: sym.sdk.resource.InvalidSRNError

Raised when a component of a SRN is an invalid slug.

format_slack() str

Returns a string representation of this error formatted for display in Slack-compatible markdown.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception sym.sdk.resource.InvalidVersionError(srn: str, component: str, value: str)

Bases: sym.sdk.resource.InvalidSRNError

Raised when a SRN has an invalid version.

format_slack() str

Returns a string representation of this error formatted for display in Slack-compatible markdown.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception sym.sdk.resource.MissingComponentError(srn: str, component: str)

Bases: sym.sdk.resource.InvalidSRNError

Raised when a component of a SRN is missing.

format_slack() str

Returns a string representation of this error formatted for display in Slack-compatible markdown.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception sym.sdk.resource.MultipleErrors(srn: str)

Bases: sym.sdk.resource.InvalidSRNError

Raised when a SRN has multiple validation errors.

format_slack() str

Returns a string representation of this error formatted for display in Slack-compatible markdown.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class sym.sdk.resource.SRN(org: str, model: str, type: Optional[str], slug: str, version: str, identifier: Optional[str] = None)

Bases: object

Sym Resource Name (SRN) is a unique identifier for a Sym Resource.

SRNs have the following structure:

<ORG>:<MODEL>[:<TYPE>]:<SLUG>:<VERSION>[:<IDENTIFIER>]

Where VERSION is either a semver string, or “latest”. And TYPE indicates the type of the model; this is often the type field of the resource defined in Terraform. For example, the type slack for an integration resource.

For example, the SRN for the v1.0.0 sym:approval template is:

sym:template:approval:1.0.0

Or the SRN for a Flow instance (with a UUID as an instance identifier) could be:

sym:flow:test-flow:0.1.0:d47782bc-88be-44df-9e34-5fae0dbdea22

Or the SRN for a Slack integration with a slug “my-integration” is:

sym:integration:slack:my-integration:latest:d47782bc-88be-44df-9e34-5fae0dbdea22
SEPARATOR = ':'

The default separator for SRN components.

SLUG_PATTERN = re.compile('^[a-zA-Z0-9-_]+$')

The pattern for validating slug components.

VERSION_PATTERN = re.compile('^(latest|[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})$')

The pattern for validating the version component.

copy(organization: Optional[str] = None, model: Optional[str] = None, type: Optional[str] = None, slug: Optional[str] = None, version: Optional[str] = None, identifier: Optional[str] = None)

Creates a copy of this SRN.

Optionally can create a new SRN with modified components from the current, as specified by the keyword arguments.

property identifier

An arbitrary string identifying an instance of the resource.

This is often a UUID.

property model

The model name for this SRN.

For example, for the sym:approval Template, the model name is template.

property organization

The slug for the organization this SRN belongs to.

For example, for the sym:approval Template, the organization slug is sym.

classmethod parse(raw: str) sym.sdk.resource.SRN

Parses and validates the given string as an SRN.

Parameters

raw – A raw string representing a SRN.

Returns

A SRN instance.

Raises
classmethod requires_type(model: str) bool

Returns True if the given model has a type component.

property slug

This SRN’s slug.

For example, for the sym:approval Template, the slug is approval.

property type

The model type for this SRN.

For example, for a Slack integration SRN sym:integration:slack:my-integration:latest, the type is slack.

If no type is specified, then this property will return None.

property version

A semver string representing the version of this SRN.

For example, the first version of the sym:approval Template is 1.0.0.

class sym.sdk.resource.SymBaseResource

Bases: object

The base class that all Sym SDK models inherit from.

dict()

Represent this resource as a dictionary.

class sym.sdk.resource.SymResource(srn: Union[sym.sdk.resource.SRN, str])

Bases: sym.sdk.resource.SymBaseResource

A piece of infrastructure provisioned with Sym’s Terraform provider.

For example, a Flow is a Resource.

dict()

Represent this resource as a dictionary.

property name

An alias for this resource’s slug, derived from its SRN.

property srn

A SRN object that represents the unique identifier for this resource.

exception sym.sdk.resource.TrailingSeparatorError(srn: str)

Bases: sym.sdk.resource.InvalidSRNError

Raised when a SRN contains a trailing separator.

format_slack() str

Returns a string representation of this error formatted for display in Slack-compatible markdown.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.