Service Interfaces¶
This package contains a series of interface definitions that need to be implemented by the implemention-dependent backend provider.
- class jsonapi_serde.interfaces.MutationContext¶
A
MutationContextdenotes a context passed over the call chains between the mapper and native object builders accompanied by a method that depends on the site state (database connections etc.)
- class jsonapi_serde.interfaces.NativeAttributeDescriptor¶
A
NativeAttributeDescriptordescribes an attribute of a native object, which will end up being associated to some resource attribute descriptor(s) byMapper.This class has nothing to do with Python’s sense of “descriptors.”
- abstract property allow_null: bool¶
Returns the attribute’s nullability which this descriptor describes.
- abstract fetch_value(target: Any) Any¶
Fetches a value from the target native object that corresponds to the attribute described by it.
- Parameters
target (Any) – A native object from which the attribute’s value is fetched.
- Returns
The fetched attribute value.
- abstract property name: Optional[str]¶
Returns the attribute’s name which this descriptor describes. In case the type is indeterminable, returns None.
- abstract property type: Optional[Type]¶
Returns the attribute’s type which this descriptor describes. In case the type is indeterminable, returns None.
- class jsonapi_serde.interfaces.NativeBuilder¶
A
NativeBuilderconstitutes the series of the “builder” objects. It is responsible for building a single native object.- abstract mark_immutable(descr: jsonapi_serde.interfaces.NativeAttributeDescriptor, mutator_descr: jsonapi_serde.interfaces.MutatorDescriptor) None¶
Marks the specified attribute as immutable. If the corresponding attribute is to be changed, the builder will end up raising
ImmutableAttributeError.- Parameters
descr (NativeAttributeDescriptor) – The attribute descriptor that represents the attribute to mark immutable.
mutator_descr (MutatorDescriptor) – The mutator descriptor that describes a set of resource attribute descriptors.
- abstract to_many_relationship(descr: jsonapi_serde.interfaces.NativeToManyRelationshipDescriptor) jsonapi_serde.interfaces.NativeToManyRelationshipBuilder¶
Returns a
NativeToManyRelationshipBuilderto build a one-to-many relationship.- Parameters
descr (NativeToManyRelationshipDescriptor) – The relationship descriptor that represents the relationship.
- Returns
The relationship builder.
- abstract to_one_relationship(descr: jsonapi_serde.interfaces.NativeToOneRelationshipDescriptor) jsonapi_serde.interfaces.NativeToOneRelationshipBuilder¶
Returns a
NativeToOneRelationshipBuilderto build a one-to-one relationship.- Parameters
descr (NativeToOneRelationshipDescriptor) – The relationship descriptor that represents the relationship.
- Returns
The relationship builder.
- class jsonapi_serde.interfaces.NativeDescriptor¶
A
NativeDescriptordenotes the properties of a native object.- abstract property attributes: Sequence[jsonapi_serde.interfaces.NativeAttributeDescriptor]¶
Returns descriptors for the attributes the native object possesses.
- Returns
the sequence of
NativeAttributeDescriptor.
- abstract property class_: type¶
Returns the class of the native object that the descriptor denotes.
- Returns
A type object that represents the class.
- abstract get_attribute_by_name(name: str) jsonapi_serde.interfaces.NativeAttributeDescriptor¶
Returns an attribute descriptor whose name is
name.- Returns
A
NativeAttributeDescriptorinstance.
- abstract get_identity(target: Any) Any¶
Retrieves the identity for the target native object.
- Returns
An implementation-dependent identifier for the native object.
- abstract get_relationship_by_name(name: str) jsonapi_serde.interfaces.NativeRelationshipDescriptor¶
Returns a relationship descriptor whose name is
name.- Returns
A
NativeRelationshipDescriptorinstance.
- abstract new_builder() jsonapi_serde.interfaces.NativeBuilder¶
Returns a new
NativeBuilderobject for building a native objects.- Returns
A new
NativeBuilderinstance.
- abstract new_updater(target: Any) jsonapi_serde.interfaces.NativeUpdater¶
Returns a new
NativeUpdaterobject for updating a native objects.- Returns
A new
NativeUpdaterinstance.
- abstract property relationships: Sequence[jsonapi_serde.interfaces.NativeRelationshipDescriptor]¶
Returns descriptors for the relationships the native object has.
- Returns
the sequence of
NativeRelationshipDescriptor.
- class jsonapi_serde.interfaces.NativeRelationshipDescriptor¶
A
NativeRelationshipDescriptordescribes a relationship of two native objects, which will end up being associated to a resource relationship descriptor byMapper. This is a super-interfaces of the following interfaces:This class has nothing to do with Python’s sense of “descriptors.”
- abstract property destination: jsonapi_serde.interfaces.NativeDescriptor¶
Returns the
NativeDescriptorobject that describes the other side of the relationship.- Returns
The
NativeDescriptorobject for the other side of the relationship.
- abstract property name: Optional[str]¶
Returns the attribute’s name which this descriptor describes. In case the type is indeterminable, returns None.
- class jsonapi_serde.interfaces.NativeToManyRelationshipBuilder¶
A
NativeToManyRelationshipBuilderconstitutes the series of the “builder” objects. It is responsible for modifying a one-to-many relationship from a single native object to multiple native objects.- abstract next(id: Any)¶
Set the builder so as to have the specified native identifier
- class jsonapi_serde.interfaces.NativeToManyRelationshipDescriptor¶
A
NativeRelationshipDescriptordescribes a one-to-many relationship between two native objects.Returns an iterable that fetches the native objects on the other side of the relationship from the target native object.
- Parameters
target (Any) – A native object from which the related object is fetched.
- Returns
The fetched object.
- class jsonapi_serde.interfaces.NativeToManyRelationshipManipulator¶
A
NativeToManyRelationshipManipulatorrepresents a batch of operations on a one-to-many relationship from a single native object to multiple native objects.- abstract add(id: Any) jsonapi_serde.deferred.Deferred[bool]¶
Add a new relationship.
- Parameters
id (Any) – A native identifier.
- Returns
a
Deferredobject that will get its value set to a boolean value that indicates if the manipulation is successfully done.
- abstract remove(id: Any) jsonapi_serde.deferred.Deferred[bool]¶
Remove an existing relationship.
- Parameters
id (Any) – A native identifier.
- Returns
a
Deferredobject that will get its value set to a boolean value that indicates if the manipulation is successfully done.
- class jsonapi_serde.interfaces.NativeToOneRelationshipBuilder¶
A
NativeToOneRelationshipBuilderconstitutes the series of the “builder” objects. It is responsible for building a one-to-one relationship between two native objects.- abstract nullify()¶
Sets the builder to not having any counterpart.
- abstract set(id: Any)¶
Sets the builder so that it will yield a counterpart native object.
- Parameters
id (Any) – A native identifier.
- class jsonapi_serde.interfaces.NativeToOneRelationshipDescriptor¶
A
NativeRelationshipDescriptordescribes a one-to-one relationship between two native objects.Fetches the native object on the other side of the relationship from the target native object.
- Parameters
target (Any) – A native object from which the related object is fetched.
- Returns
The fetched object.
- class jsonapi_serde.interfaces.NativeToOneRelationshipManipulator¶
A
NativeToOneRelationshipManipulatorconstitutes the series of the “builder” objects. It is responsible for modifying a one-to-one relationship between two native objects.- abstract nullify() jsonapi_serde.deferred.Deferred[bool]¶
Sets the updater to not having any counterpart.
- abstract set(id: Any) jsonapi_serde.deferred.Deferred[bool]¶
Sets the builder so that it will yield a counterpart native object.
- Parameters
id (Any) – A native identifier.
- Returns
a
Deferredobject that will get its value set to a boolean value that indicates if the manipulation is successfully done.
- abstract unset(id: Any) jsonapi_serde.deferred.Deferred[bool]¶
Sets the builder to not having the counterpart native object.
- Parameters
id (Any) – A native identifier.
- Returns
a
Deferredobject that will get its value set to a boolean value that indicates if the manipulation is successfully done.
- class jsonapi_serde.interfaces.NativeUpdater¶
- abstract to_many_relationship_manipulator(descr: jsonapi_serde.interfaces.NativeToManyRelationshipDescriptor) jsonapi_serde.interfaces.NativeToManyRelationshipManipulator¶
Returns a
NativeToManyRelationshipManipulatorto manipulator a one-to-many relationship.- Parameters
descr (NativeToManyRelationshipDescriptor) – The relationship descriptor that represents the relationship.
- Returns
The relationship manipulator.
- abstract to_one_relationship_manipulator(descr: jsonapi_serde.interfaces.NativeToOneRelationshipDescriptor) jsonapi_serde.interfaces.NativeToOneRelationshipManipulator¶
Returns a
NativeToOneRelationshipManipulatorto manipulate a one-to-one relationship.- Parameters
descr (NativeToOneRelationshipDescriptor) – The relationship descriptor that represents the relationship.
- Returns
The relationship manipulator.