benchling_sdk.apps.config.dependencies module¶

class ApiConfigItem¶

Bases: benchling_sdk.apps.config.dependencies.BaseConfigItem

API Config Item.

A reference to a config item for a Benchling object referencable by the API.

__init__(parent: Union[BaseDependencies, BaseConfigNode], config_item: Optional[Union[EntitySchemaAppConfigItem, FieldAppConfigItem, GenericApiIdentifiedAppConfigItem]]) → None¶
config_item: Optional[Union[EntitySchemaAppConfigItem, FieldAppConfigItem, GenericApiIdentifiedAppConfigItem]]¶
class ArrayConfigItem¶

Bases: benchling_sdk.apps.config.dependencies.BaseConfigItem

Array Config Item.

An array config item representing a row.

__init__(parent: Union[BaseDependencies, BaseConfigNode], config_item: Optional[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]) → None¶
config_item: Optional[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶
full_path() → List[str]¶

Return the full path of the current array row, inheriting from all parents.

property name: str¶

Return the user defined name of the array row.

class BaseConfigItem¶

Bases: benchling_sdk.apps.config.dependencies.BaseConfigNode

Base Config Item.

A reference to any config item.

__init__(parent: Union[BaseDependencies, BaseConfigNode], config_item: Optional[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]) → None¶
config_item: Optional[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶
class BaseConfigNode¶

Bases: object

Base Config Node.

A node in a graph of related config items, referencing its parent.

All nodes should have a parent, which may be BaseDependencies, but not all nodes represent an AppConfigItem in Benchling.

__init__(parent: Union[BaseDependencies, BaseConfigNode]) → None¶
context() → BaseDependencies¶

Return the dependency class at the root of the dependency graph.

full_path() → List[str]¶

Return the full path of the current node, inheriting from all parents.

parent: Union[BaseDependencies, BaseConfigNode]¶
class BaseDependencies¶

Bases: object

A base class for implementing dependencies.

Used as a facade for the underlying link store, which holds dependency links configured in Benchling.

__init__(store: DependencyLinkStore, scalar_definitions: Dict[Union[BooleanAppConfigItemType, DateAppConfigItemType, DatetimeAppConfigItemType, FloatAppConfigItemType, IntegerAppConfigItemType, JsonAppConfigItemType, SecureTextAppConfigItemType, TextAppConfigItemType], ScalarDefinition] = DEFAULT_SCALAR_DEFINITIONS, unknown_scalar_definition: Optional[ScalarDefinition] = None, decryption_provider: Optional[BaseDecryptionProvider] = None)¶

Initialize Base Dependencies.

Parameters
  • store – The dependency link store to source dependency links from.

  • scalar_definitions – A map of scalar types from the API definitions to ScalarDefinitions which

determines how we want map them to concrete Python types and values. Can be overridden to customize deserialization behavior or formatting. :param unknown_scalar_definition: A scalar definition for handling unknown scalar types from the API. Can be used to control behavior for forwards compatibility with new types the SDK does not yet support (e.g., by treating them as strings). :param decryption_provider: A decryption provider that can decrypt secrets from app config. If dependencies attempt to use a secure_text’s decrypted value, a decryption_provider must be specified.

classmethod from_app(client: Benchling, app_id: str, decryption_provider: Optional[BaseDecryptionProvider] = None) → benchling_sdk.apps.config.dependencies.D¶

Initialize dependencies from an app_id.

classmethod from_store(store: DependencyLinkStore, decryption_provider: Optional[BaseDecryptionProvider] = None) → benchling_sdk.apps.config.dependencies.D¶

Initialize dependencies from a store.

invalidate_cache() → None¶

Invalidate the cache of dependency links and force an update.

class BaseField¶

Bases: abc.ABC, benchling_api_client.v2.stable.models.field.Field, Generic[benchling_sdk.apps.config.scalars.ScalarType]

Base Field.

Provides additional accessors on top of the OpenAPI Field model.

additional_properties: Dict[str, Any]¶
classmethod from_field(field: Optional[Field]) → benchling_sdk.apps.config.dependencies.F¶

From Field.

Create a new instance from an existing field.

property scalar_definition: ScalarDefinition[benchling_sdk.apps.config.scalars.ScalarType]¶

Scalar Definition.

Returns a scalar definition for parsing a concrete type from a field. Override to implement custom deserialization.

class BenchlingConfigProvider¶

Bases: benchling_sdk.apps.config.dependencies.ConfigProvider

Benchling Config provider.

Provides a BenchlingAppConfiguration retrieved from Benchling’s API.

__init__(client: Benchling, app_id: str)¶

Initialize Benchling Config Provider.

Parameters
  • client – A configured Benchling instance for making API calls.

  • app_id – The app_id from which to retrieve configuration.

config() → List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶

Provide a Benchling app configuration from Benchling’s APIs.

class ConfigProvider¶

Bases: Protocol

Config provider.

Provides a BenchlingAppConfiguration.

__init__(*args, **kwargs)¶
config() → List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶

Implement to provide a Benchling app configuration.

class DependencyLinkStore¶

Bases: object

Dependency Link Store.

Marshalls an app configuration from the configuration provider into an indexable structure. Only retrieves app configuration once unless its cache is invalidated.

__init__(configuration_provider: ConfigProvider)¶

Initialize Dependency Link Store.

Parameters

configuration_provider – A ConfigProvider that will be invoked to provide the

underlying config from which to organize dependency links.

config_by_path(path: List[str]) → Optional[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶

Config by path.

Find an app config item by its exact path match, if it exists. Does not search partial paths.

config_keys_by_path(path: List[str]) → ordered_set.OrderedSet[str]¶

Config keys by path.

Find a set of app config keys at the specified path, if any. Does not return keys that are nested beyond the current level.

For instance, given paths: [“One”, “Two”] [“One”, “Two”, “Three”] [“One”, “Two”, “Four”] [“One”, “Two”, “Three”, “Five”] [“Zero”, “One”, “Two”, “Three”]

The expected return from this method when path=[“One”, “Two”] is a set {“Three”, “Four”}.

property configuration: List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶

Get the underlying configuration.

Return the raw, stored configuration. Can be used if the provided accessors are inadequate to find particular configuration items.

property configuration_path_map: Dict[Tuple[str, ...], Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶

Config links.

Return a map of configuration item paths to their corresponding configuration items.

classmethod from_app(client: Benchling, app_id: str) → DependencyLinkStore¶

From App.

Instantiate a DependencyLinkStore from an app_id and a configured Benchling instance. Preferred to using the class’s constructor.

invalidate_cache() → None¶

Invalidate Cache.

Will force retrieval of configuration from the ConfigProvider the next time the link store is accessed.

class HasApiIdentifiedAppConfigItem¶

Bases: Protocol

Has Api Identified App Config Item.

A mixin for typing to assert that a class has an optional app config item attribute. That app config item must have a linked_resource property.

__init__(*args, **kwargs)¶
property config_item: Optional[Union[EntitySchemaAppConfigItem, FieldAppConfigItem, GenericApiIdentifiedAppConfigItem]]¶

Return the underlying app config item, if present. App config item must have linked_resource.

property path: List[str]¶

Return the path requested by the manifest.

class HasAppConfigItem¶

Bases: Protocol

Has App Config Item.

A mixin for typing to assert that a class has an optional app config item attribute.

__init__(*args, **kwargs)¶
property config_item: Optional[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶

Return the underlying app config item, if present.

property path: List[str]¶

Return the path requested by the manifest.

class HasConfigWithDecryptionProvider¶

Bases: Protocol

Has Config With Decryption Provider.

A mixin for typing to assert that a particular class has a decryption provider and config.

__init__(*args, **kwargs)¶
property config_item: Optional[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶

Return the underlying app config item, if present.

property decryption_provider: Optional[BaseDecryptionProvider]¶

Return the decryption provider.

property path: List[str]¶

Return the path requested by the manifest.

class HasScalarDefinition¶

Bases: Protocol

Has Scalar Definition.

A mixin for typing to assert that a particular class has scalar attributes.

__init__(*args, **kwargs)¶
property config_item: Optional[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶

Return the underlying app config item, if present.

property definition: Optional[ScalarDefinition]¶

Return the scalar definition, allowing for conversion to Python types.

property path: List[str]¶

Return the path requested by the manifest.

exception InaccessibleAppConfigResourceError¶

Bases: Exception

Inaccessible app config resource error.

A resource was linked in app config, but the permissions do not allow access to it. Most likely happens when an app lacks the necessary permissions.

exception MissingDependencyError¶

Bases: Exception

Missing dependency error.

Indicates a dependency was missing from app config. For instance, no dependency with that name was in the list.

exception MissingScalarDefinitionError¶

Bases: Exception

Missing scalar definition error.

The manifest and configuration specified a scalar type which the SDK does not know how to translate to Python values yet.

class OptionalField¶

Bases: benchling_sdk.apps.config.dependencies.BaseField, Generic[benchling_sdk.apps.config.scalars.ScalarType]

Optional Field.

A decorator class providing typed accessors for an underlying Field. Use with optional, single valued fields.

additional_properties: Dict[str, Any]¶
property typed: _OptionalFieldTyped¶

Typed.

Return a reference to a typed field with typesafe accessors.

class OptionalLinkedResourceDependencyMixin¶

Bases: object

Optional Linked Resource Dependency Mixin.

A mixin for easily accessing attributes from linked_resource for an app config item which is optional and may not be present. Should only be mixed in with HasApiIdentifiedAppConfigItem

property id: Optional[str]¶

Return the API ID of the linked configuration, if present.

property name: Optional[str]¶

Return the name of the linked configuration, if present.

Raises InaccessibleAppConfigResourceError if the app does not have permission to the linked resource.

class OptionalMultiValueField¶

Bases: benchling_sdk.apps.config.dependencies.BaseField, Generic[benchling_sdk.apps.config.scalars.ScalarType]

Optional Multi Value Field.

A decorator class providing typed accessors for an underlying Field. Use with optional, multi-valued fields.

additional_properties: Dict[str, Any]¶
property typed: _OptionalMultiValueFieldType¶

Typed.

Return a reference to a typed field with typesafe accessors.

class OptionalScalarDependencyMixin¶

Bases: Generic[benchling_sdk.apps.config.scalars.ScalarType]

Optional Scalar Config.

A mixin for accessing a scalar config which is optional and may not be present. Should only be mixed in with HasScalarDefinition.

property value: Optional[benchling_sdk.apps.config.scalars.ScalarType]¶

Return the value of the scalar, if present.

property value_str: Optional[str]¶

Return the value of the scalar as a string, if present.

class OptionalSecureTextDependencyMixin¶

Bases: benchling_sdk.apps.config.dependencies.OptionalScalarDependencyMixin[str]

Optional Secure Text.

A mixin for accessing a secure text config which is optional and may not be present. Should only be mixed in with SecureTextConfig.

decrypted_value() → Optional[str]¶

Decrypted value.

Decrypts a secure_text dependency’s encrypted value into plain text, if present.

class OptionalSingleOrMultiValueField¶

Bases: benchling_sdk.apps.config.dependencies.BaseField, Generic[benchling_sdk.apps.config.scalars.ScalarType]

Optional Single Or Multi Value Field.

A decorator class providing typed accessors for an underlying Field. Use with optional fields where isMulti is unset.

additional_properties: Dict[str, Any]¶
property typed: _OptionalSingleOrMultiValueFieldTyped¶

Typed.

Return a reference to a typed field with typesafe accessors.

class OptionalValueMixin¶

Bases: object

Optional Value Mixin.

A mixin for accessing a value which is optional and may not be present. Should only be mixed in with HasAppConfigItem or another class that provides the self.config_item attribute.

property value: Optional[str]¶

Return the value of the app config item, if present.

class RequiredField¶

Bases: benchling_sdk.apps.config.dependencies.BaseField, Generic[benchling_sdk.apps.config.scalars.ScalarType]

Required Field.

A decorator class providing typed accessors for an underlying Field. Use with required, single valued fields.

additional_properties: Dict[str, Any]¶
property typed: _RequiredFieldTyped¶

Typed.

Return a reference to a typed field with typesafe accessors.

class RequiredLinkedResourceDependencyMixin¶

Bases: object

Required Linked Resource Dependency Mixin.

A mixin for easily accessing attributes from linked_resource for an app config item which is required and should always be present. Should only be mixed in with HasApiIdentifiedAppConfigItem

property id: str¶

Return the API ID of the linked configuration.

property name: str¶

Return the name of the linked configuration.

Raises InaccessibleAppConfigResourceError if the app does not have permission to the linked resource.

class RequiredMultiValueField¶

Bases: benchling_sdk.apps.config.dependencies.BaseField, Generic[benchling_sdk.apps.config.scalars.ScalarType]

Required Multi Value Field.

A decorator class providing typed accessors for an underlying Field. Use with required, multi-valued fields.

additional_properties: Dict[str, Any]¶
property typed: _RequiredMultiValueFieldType¶

Typed.

Return a reference to a typed field with typesafe accessors.

class RequiredScalarDependencyMixin¶

Bases: Generic[benchling_sdk.apps.config.scalars.ScalarType]

Require Scalar Config.

A mixin for accessing a scalar config which is required and should always be present. Should only be mixed in with HasScalarDefinition.

property value: benchling_sdk.apps.config.scalars.ScalarType¶

Return the value of the scalar.

property value_str: str¶

Return the value of the scalar as a string.

class RequiredSecureTextDependencyMixin¶

Bases: benchling_sdk.apps.config.dependencies.RequiredScalarDependencyMixin[str]

Require Secure Text.

A mixin for accessing a secure text config which is required and should always be present. Should only be mixed in with SecureTextConfig.

decrypted_value() → str¶

Decrypted value.

Decrypts a secure_text dependency’s encrypted value into plain text.

class RequiredSingleOrMultiValueField¶

Bases: benchling_sdk.apps.config.dependencies.BaseField, Generic[benchling_sdk.apps.config.scalars.ScalarType]

Required Single Or Multi Value Field.

A decorator class providing typed accessors for an underlying Field. Use with required fields where isMulti is unset.

additional_properties: Dict[str, Any]¶
property typed: _RequiredSingleOrMultiValueFieldTyped¶

Typed.

Return a reference to a typed field with typesafe accessors.

class RequiredValueMixin¶

Bases: object

Required Value Mixin.

A mixin for accessing a value which is required and should always be present. Should only be mixed in with HasAppConfigItem or another class that provides the self.config_item attribute.

property value: str¶

Return the value of the app config item.

class ScalarConfigItem¶

Bases: benchling_sdk.apps.config.dependencies.BaseConfigItem

Scalar Config Item.

Scalars are values that can be represented outside the Benchling domain.

__init__(parent: Union[BaseDependencies, BaseConfigNode], config_item: Optional[Union[BooleanAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, FloatAppConfigItem, IntegerAppConfigItem, JsonAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]], definition: Optional[ScalarDefinition]) → None¶
config_item: Optional[Union[BooleanAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, FloatAppConfigItem, IntegerAppConfigItem, JsonAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶
definition: Optional[ScalarDefinition]¶
class SecureTextDependency¶

Bases: benchling_sdk.apps.config.dependencies.ScalarConfigItem

SecureText Config.

A dependency for accessing a secure_text config.

__init__(parent: Union[BaseDependencies, BaseConfigNode], config_item: Optional[Union[BooleanAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, FloatAppConfigItem, IntegerAppConfigItem, JsonAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]], definition: Optional[ScalarDefinition], decryption_provider: Optional[BaseDecryptionProvider]) → None¶
decryption_provider: Optional[BaseDecryptionProvider]¶
class StaticConfigProvider¶

Bases: benchling_sdk.apps.config.dependencies.ConfigProvider

Static Config provider.

Provides a BenchlingAppConfiguration from a static declaration. Useful for mocking or testing.

__init__(configuration_items: List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]])¶

Initialize Static Config Provider.

Parameters

configuration_items – The configuration items to return.

config() → List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶

Provide Benchling app configuration items from a static reference.

exception UnsupportedDependencyError¶

Bases: Exception

Unsupported dependency error.

The manifest and configuration specified a dependency which the SDK is incapable of handling yet.