Services
plateforme.core.services
This module provides a collection of classes and utilities to define and interact with services within the Plateforme framework. It includes base classes for creating services, utilities for service configuration and management, and a set of protocols and metaclasses to define service behavior and characteristics.
The BaseService
base class provides a base structure for defining services
for all services in the Plateforme framework, providing common functionality
and enforcing a structure for service implementations.
The BaseServiceWithSpec
base class extends the BaseService
class to include
the declaration of a resource class or specification associated with the
service.
The ServiceConfig
class provides a configuration class for services, allowing
services to define and validate configuration options for individual services.
Service
module-attribute
Service = TypeVar('Service', bound='BaseService')
A type variable for service classes.
ServiceFacade
ServiceWithSpecFacade
ServiceConfigDict
Bases: TypedDict
A service class configuration dictionary.
name
instance-attribute
name: str
The name of the service. It must adhere to a specific ALIAS
pattern
as defined in the framework's regular expressions repository. It is
inferred from the snake case version of the service name.
include
instance-attribute
The method names to include when binding the service.
exclude
instance-attribute
The method names to exclude when binding the service.
include_method
instance-attribute
The HTTP methods to include when binding the service.
exclude_method
instance-attribute
The HTTP methods to exclude when binding the service.
include_mode
instance-attribute
The method modes to include when binding the service.
exclude_mode
instance-attribute
The method modes to exclude when binding the service.
limit
instance-attribute
limit: int
The default page size limit for service queries. It is used to limit the number of results returned per page when paginating results.
page_size
instance-attribute
page_size: int
The default page size for service queries. It is used to determine the number of results returned per page when paginating results.
auto_apply_spec
instance-attribute
auto_apply_spec: bool
Whether to automatically apply the specification when binding the service to a facade owner.
ServiceConfig
ServiceConfig(
__owner: Any | None = None,
__defaults: dict[str, Any] | None = None,
__partial_init: bool = False,
/,
**data: Any,
)
Bases: ConfigWrapper
A service class configuration.
Initialize the configuration class with the given data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
__owner
|
Any | None
|
The owner of the configuration instance. It can be any
object or type that uses the configuration instance.
Defaults to |
None
|
__defaults
|
dict[str, Any] | None
|
The default values to initialize the configuration
instance with. Defaults to |
None
|
__partial_init
|
bool
|
Flag indicating whether to partially initialize
the configuration instance. Defaults to |
False
|
**data
|
Any
|
The data as keyword arguments to initialize the configuration instance with. |
{}
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
type_
class-attribute
instance-attribute
type_: str = ConfigField(
default="service", frozen=True, init=False
)
The configuration owner type set to service
. It is a protected field
that is typically used with check_config
to validate an object type
without using isinstance
in order to avoid circular imports.
name
class-attribute
instance-attribute
name: str = Deferred
The name of the service. It must adhere to a specific ALIAS
pattern
as defined in the framework's regular expressions repository. It is
inferred from the snake case version of the service name.
include
class-attribute
instance-attribute
include: list[str] | set[str] | None = ConfigField(
default=None
)
The method names to include when binding the service.
exclude
class-attribute
instance-attribute
exclude: list[str] | set[str] | None = ConfigField(
default=None
)
The method names to exclude when binding the service.
include_method
class-attribute
instance-attribute
include_method: list[APIMethod] | set[APIMethod] | None = (
ConfigField(default=None)
)
The HTTP methods to include when binding the service.
exclude_method
class-attribute
instance-attribute
exclude_method: list[APIMethod] | set[APIMethod] | None = (
ConfigField(default=None)
)
The HTTP methods to exclude when binding the service.
include_mode
class-attribute
instance-attribute
include_mode: list[APIMode] | set[APIMode] | None = (
ConfigField(default=None)
)
The method modes to include when binding the service.
exclude_mode
class-attribute
instance-attribute
exclude_mode: list[APIMode] | set[APIMode] | None = (
ConfigField(default=None)
)
The method modes to exclude when binding the service.
limit
class-attribute
instance-attribute
limit: int = ConfigField(default=20)
The default page size limit for service queries. It is used to limit the number of results returned per page when paginating results.
page_size
class-attribute
instance-attribute
page_size: int = ConfigField(default=20)
The default page size for service queries. It is used to determine the number of results returned per page when paginating results.
auto_apply_spec
class-attribute
instance-attribute
auto_apply_spec: bool = ConfigField(default=True)
Whether to automatically apply the specification when binding the service to a facade owner.
create
classmethod
create(
owner: Any | None = None,
defaults: dict[str, Any] | None = None,
partial_init: bool = False,
*,
data: dict[str, Any] | None = None,
) -> Self
Create a new configuration instance.
This method is typically used internally to create a new configuration
class with a specific owner and partial initialization flag. It is an
alternative to the __init__
method for creating a new configuration
instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
owner
|
Any | None
|
The owner of the configuration instance. |
None
|
defaults
|
dict[str, Any] | None
|
The default values to initialize the configuration
instance with. Defaults to |
None
|
partial_init
|
bool
|
Flag indicating whether to partially initialize the
configuration instance. Defaults to |
False
|
data
|
dict[str, Any] | None
|
The data to initialize the configuration instance with.
Defaults to |
None
|
Returns:
Type | Description |
---|---|
Self
|
The new configuration instance created. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
from_meta
classmethod
from_meta(
owner: type[Any],
bases: tuple[type, ...],
namespace: dict[str, Any],
/,
config_attr: str = "__config__",
partial_init: bool = False,
data: dict[str, Any] | None = None,
) -> Self
Create a new configuration instance from a class constructor.
This method is typically used internally to create a new configuration class from the meta configuration of a model, package, resource, or service. It merges the configuration of the given bases, the namespace, and the keyword arguments to create a new configuration class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
owner
|
type[Any]
|
The owner of the configuration instance. It should be the class that is being created from the meta configuration. |
required |
bases
|
tuple[type, ...]
|
The configurable base classes to merge. |
required |
namespace
|
dict[str, Any]
|
The configurable namespace to merge. |
required |
config_attr
|
str
|
The configurable attribute name used to extract the
configuration dictionary from the bases and the namespace of
the configurable class. Defaults to |
'__config__'
|
partial_init
|
bool
|
Flag indicating whether to partially initialize the
configuration instance. Defaults to |
False
|
data
|
dict[str, Any] | None
|
The data to initialize the configuration instance with.
Defaults to |
None
|
Returns:
Type | Description |
---|---|
Self
|
The new configuration instance created from the given meta |
Self
|
configuration. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
validate
Validate the configuration instance.
It post-initializes the configuration instance, checks for any missing required fields and validates the assignments of the configuration values based on the configuration fields information and the current validation context. This is performed automatically upon initialization of the configuration instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
strict
|
bool | None
|
Whether to enforce strict validation. Defaults to |
None
|
context
|
dict[str, Any] | None
|
The context to use for validation. Defaults to |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If the configuration instance has undefined values for required fields. |
ValidationError
|
If the assignment of a value is invalid based on the configuration fields information and the current validation context. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
context
staticmethod
Context manager for the configuration instance.
If the frozen mutation flag is not specified, the current frozen
mutation flag is used if available, otherwise it defaults to False
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allow_mutation
|
bool | None
|
Flag indicating whether to allow frozen mutation
of the configuration instance. When set to |
None
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
clear
copy
copy() -> Self
Return a shallow copy of the configuration dictionary.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
merge
Merge the configuration with other configurations.
It merges the configuration with the provided configuration instances
or dictionaries. The precedence of the rightmost configuration is
higher than the leftmost configuration. This can be changed by setting
the setdefault
argument to True
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*configs
|
Self | dict[str, Any]
|
The configuration instances or dictionaries to merge with the target configuration dictionary. |
()
|
setdefault
|
bool
|
Flag indicating whether to set the default values for
the configuration keys if they are not already set.
This modifies the behavior of the merge operation, making the
precedence of the leftmost configuration higher than the
rightmost configuration.
Defaults to |
False
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
check
check(
key: str,
*,
scope: Literal["all", "default", "set"] = "all",
raise_errors: bool = True,
) -> bool
Check if the configuration key exists in the given scope.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The configuration key to check for. |
required |
scope
|
Literal['all', 'default', 'set']
|
The scope to check for the configuration key. It can be
either |
'all'
|
raise_errors
|
bool
|
Flag indicating whether to raise an error if the
configuration key is not defined for the configuration wrapper.
Defaults to |
True
|
Returns:
Type | Description |
---|---|
bool
|
A boolean indicating whether the configuration key exists in the |
bool
|
specified scope. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
entries
entries(
*,
scope: Literal["all", "default", "set"] = "all",
default_mode: Literal[
"preserve", "unwrap", "wrap"
] = "unwrap",
include_keys: Iterable[str] | None = None,
exclude_keys: Iterable[str] | None = None,
include_metadata: Iterable[Any] | None = None,
exclude_metadata: Iterable[Any] | None = None,
) -> dict[str, Any]
Return the configuration dictionary.
It returns the configuration dictionary based on the specified scope, and keys and extra information to filter the configuration dictionary entries.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scope
|
Literal['all', 'default', 'set']
|
The scope of the configuration dictionary to return. It can
be either |
'all'
|
default_mode
|
Literal['preserve', 'unwrap', 'wrap']
|
The default mode to use when returning a default
entry from the configuration dictionary. It can be either
|
'unwrap'
|
include_keys
|
Iterable[str] | None
|
The keys to include from the configuration dictionary
entries. Defaults to |
None
|
exclude_keys
|
Iterable[str] | None
|
The keys to exclude from the configuration dictionary
entries. Defaults to |
None
|
include_metadata
|
Iterable[Any] | None
|
The metadata information to include from the
configuration dictionary entries. Defaults to |
None
|
exclude_metadata
|
Iterable[Any] | None
|
The metadata information to exclude from the
configuration dictionary entries. Defaults to |
None
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A dictionary containing the configuration entries based on the |
dict[str, Any]
|
specified scope and extra information. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 |
|
keys
values
values() -> ValuesView[Any]
items
get
get(
key: str,
default: Any = Undefined,
*,
default_mode: Literal[
"preserve", "unwrap", "wrap"
] = "unwrap",
) -> Any
Get the value for the specified key if set otherwise the default.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The configuration key to get the value for. |
required |
default
|
Any
|
The default value to return if the key is not set. |
Undefined
|
default_mode
|
Literal['preserve', 'unwrap', 'wrap']
|
The default mode to use when returning a default
value from the configuration dictionary. It can be either
|
'unwrap'
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
pop
pop(
key: str,
default: Any = Undefined,
*,
default_mode: Literal[
"preserve", "unwrap", "wrap"
] = "unwrap",
) -> Any
Pop the specified key if set and return its corresponding value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The configuration key to pop the value for. |
required |
default
|
Any
|
The default value to return if the key is not set. |
Undefined
|
default_mode
|
Literal['preserve', 'unwrap', 'wrap']
|
The default mode to use when returning a default
value from the configuration dictionary. It can be either
|
'unwrap'
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
getdefault
Get the default value for the specified key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The configuration key to get the default value for. |
required |
mode
|
Literal['preserve', 'unwrap', 'wrap']
|
The mode to use when returning the default value. It can be
either |
'unwrap'
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
setdefault
Set the default value for the specified key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The configuration key to set the default value for. |
required |
default
|
Any
|
The default value to set for the key. |
required |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
update
Update the config dictionary with new data.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
post_init
Post-initialization steps for the service configuration.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
ServiceMeta
Bases: ABCMeta
, ConfigurableMeta
A metaclass for service classes.
collect_config_wrappers
Collect configuration wrappers from the given bases and namespace.
It collects the configuration wrappers from the given bases and namespace by extracting the configuration wrapper type from the original bases annotation if it is a generic subclass of the configurable class or metaclass, and from the configuration attribute if present in the class and bases namespace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bases
|
tuple[type, ...]
|
The class bases. |
required |
namespace
|
dict[str, Any]
|
The class namespace. |
required |
Returns:
Type | Description |
---|---|
list[ConfigType]
|
A list of configuration wrapper classes found in the given bases |
list[ConfigType]
|
and namespace. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 |
|
collect_spec
Collect the specification from the given bases and namespace.
It collects the specification from the given bases and namespace by extracting the specification from the original bases annotation if it is a generic subclass of the base service with specification class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bases
|
tuple[type, ...]
|
The class bases. |
required |
namespace
|
dict[str, Any]
|
The class namespace. |
required |
Returns:
Type | Description |
---|---|
SpecType | None
|
The specification if found, otherwise |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
BaseService
BaseService(name: str | None = None)
Bases: Configurable[ServiceConfig]
A base class for services.
It provides a base class for creating service objects that can be attached
to a service facade owner. Services can be customized through their
service_config
attribute and optionally integrated with a specification.
When combined with a specification, services are augmented with the specification specific methods, attributes and model schemas. This allows services to have a dynamic behavior based on the provided specification.
See the BaseServiceWithSpec
class for more details on how to integrate
services with a specification.
Attributes:
Name | Type | Description |
---|---|---|
__config__ |
ServiceConfig | ConfigDict[ServiceConfigDict]
|
The configuration class setter for the service. |
__config_spec__ |
SpecType | None
|
The specification class for the service. |
service_config |
ServiceConfig
|
The configuration class for the service. |
service_methods |
dict[str, FunctionLenientType]
|
A dictionary of public methods of the service. |
service_owner |
ServiceFacade | ServiceWithSpecFacade | None
|
The service facade owner of the service. |
Note
The service class should not be directly instantiated, and it should be subclassed to define a new service class. The service class should define public methods that can be bound to the service facade owner.
Initialize the service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str | None
|
The name of the service. If provided, it will update the service name in the service configuration. This can be useful when multiple services have the same name and need to be uniquely identified. |
None
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
BaseServiceWithSpec
BaseServiceWithSpec(name: str | None = None)
Bases: BaseService
, Generic[Spec]
A base class for services with a specification.
It provides a base class for creating service objects that can be attached
to a service facade owner. Services can be customized through their
service_config
attribute.
The provided specification in the generic argument, that much implements the base specification protocol such as resources, augments the service with specific methods, attributes and model schemas. This allows services to have a dynamic behavior.
Attributes:
Name | Type | Description |
---|---|---|
service_config |
ServiceConfig
|
The configuration class for the service. |
service_methods |
dict[str, FunctionLenientType]
|
A dictionary of public methods of the service. |
service_owner |
ServiceFacade | ServiceWithSpecFacade | None
|
The service facade owner of the service. |
Note
The service class should not be directly instantiated, and it should be subclassed to define a new service class. The service class should define public methods that can be bound to the service facade owner.
Initialize the service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str | None
|
The name of the service. If provided, it will update the service name in the service configuration. This can be useful when multiple services have the same name and need to be uniquely identified. |
None
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
CRUDService
CRUDService(name: str | None = None)
Bases: BaseServiceWithSpec[CRUDSpec]
The CRUD services.
Initialize the service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str | None
|
The name of the service. If provided, it will update the service name in the service configuration. This can be useful when multiple services have the same name and need to be uniquely identified. |
None
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
ResourceFieldInfo
module-attribute
ResourceFieldInfo = FieldInfo['BaseResource']
A type alias for a resource field information.
Package
Package(
name: str,
module: ModuleType,
*,
info: dict[Any, Any] | None = None,
settings: PackageSettings | None = None,
)
Bases: Representation
A package within the Plateforme framework.
It is initialized with a python module name. It checks for a package configuration to ensure the given module name corresponds to an importable package within the Plateforme framework. Each package is uniquely represented as a singleton object, identified by its module name. This process guarantees the consistent and correct identification of Plateforme packages for further operations.
The package class exposes a catalog
attribute that maps the alias and
slug names within the package namespace to their respective objects, either
a resource type, an association (i.e. a tuple of one or two linked fields),
or a service method. It also provides access to the package resources,
dependencies, and dependents, as well as the package implementations within
the current application context.
Attributes:
Name | Type | Description |
---|---|---|
_impls |
dict[Plateforme | None, PackageImpl]
|
The registered package implementations as a dictionary mapping the application context to the package implementation. |
module |
ModuleType
|
The package module object. |
name |
str
|
The package module name that is unique within the entire runtime environment. |
info |
dict[Any, Any] | None
|
Additional information about the package. |
catalog |
Catalog
|
A dictionary mapping the alias and slug names within the package namespace to their respective objects, either a resource type, an association, or a service method. |
metadata |
MetaData
|
The package resource metadata. |
registry |
Registry
|
The package resource registry. |
Initialize a package.
Note
The import_package
method should be used to retrieve a package
instance based on the provided module name.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/packages.py
impl
property
impl: PackageImpl
The current package implementation based on the app context.
A read-only property that returns the package implementation based on the application context. If no context is available, it returns the package default implementation. Otherwise, it raises an error if the package implementation is not available in the current application context.
ResourceConfig
ResourceConfig(
__owner: Any | None = None,
__defaults: dict[str, Any] | None = None,
__partial_init: bool = False,
/,
**data: Any,
)
Bases: ModelConfig
A resource class configuration.
Initialize the configuration class with the given data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
__owner
|
Any | None
|
The owner of the configuration instance. It can be any
object or type that uses the configuration instance.
Defaults to |
None
|
__defaults
|
dict[str, Any] | None
|
The default values to initialize the configuration
instance with. Defaults to |
None
|
__partial_init
|
bool
|
Flag indicating whether to partially initialize
the configuration instance. Defaults to |
False
|
**data
|
Any
|
The data as keyword arguments to initialize the configuration instance with. |
{}
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
stub
class-attribute
instance-attribute
stub: bool = ConfigField(
default=False, frozen=True, init=False
)
Whether the model is a stub model. This is set to True
when a
collected bare model has a final stub no-operation statement.
Defaults to False
.
alias
class-attribute
instance-attribute
alias: str = Deferred
The alias name of the model. It must adhere to a specific ALIAS
pattern as defined in the framework's regular expressions repository. It is
inferred from the snake case version of the resolved model identifier.
slug
class-attribute
instance-attribute
slug: str = Deferred
The slug name of the model. It must adhere to a specific SLUG
pattern as defined in the framework's regular expressions repository. It is
inferred from the pluralized kebab case version of the model identifier.
title
class-attribute
instance-attribute
The human-readable name of the model. It must adhere to a specific
TITLE
pattern as defined in the framework's regular expressions
repository. It is inferred from the titleized version of the model
identifier.
str_to_lower
class-attribute
instance-attribute
Whether to convert strings to lowercase. Defaults to False
.
str_to_upper
class-attribute
instance-attribute
Whether to convert strings to uppercase. Defaults to False
.
str_strip_whitespace
class-attribute
instance-attribute
Whether to strip whitespace from strings. Defaults to False
.
str_min_length
class-attribute
instance-attribute
The minimum length for strings. Defaults to None
.
str_max_length
class-attribute
instance-attribute
The maximum length for strings. Defaults to None
.
frozen
class-attribute
instance-attribute
Whether to freeze the configuration. Defaults to False
.
populate_by_name
class-attribute
instance-attribute
Whether to populate fields by name. Defaults to False
.
use_enum_values
class-attribute
instance-attribute
Whether to use enum values. Defaults to False
.
validate_assignment
class-attribute
instance-attribute
Whether to validate assignments. Defaults to False
.
arbitrary_types_allowed
class-attribute
instance-attribute
Whether to allow arbitrary types. Defaults to False
.
from_attributes
class-attribute
instance-attribute
Whether to set attributes from the configuration.
Defaults to False
.
loc_by_alias
class-attribute
instance-attribute
Whether to use the alias for error loc
s. Defaults to True
.
alias_generator
class-attribute
instance-attribute
alias_generator: Annotated[
Callable[[str], str] | AliasGenerator | None, pydantic
] = to_name_case
A callable or alias generator to create aliases for the model.
Defaults to None
.
ignored_types
class-attribute
instance-attribute
A tuple of types to ignore. Defaults to an empty tuple.
allow_inf_nan
class-attribute
instance-attribute
Whether to allow infinity and NaN. Defaults to True
.
json_schema_extra
class-attribute
instance-attribute
json_schema_extra: Annotated[
JsonSchemaExtraCallable | None, pydantic
] = None
Dictionary of extra JSON schema properties. Defaults to None
.
json_encoders
class-attribute
instance-attribute
json_encoders: Annotated[
dict[type[object], JsonEncoder] | None, pydantic
] = None
A dictionary of custom JSON encoders for specific types.
Defaults to None
.
strict
class-attribute
instance-attribute
Whether to make the configuration strict. Defaults to False
.
revalidate_instances
class-attribute
instance-attribute
revalidate_instances: Annotated[
Literal["always", "never", "subclass-instances"],
pydantic,
] = "never"
When and how to revalidate models and dataclasses during validation.
Defaults to never
.
ser_json_timedelta
class-attribute
instance-attribute
The format of JSON serialized timedeltas. Defaults to iso8601
.
ser_json_bytes
class-attribute
instance-attribute
The encoding of JSON serialized bytes. Defaults to utf8
.
ser_json_inf_nan
class-attribute
instance-attribute
The encoding of JSON serialized infinity and NaN float values. Accepts
the string values of 'null'
and 'constants'
.
Defaults to 'null'
.
validate_default
class-attribute
instance-attribute
Whether to validate default values during validation.
Defaults to False
.
validate_return
class-attribute
instance-attribute
Whether to validate return values during validation.
Defaults to False
.
protected_namespaces
class-attribute
instance-attribute
A tuple of strings that prevent models to have field which conflict with
them. The provided namespaces are added to the internally forbidden and
protected ones, model_
, resource_
, and service_
.
Defaults to an empty tuple.
hide_input_in_errors
class-attribute
instance-attribute
Whether to hide inputs when printing errors. Defaults to False
.
plugin_settings
class-attribute
instance-attribute
A dictionary of settings for plugins. Defaults to None
.
schema_generator
class-attribute
instance-attribute
A custom core schema generator class to use when generating JSON
schemas. Defaults to None
.
json_schema_serialization_defaults_required
class-attribute
instance-attribute
Whether fields with default values should be marked as required in the
serialization schema. Defaults to False
.
json_schema_mode_override
class-attribute
instance-attribute
json_schema_mode_override: Annotated[
Literal["validation", "serialization"] | None, pydantic
] = None
If not None
, the specified mode will be used to generate the JSON
schema regardless of what mode
was passed to the function call.
Defaults to None
.
coerce_numbers_to_str
class-attribute
instance-attribute
If True
, enables automatic coercion of any Number
type to str
in
lax
(non-strict) mode. Defaults to False
.
regex_engine
class-attribute
instance-attribute
The regex engine to use for pattern validation.
Defaults to rust-regex
.
validation_error_cause
class-attribute
instance-attribute
If True
, Python exceptions that were part of a validation failure
will be shown as an exception group as a cause. Can be useful for
debugging. Defaults to False
.
use_attribute_docstrings
class-attribute
instance-attribute
Whether docstrings of attributes should be used for field descriptions.
Defaults to False
.
cache_strings
class-attribute
instance-attribute
Whether to cache strings to avoid constructing new Python objects.
Enabling this setting should significantly improve validation performance
while increasing memory usage slightly.
- True
or 'all'
(default): Cache all strings
- 'keys'
: Cache only dictionary keys
- False
or 'none'
: No caching
Defaults to True
.
type_
class-attribute
instance-attribute
type_: str = ConfigField(
default="resource", frozen=True, init=False
)
The configuration owner type set to resource
. It is a protected
field that is typically used with check_config
to validate an object type
without using isinstance
in order to avoid circular imports.
extra
class-attribute
instance-attribute
extra: Annotated[
Literal["allow", "ignore", "forbid"], pydantic
] = ConfigField(default="forbid", frozen=True, init=False)
Extra values are not allowed within a resource instance. This attribute
is protected and will initialize to its default value forbid
.
defer_build
class-attribute
instance-attribute
defer_build: Annotated[bool, pydantic] = ConfigField(
default=True, frozen=True, init=False
)
Defer building is not allowed for resource instances. This attribute is
protected and will initialize to its default value True
.
tags
class-attribute
instance-attribute
A list of tags to associate with the resource. Tags are used to group
resources and provide additional metadata. It will be added to the
generated OpenAPI, visible at /docs
. If not provided, the resource slug
will be used as the default tag. Defaults to None
.
api_max_depth
class-attribute
instance-attribute
api_max_depth: int = 2
The maximum depth to walk through the resource path to collect manager
methods from resource dependencies. It is used to generate API routes.
Defaults to 2
.
api_max_selection
class-attribute
instance-attribute
api_max_selection: int = 20
The limit of resources to return for the API route selections. It is
used when generating the API routes for resources within the application
to avoid too many resources being returned. Defaults to 20
.
id_strategy
class-attribute
instance-attribute
id_strategy: Literal['auto', 'manual', 'hybrid'] = 'auto'
The identifier strategy to use for the resource. It defines how the
identifier is generated for the resource and can be set to one of the
following values:
- auto
: Enforce automatic generation of the resource identifier.
- manual
: Enforce manual specification of the resource identifier.
- hybrid
: Allow both automatic and manual generation of the resource
identifier.
Defaults to auto
.
id_type
class-attribute
instance-attribute
id_type: Literal['integer', 'uuid'] = 'integer'
The identifier type to use for the resource. It defines the data type of
the resource identifier and can be set to one of the following values:
- integer
: Use an integer data type engine for the resource identifier.
- uuid
: Use a UUID data type engine for the resource identifier.
Defaults to integer
.
mapper_args
class-attribute
instance-attribute
A dictionary of additional arguments to pass to the resource declarative
mapper during the resource configuration, i.e. the dictionary of arguments
to add to the __mapper_args__
attribute of the resource class.
Defaults to an empty dictionary.
use_single_table_inheritance
class-attribute
instance-attribute
use_single_table_inheritance: bool = False
It defines the inheritance design pattern to use for database ORM.
Defaults to False
, using joined table inheritance with separate tables
for parent and child classes linked by a foreign key. This approach is
generally preferred for its normalization benefits. Setting this to
True
enables single table inheritance, creating a single table for both
parent and child classes with a discriminator column.
Note
Single table inheritance can lead to sparse tables and may impact performance for large and complex hierarchies.
indexes
class-attribute
instance-attribute
indexes: tuple[ResourceIndex, ...] = ()
A tuple of resource indexes configurations that define indexing for
resource model fields. An index is defined as a dictionary with the
following keys:
- aliases
: A tuple of strings representing the resource field aliases
to include in the index.
- unique
: Whether the index is unique. Defaults to True
.
Defaults to an empty tuple.
services
class-attribute
instance-attribute
services: tuple[
BaseService | EllipsisType | ServiceType, ...
] = ()
A tuple of services to bind to the resource. The services are used to
define the business logic and data access methods for the resource. The
services can be defined as instances of BaseService
or as service
types. The ellipsis ...
can be used to insert all services from the
parent resource. Defaults to an empty tuple.
specs
class-attribute
instance-attribute
A tuple of specifications to apply to the resource. The specifications are used to define additional resource configurations, schemas, and behaviors. All the specifications from the parent resource are merged with the provided configuration, .i.e. a child resource must inherit all the specifications from the parent resource. Defaults to an empty tuple.
deprecated
class-attribute
instance-attribute
deprecated: bool | None = None
A flag indicating whether the resource is deprecated.
Defaults to None
.
id_autoincrement
property
Whether the resource identifier is autoincremented.
id_engine
property
id_engine: type[IntegerEngine | UuidEngine[UUID4]]
The identifier engine to use for the resource.
create
classmethod
create(
owner: Any | None = None,
defaults: dict[str, Any] | None = None,
partial_init: bool = False,
*,
data: dict[str, Any] | None = None,
) -> Self
Create a new configuration instance.
This method is typically used internally to create a new configuration
class with a specific owner and partial initialization flag. It is an
alternative to the __init__
method for creating a new configuration
instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
owner
|
Any | None
|
The owner of the configuration instance. |
None
|
defaults
|
dict[str, Any] | None
|
The default values to initialize the configuration
instance with. Defaults to |
None
|
partial_init
|
bool
|
Flag indicating whether to partially initialize the
configuration instance. Defaults to |
False
|
data
|
dict[str, Any] | None
|
The data to initialize the configuration instance with.
Defaults to |
None
|
Returns:
Type | Description |
---|---|
Self
|
The new configuration instance created. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
from_meta
classmethod
from_meta(
owner: type[Any],
bases: tuple[type, ...],
namespace: dict[str, Any],
/,
config_attr: str = "__config__",
partial_init: bool = False,
data: dict[str, Any] | None = None,
) -> Self
Create a new configuration instance from a class constructor.
This method is typically used internally to create a new configuration class from the meta configuration of a model, package, resource, or service. It merges the configuration of the given bases, the namespace, and the keyword arguments to create a new configuration class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
owner
|
type[Any]
|
The owner of the configuration instance. It should be the class that is being created from the meta configuration. |
required |
bases
|
tuple[type, ...]
|
The configurable base classes to merge. |
required |
namespace
|
dict[str, Any]
|
The configurable namespace to merge. |
required |
config_attr
|
str
|
The configurable attribute name used to extract the
configuration dictionary from the bases and the namespace of
the configurable class. Defaults to |
'__config__'
|
partial_init
|
bool
|
Flag indicating whether to partially initialize the
configuration instance. Defaults to |
False
|
data
|
dict[str, Any] | None
|
The data to initialize the configuration instance with.
Defaults to |
None
|
Returns:
Type | Description |
---|---|
Self
|
The new configuration instance created from the given meta |
Self
|
configuration. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
validate
Validate the configuration instance.
It post-initializes the configuration instance, checks for any missing required fields and validates the assignments of the configuration values based on the configuration fields information and the current validation context. This is performed automatically upon initialization of the configuration instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
strict
|
bool | None
|
Whether to enforce strict validation. Defaults to |
None
|
context
|
dict[str, Any] | None
|
The context to use for validation. Defaults to |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If the configuration instance has undefined values for required fields. |
ValidationError
|
If the assignment of a value is invalid based on the configuration fields information and the current validation context. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
context
staticmethod
Context manager for the configuration instance.
If the frozen mutation flag is not specified, the current frozen
mutation flag is used if available, otherwise it defaults to False
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allow_mutation
|
bool | None
|
Flag indicating whether to allow frozen mutation
of the configuration instance. When set to |
None
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
clear
copy
copy() -> Self
Return a shallow copy of the configuration dictionary.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
merge
Merge the configuration with other configurations.
It merges the configuration with the provided configuration instances
or dictionaries. The precedence of the rightmost configuration is
higher than the leftmost configuration. This can be changed by setting
the setdefault
argument to True
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*configs
|
Self | dict[str, Any]
|
The configuration instances or dictionaries to merge with the target configuration dictionary. |
()
|
setdefault
|
bool
|
Flag indicating whether to set the default values for
the configuration keys if they are not already set.
This modifies the behavior of the merge operation, making the
precedence of the leftmost configuration higher than the
rightmost configuration.
Defaults to |
False
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
check
check(
key: str,
*,
scope: Literal["all", "default", "set"] = "all",
raise_errors: bool = True,
) -> bool
Check if the configuration key exists in the given scope.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The configuration key to check for. |
required |
scope
|
Literal['all', 'default', 'set']
|
The scope to check for the configuration key. It can be
either |
'all'
|
raise_errors
|
bool
|
Flag indicating whether to raise an error if the
configuration key is not defined for the configuration wrapper.
Defaults to |
True
|
Returns:
Type | Description |
---|---|
bool
|
A boolean indicating whether the configuration key exists in the |
bool
|
specified scope. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
entries
entries(
*,
scope: Literal["all", "default", "set"] = "all",
default_mode: Literal[
"preserve", "unwrap", "wrap"
] = "unwrap",
include_keys: Iterable[str] | None = None,
exclude_keys: Iterable[str] | None = None,
include_metadata: Iterable[Any] | None = None,
exclude_metadata: Iterable[Any] | None = None,
) -> dict[str, Any]
Return the configuration dictionary.
It returns the configuration dictionary based on the specified scope, and keys and extra information to filter the configuration dictionary entries.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scope
|
Literal['all', 'default', 'set']
|
The scope of the configuration dictionary to return. It can
be either |
'all'
|
default_mode
|
Literal['preserve', 'unwrap', 'wrap']
|
The default mode to use when returning a default
entry from the configuration dictionary. It can be either
|
'unwrap'
|
include_keys
|
Iterable[str] | None
|
The keys to include from the configuration dictionary
entries. Defaults to |
None
|
exclude_keys
|
Iterable[str] | None
|
The keys to exclude from the configuration dictionary
entries. Defaults to |
None
|
include_metadata
|
Iterable[Any] | None
|
The metadata information to include from the
configuration dictionary entries. Defaults to |
None
|
exclude_metadata
|
Iterable[Any] | None
|
The metadata information to exclude from the
configuration dictionary entries. Defaults to |
None
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A dictionary containing the configuration entries based on the |
dict[str, Any]
|
specified scope and extra information. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 |
|
keys
values
values() -> ValuesView[Any]
items
get
get(
key: str,
default: Any = Undefined,
*,
default_mode: Literal[
"preserve", "unwrap", "wrap"
] = "unwrap",
) -> Any
Get the value for the specified key if set otherwise the default.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The configuration key to get the value for. |
required |
default
|
Any
|
The default value to return if the key is not set. |
Undefined
|
default_mode
|
Literal['preserve', 'unwrap', 'wrap']
|
The default mode to use when returning a default
value from the configuration dictionary. It can be either
|
'unwrap'
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
pop
pop(
key: str,
default: Any = Undefined,
*,
default_mode: Literal[
"preserve", "unwrap", "wrap"
] = "unwrap",
) -> Any
Pop the specified key if set and return its corresponding value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The configuration key to pop the value for. |
required |
default
|
Any
|
The default value to return if the key is not set. |
Undefined
|
default_mode
|
Literal['preserve', 'unwrap', 'wrap']
|
The default mode to use when returning a default
value from the configuration dictionary. It can be either
|
'unwrap'
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
getdefault
Get the default value for the specified key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The configuration key to get the default value for. |
required |
mode
|
Literal['preserve', 'unwrap', 'wrap']
|
The mode to use when returning the default value. It can be
either |
'unwrap'
|
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
setdefault
Set the default value for the specified key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The configuration key to set the default value for. |
required |
default
|
Any
|
The default value to set for the key. |
required |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
update
Update the config dictionary with new data.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/config.py
post_init
Post-initialization steps for the resource configuration.
Source code in .venv/lib/python3.12/site-packages/plateforme/core/resources.py
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
|
create
async
create(
session: AsyncSessionDep,
__selection: KeyList[CRUDSpec] = Selection(),
payload: Create | Sequence[Create] = Payload(
apply_selection=True,
title="Payload",
description="The payload to create instances of the associated\n resource, either a single instance or a sequence of instances.\n The payload must adhere to the resource schema for the create\n operation.",
),
return_result: bool = Body(
default=True,
title="Return result",
description="Whether to return the created result. If set to\n `False`, the transaction will be executed without returning\n the result.",
),
include: IncEx | None = Body(
default=None,
title="Include fields",
description="The fields to include in the query results.",
examples=[
["user.name", "user.email"],
{"user": ["name", "email"], "product": False},
],
),
exclude: IncEx | None = Body(
default=None,
title="Exclude fields",
description="The fields to exclude from the query results.",
examples=[
["user.password", "product.price"],
{"user": ["password"], "product": True},
],
),
dry_run: bool = Body(
default=False,
title="Dry-run",
description="Whether to run the transaction in dry-run mode. If\n set to `True`, the transaction will be rolled back after\n execution.",
),
) -> Any | None
Create a single or collection of resource instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSessionDep
|
The async session dependency to use for the transaction. |
required |
__selection
|
KeyList[CRUDSpec]
|
The key selection dependency to resolve the query. |
Selection()
|
payload
|
Create | Sequence[Create]
|
The payload to create instances of the associated resource, either a single instance or a sequence of instances. |
Payload(apply_selection=True, title='Payload', description='The payload to create instances of the associated\n resource, either a single instance or a sequence of instances.\n The payload must adhere to the resource schema for the create\n operation.')
|
return_result
|
bool
|
Whether to return the created result. |
Body(default=True, title='Return result', description='Whether to return the created result. If set to\n `False`, the transaction will be executed without returning\n the result.')
|
include
|
IncEx | None
|
The fields to include in the query results. |
Body(default=None, title='Include fields', description='The fields to include in the query results.', examples=[['user.name', 'user.email'], {'user': ['name', 'email'], 'product': False}])
|
exclude
|
IncEx | None
|
The fields to exclude from the query results. |
Body(default=None, title='Exclude fields', description='The fields to exclude from the query results.', examples=[['user.password', 'product.price'], {'user': ['password'], 'product': True}])
|
dry_run
|
bool
|
Whether to run the transaction in dry-run mode. |
Body(default=False, title='Dry-run', description='Whether to run the transaction in dry-run mode. If\n set to `True`, the transaction will be rolled back after\n execution.')
|
Returns:
Type | Description |
---|---|
Any | None
|
The created resource instances or |
Any | None
|
disabled, i.e., |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 |
|
read_one
async
read_one(
session: AsyncSessionDep,
selection: Key[CRUDSpec] = Selection(),
include: IncEx | None = Body(
default=None,
title="Include fields",
description="The fields to include in the query results.",
examples=[
["user.name", "user.email"],
{"user": ["name", "email"], "product": False},
],
),
exclude: IncEx | None = Body(
default=None,
title="Exclude fields",
description="The fields to exclude from the query results.",
examples=[
["user.password", "product.price"],
{"user": ["password"], "product": True},
],
),
) -> Any
Read a resource instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSessionDep
|
The async session dependency to use for the query. |
required |
selection
|
Key[CRUDSpec]
|
The key selection dependency to resolve the query. |
Selection()
|
include
|
IncEx | None
|
The fields to include in the query results. |
Body(default=None, title='Include fields', description='The fields to include in the query results.', examples=[['user.name', 'user.email'], {'user': ['name', 'email'], 'product': False}])
|
exclude
|
IncEx | None
|
The fields to exclude from the query results. |
Body(default=None, title='Exclude fields', description='The fields to exclude from the query results.', examples=[['user.password', 'product.price'], {'user': ['password'], 'product': True}])
|
Returns:
Type | Description |
---|---|
Any
|
The resource instance from the selection. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
read_many
async
read_many(
session: AsyncSessionDep,
selection: KeyList[CRUDSpec] = Selection(),
include: IncEx | None = Body(
default=None,
title="Include fields",
description="The fields to include in the query results.",
examples=[
["user.name", "user.email"],
{"user": ["name", "email"], "product": False},
],
),
exclude: IncEx | None = Body(
default=None,
title="Exclude fields",
description="The fields to exclude from the query results.",
examples=[
["user.password", "product.price"],
{"user": ["password"], "product": True},
],
),
filter: Annotated[
Filter | None, Depends(filter_dependency)
] = Body(
default=None,
title="Filter criteria",
description="The filter criteria to apply to the query. It is\n specified in the request body as a dictionary of field aliases\n with their corresponding filter criteria. Additionally, it can\n be specified directly in the query parameters using a dot\n notation for field aliases and tilde `~` character for filter\n criteria. For example, to filter results where the `user.name`\n field starts with `Al`, the filter criteria can be specified as\n `.user.name=like~Al*` in the query parameters.",
examples=[
".user.name=like~Al*",
".price=gt~1000",
".user.name=like~Al*&.price=gt~1000",
{
"user": {
"name": {
"operator": "like",
"value": "Al*",
}
},
"price": {"operator": "gt", "value": 1000},
},
],
),
sort: Sort | None = Query(
default=None,
title="Sort criteria",
description="The sort criteria to apply to the query. It is\n specified in the query parameters as a comma-separated list of\n field aliases with an optional prefix of a minus sign `-` for\n descending order. For example, to sort results by the\n `user.name` field in descending order, the sort criteria can be\n specified as `user.name,-price` in the query parameters.\n Additionally, the direction and nulls position can be piped\n using a colon `:` character. For example, to sort results by\n the `price` field in ascending order with nulls first, the sort\n criteria can be specified as `price:asc:nf` in the query\n parameters.",
examples=["user.name,-price", "price:asc:nf"],
),
limit: int | None = Query(
default=None,
gt=0,
title="Limit",
description="The maximum number of results to return. It is\n specified in the query parameters as an integer value. Defaults\n to the service configuration default page size if not\n specified.",
examples=[10, 20, 50],
),
offset: int | None = Query(
default=None,
ge=0,
title="Offset",
description="The number of results to skip before returning the\n results. It is specified in the query parameters as an integer\n value. Defaults to `0` if not specified.",
),
page: int | None = Query(
default=None,
gt=0,
title="Page",
description="The page number to return results for. It is\n specified in the query parameters as an integer value. Defaults\n to the first page if not specified.",
),
page_size: int | None = Query(
default=None,
gt=0,
title="Page size",
description="The number of results to return per page. It is\n specified in the query parameters as an integer value. The\n maximum page size is defined by the service configuration.\n Defaults to the service configuration default page size if not\n specified.",
),
) -> Any
Read a collection of resource instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSessionDep
|
The async session dependency to use for the query. |
required |
selection
|
KeyList[CRUDSpec]
|
The key selection dependency to resolve the query. |
Selection()
|
include
|
IncEx | None
|
The fields to include in the query results. |
Body(default=None, title='Include fields', description='The fields to include in the query results.', examples=[['user.name', 'user.email'], {'user': ['name', 'email'], 'product': False}])
|
exclude
|
IncEx | None
|
The fields to exclude from the query results. |
Body(default=None, title='Exclude fields', description='The fields to exclude from the query results.', examples=[['user.password', 'product.price'], {'user': ['password'], 'product': True}])
|
filter
|
Annotated[Filter | None, Depends(filter_dependency)]
|
The filter criteria to apply to the query. |
Body(default=None, title='Filter criteria', description='The filter criteria to apply to the query. It is\n specified in the request body as a dictionary of field aliases\n with their corresponding filter criteria. Additionally, it can\n be specified directly in the query parameters using a dot\n notation for field aliases and tilde `~` character for filter\n criteria. For example, to filter results where the `user.name`\n field starts with `Al`, the filter criteria can be specified as\n `.user.name=like~Al*` in the query parameters.', examples=['.user.name=like~Al*', '.price=gt~1000', '.user.name=like~Al*&.price=gt~1000', {'user': {'name': {'operator': 'like', 'value': 'Al*'}}, 'price': {'operator': 'gt', 'value': 1000}}])
|
sort
|
Sort | None
|
The sort criteria to apply to the query. |
Query(default=None, title='Sort criteria', description='The sort criteria to apply to the query. It is\n specified in the query parameters as a comma-separated list of\n field aliases with an optional prefix of a minus sign `-` for\n descending order. For example, to sort results by the\n `user.name` field in descending order, the sort criteria can be\n specified as `user.name,-price` in the query parameters.\n Additionally, the direction and nulls position can be piped\n using a colon `:` character. For example, to sort results by\n the `price` field in ascending order with nulls first, the sort\n criteria can be specified as `price:asc:nf` in the query\n parameters.', examples=['user.name,-price', 'price:asc:nf'])
|
limit
|
int | None
|
The maximum number of results to return. |
Query(default=None, gt=0, title='Limit', description='The maximum number of results to return. It is\n specified in the query parameters as an integer value. Defaults\n to the service configuration default page size if not\n specified.', examples=[10, 20, 50])
|
offset
|
int | None
|
The number of results to skip before returning the results. |
Query(default=None, ge=0, title='Offset', description='The number of results to skip before returning the\n results. It is specified in the query parameters as an integer\n value. Defaults to `0` if not specified.')
|
page
|
int | None
|
The page number to return results for. |
Query(default=None, gt=0, title='Page', description='The page number to return results for. It is\n specified in the query parameters as an integer value. Defaults\n to the first page if not specified.')
|
page_size
|
int | None
|
The number of results to return per page. |
Query(default=None, gt=0, title='Page size', description='The number of results to return per page. It is\n specified in the query parameters as an integer value. The\n maximum page size is defined by the service configuration.\n Defaults to the service configuration default page size if not\n specified.')
|
Returns:
Type | Description |
---|---|
Any
|
The collection of resource instances from the selection. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 |
|
update_one
async
update_one(
session: AsyncSessionDep,
selection: Key[CRUDSpec] = Selection(),
payload: Update = Payload(
apply_selection=False,
title="Payload",
description="The payload to update the instance of the associated\n resource. The payload must adhere to the resource schema for\n the update operation.",
),
return_result: bool = Body(
default=True,
title="Return result",
description="Whether to return the updated result. If set to\n `False`, the transaction will be executed without returning\n the result.",
),
include: IncEx | None = Body(
default=None,
title="Include fields",
description="The fields to include in the query results.",
examples=[
["user.name", "user.email"],
{"user": ["name", "email"], "product": False},
],
),
exclude: IncEx | None = Body(
default=None,
title="Exclude fields",
description="The fields to exclude from the query results.",
examples=[
["user.password", "product.price"],
{"user": ["password"], "product": True},
],
),
dry_run: bool = Body(
default=False,
title="Dry-run",
description="Whether to run the transaction in dry-run mode. If\n set to `True`, the transaction will be rolled back after\n execution.",
),
) -> Any | None
Update a resource instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSessionDep
|
The async session dependency to use for the transaction. |
required |
selection
|
Key[CRUDSpec]
|
The key selection dependency to resolve the query. |
Selection()
|
payload
|
Update
|
The payload to update the associated resource instance. |
Payload(apply_selection=False, title='Payload', description='The payload to update the instance of the associated\n resource. The payload must adhere to the resource schema for\n the update operation.')
|
return_result
|
bool
|
Whether to return the updated result. |
Body(default=True, title='Return result', description='Whether to return the updated result. If set to\n `False`, the transaction will be executed without returning\n the result.')
|
include
|
IncEx | None
|
The fields to include in the query results. |
Body(default=None, title='Include fields', description='The fields to include in the query results.', examples=[['user.name', 'user.email'], {'user': ['name', 'email'], 'product': False}])
|
exclude
|
IncEx | None
|
The fields to exclude from the query results. |
Body(default=None, title='Exclude fields', description='The fields to exclude from the query results.', examples=[['user.password', 'product.price'], {'user': ['password'], 'product': True}])
|
dry_run
|
bool
|
Whether to run the transaction in dry-run mode. |
Body(default=False, title='Dry-run', description='Whether to run the transaction in dry-run mode. If\n set to `True`, the transaction will be rolled back after\n execution.')
|
Returns:
Type | Description |
---|---|
Any | None
|
The updated resource instance or |
Any | None
|
disabled, i.e., |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 |
|
update_many
async
update_many(
session: AsyncSessionDep,
selection: KeyList[CRUDSpec] = Selection(),
payload: Update = Payload(
apply_selection=False,
title="Payload",
description="The payload to update instances of the associated\n resource. The payload must adhere to the resource schema for\n the update operation.",
),
return_result: bool = Body(
default=True,
title="Return result",
description="Whether to return the updated result. If set to\n `False`, the transaction will be executed without returning\n the result.",
),
include: IncEx | None = Body(
default=None,
title="Include fields",
description="The fields to include in the query results.",
examples=[
["user.name", "user.email"],
{"user": ["name", "email"], "product": False},
],
),
exclude: IncEx | None = Body(
default=None,
title="Exclude fields",
description="The fields to exclude from the query results.",
examples=[
["user.password", "product.price"],
{"user": ["password"], "product": True},
],
),
filter: Annotated[
Filter | None, Depends(filter_dependency)
] = Body(
default=None,
title="Filter criteria",
description="The filter criteria to apply to the query. It is\n specified in the request body as a dictionary of field aliases\n with their corresponding filter criteria. Additionally, it can\n be specified directly in the query parameters using a dot\n notation for field aliases and tilde `~` character for filter\n criteria. For example, to filter results where the `user.name`\n field starts with `Al`, the filter criteria can be specified as\n `.user.name=like~Al*` in the query parameters.",
examples=[
".user.name=like~Al*",
".price=gt~1000",
".user.name=like~Al*&.price=gt~1000",
{
"user": {
"name": {
"operator": "like",
"value": "Al*",
}
},
"price": {"operator": "gt", "value": 1000},
},
],
),
sort: Sort | None = Query(
default=None,
title="Sort criteria",
description="The sort criteria to apply to the query. It is\n specified in the query parameters as a comma-separated list of\n field aliases with an optional prefix of a minus sign `-` for\n descending order. For example, to sort results by the\n `user.name` field in descending order, the sort criteria can be\n specified as `user.name,-price` in the query parameters.\n Additionally, the direction and nulls position can be piped\n using a colon `:` character. For example, to sort results by\n the `price` field in ascending order with nulls first, the sort\n criteria can be specified as `price:asc:nf` in the query\n parameters.",
examples=["user.name,-price", "price:asc:nf"],
),
limit: int | None = Query(
default=None,
gt=0,
title="Limit",
description="The maximum number of results to return. It is\n specified in the query parameters as an integer value. Defaults\n to the service configuration default page size if not\n specified.",
examples=[10, 20, 50],
),
offset: int | None = Query(
default=None,
ge=0,
title="Offset",
description="The number of results to skip before returning the\n results. It is specified in the query parameters as an integer\n value. Defaults to `0` if not specified.",
),
page: int | None = Query(
default=None,
gt=0,
title="Page",
description="The page number to return results for. It is\n specified in the query parameters as an integer value. Defaults\n to the first page if not specified.",
),
page_size: int | None = Query(
default=None,
gt=0,
title="Page size",
description="The number of results to return per page. It is\n specified in the query parameters as an integer value. The\n maximum page size is defined by the service configuration.\n Defaults to the service configuration default page size if not\n specified.",
),
dry_run: bool = Body(
default=False,
title="Dry-run",
description="Whether to run the transaction in dry-run mode. If\n set to `True`, the transaction will be rolled back after\n execution.",
),
) -> Any | None
Update a collection of resource instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSessionDep
|
The async session dependency to use for the transaction. |
required |
selection
|
KeyList[CRUDSpec]
|
The key selection dependency to resolve the query. |
Selection()
|
payload
|
Update
|
The payload to update instances of the associated resource. |
Payload(apply_selection=False, title='Payload', description='The payload to update instances of the associated\n resource. The payload must adhere to the resource schema for\n the update operation.')
|
return_result
|
bool
|
Whether to return the updated result. |
Body(default=True, title='Return result', description='Whether to return the updated result. If set to\n `False`, the transaction will be executed without returning\n the result.')
|
include
|
IncEx | None
|
The fields to include in the query results. |
Body(default=None, title='Include fields', description='The fields to include in the query results.', examples=[['user.name', 'user.email'], {'user': ['name', 'email'], 'product': False}])
|
exclude
|
IncEx | None
|
The fields to exclude from the query results. |
Body(default=None, title='Exclude fields', description='The fields to exclude from the query results.', examples=[['user.password', 'product.price'], {'user': ['password'], 'product': True}])
|
filter
|
Annotated[Filter | None, Depends(filter_dependency)]
|
The filter criteria to apply to the query. |
Body(default=None, title='Filter criteria', description='The filter criteria to apply to the query. It is\n specified in the request body as a dictionary of field aliases\n with their corresponding filter criteria. Additionally, it can\n be specified directly in the query parameters using a dot\n notation for field aliases and tilde `~` character for filter\n criteria. For example, to filter results where the `user.name`\n field starts with `Al`, the filter criteria can be specified as\n `.user.name=like~Al*` in the query parameters.', examples=['.user.name=like~Al*', '.price=gt~1000', '.user.name=like~Al*&.price=gt~1000', {'user': {'name': {'operator': 'like', 'value': 'Al*'}}, 'price': {'operator': 'gt', 'value': 1000}}])
|
sort
|
Sort | None
|
The sort criteria to apply to the query. |
Query(default=None, title='Sort criteria', description='The sort criteria to apply to the query. It is\n specified in the query parameters as a comma-separated list of\n field aliases with an optional prefix of a minus sign `-` for\n descending order. For example, to sort results by the\n `user.name` field in descending order, the sort criteria can be\n specified as `user.name,-price` in the query parameters.\n Additionally, the direction and nulls position can be piped\n using a colon `:` character. For example, to sort results by\n the `price` field in ascending order with nulls first, the sort\n criteria can be specified as `price:asc:nf` in the query\n parameters.', examples=['user.name,-price', 'price:asc:nf'])
|
limit
|
int | None
|
The maximum number of results to return. |
Query(default=None, gt=0, title='Limit', description='The maximum number of results to return. It is\n specified in the query parameters as an integer value. Defaults\n to the service configuration default page size if not\n specified.', examples=[10, 20, 50])
|
offset
|
int | None
|
The number of results to skip before returning the results. |
Query(default=None, ge=0, title='Offset', description='The number of results to skip before returning the\n results. It is specified in the query parameters as an integer\n value. Defaults to `0` if not specified.')
|
page
|
int | None
|
The page number to return results for. |
Query(default=None, gt=0, title='Page', description='The page number to return results for. It is\n specified in the query parameters as an integer value. Defaults\n to the first page if not specified.')
|
page_size
|
int | None
|
The number of results to return per page. |
Query(default=None, gt=0, title='Page size', description='The number of results to return per page. It is\n specified in the query parameters as an integer value. The\n maximum page size is defined by the service configuration.\n Defaults to the service configuration default page size if not\n specified.')
|
dry_run
|
bool
|
Whether to run the transaction in dry-run mode. |
Body(default=False, title='Dry-run', description='Whether to run the transaction in dry-run mode. If\n set to `True`, the transaction will be rolled back after\n execution.')
|
Returns:
Type | Description |
---|---|
Any | None
|
The updated resource instances or |
Any | None
|
disabled, i.e., |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 |
|
upsert
async
upsert(
session: AsyncSessionDep,
__selection: KeyList[CRUDSpec] = Selection(),
payload: Upsert | Sequence[Upsert] = Payload(
apply_selection=True,
title="Payload",
description="The payload to upsert instances of the associated\n resource, either a single instance or a sequence of instances.\n The payload must adhere to the resource schema for the upsert\n operation.",
),
on_conflict: Literal["update", "skip"] = Body(
default="update",
title="On conflict",
description="The conflict resolution strategy to apply when\n upserting instances. It can be either `update` to update the\n existing instances or `skip` to skip the existing instances.\n ",
),
return_result: bool = Body(
default=True,
title="Return result",
description="Whether to return the upserted result. If set to\n `False`, the transaction will be executed without returning\n the result.",
),
include: IncEx | None = Body(
default=None,
title="Include fields",
description="The fields to include in the query results.",
examples=[
["user.name", "user.email"],
{"user": ["name", "email"], "product": False},
],
),
exclude: IncEx | None = Body(
default=None,
title="Exclude fields",
description="The fields to exclude from the query results.",
examples=[
["user.password", "product.price"],
{"user": ["password"], "product": True},
],
),
dry_run: bool = Body(
default=False,
title="Dry-run",
description="Whether to run the transaction in dry-run mode. If\n set to `True`, the transaction will be rolled back after\n execution.",
),
) -> Any | None
Upsert a single or collection of resource instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSessionDep
|
The async session dependency to use for the transaction. |
required |
__selection
|
KeyList[CRUDSpec]
|
The key selection dependency to resolve the query. |
Selection()
|
payload
|
Upsert | Sequence[Upsert]
|
The payload to upsert instances of the associated resource, either a single instance or a sequence of instances. |
Payload(apply_selection=True, title='Payload', description='The payload to upsert instances of the associated\n resource, either a single instance or a sequence of instances.\n The payload must adhere to the resource schema for the upsert\n operation.')
|
on_conflict
|
Literal['update', 'skip']
|
The conflict resolution strategy to apply when upserting instances. |
Body(default='update', title='On conflict', description='The conflict resolution strategy to apply when\n upserting instances. It can be either `update` to update the\n existing instances or `skip` to skip the existing instances.\n ')
|
return_result
|
bool
|
Whether to return the upserted result. |
Body(default=True, title='Return result', description='Whether to return the upserted result. If set to\n `False`, the transaction will be executed without returning\n the result.')
|
include
|
IncEx | None
|
The fields to include in the query results. |
Body(default=None, title='Include fields', description='The fields to include in the query results.', examples=[['user.name', 'user.email'], {'user': ['name', 'email'], 'product': False}])
|
exclude
|
IncEx | None
|
The fields to exclude from the query results. |
Body(default=None, title='Exclude fields', description='The fields to exclude from the query results.', examples=[['user.password', 'product.price'], {'user': ['password'], 'product': True}])
|
dry_run
|
bool
|
Whether to run the transaction in dry-run mode. |
Body(default=False, title='Dry-run', description='Whether to run the transaction in dry-run mode. If\n set to `True`, the transaction will be rolled back after\n execution.')
|
Returns:
Type | Description |
---|---|
Any | None
|
The upserted resource instances or |
Any | None
|
disabled, i.e., |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 |
|
delete_one
async
delete_one(
session: AsyncSessionDep,
selection: Key[CRUDSpec] = Selection(),
return_result: bool = Body(
default=False,
title="Return result",
description="Whether to return the deleted result. If set to\n `False`, the transaction will be executed without returning\n the result.",
),
include: IncEx | None = Body(
default=None,
title="Include fields",
description="The fields to include in the query results.",
examples=[
["user.name", "user.email"],
{"user": ["name", "email"], "product": False},
],
),
exclude: IncEx | None = Body(
default=None,
title="Exclude fields",
description="The fields to exclude from the query results.",
examples=[
["user.password", "product.price"],
{"user": ["password"], "product": True},
],
),
dry_run: bool = Body(
default=False,
title="Dry-run",
description="Whether to run the transaction in dry-run mode. If\n set to `True`, the transaction will be rolled back after\n execution.",
),
) -> Any | None
Delete a resource instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSessionDep
|
The async session dependency to use for the query. |
required |
selection
|
Key[CRUDSpec]
|
The key selection dependency to resolve the query. |
Selection()
|
return_result
|
bool
|
Whether to return the deletion result. |
Body(default=False, title='Return result', description='Whether to return the deleted result. If set to\n `False`, the transaction will be executed without returning\n the result.')
|
include
|
IncEx | None
|
The fields to include in the query results. |
Body(default=None, title='Include fields', description='The fields to include in the query results.', examples=[['user.name', 'user.email'], {'user': ['name', 'email'], 'product': False}])
|
exclude
|
IncEx | None
|
The fields to exclude from the query results. |
Body(default=None, title='Exclude fields', description='The fields to exclude from the query results.', examples=[['user.password', 'product.price'], {'user': ['password'], 'product': True}])
|
dry_run
|
bool
|
Whether to run the transaction in dry-run mode. |
Body(default=False, title='Dry-run', description='Whether to run the transaction in dry-run mode. If\n set to `True`, the transaction will be rolled back after\n execution.')
|
Returns:
Type | Description |
---|---|
Any | None
|
The deleted resource instance or |
Any | None
|
disabled, i.e., |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 |
|
delete_many
async
delete_many(
session: AsyncSessionDep,
selection: KeyList[CRUDSpec] = Selection(),
return_result: bool = Body(
default=False,
title="Return result",
description="Whether to return the deleted result. If set to\n `False`, the transaction will be executed without returning\n the result.",
),
include: IncEx | None = Body(
default=None,
title="Include fields",
description="The fields to include in the query results.",
examples=[
["user.name", "user.email"],
{"user": ["name", "email"], "product": False},
],
),
exclude: IncEx | None = Body(
default=None,
title="Exclude fields",
description="The fields to exclude from the query results.",
examples=[
["user.password", "product.price"],
{"user": ["password"], "product": True},
],
),
filter: Annotated[
Filter | None, Depends(filter_dependency)
] = Body(
default=None,
title="Filter criteria",
description="The filter criteria to apply to the query. It is\n specified in the request body as a dictionary of field aliases\n with their corresponding filter criteria. Additionally, it can\n be specified directly in the query parameters using a dot\n notation for field aliases and tilde `~` character for filter\n criteria. For example, to filter results where the `user.name`\n field starts with `Al`, the filter criteria can be specified as\n `.user.name=like~Al*` in the query parameters.",
examples=[
".user.name=like~Al*",
".price=gt~1000",
".user.name=like~Al*&.price=gt~1000",
{
"user": {
"name": {
"operator": "like",
"value": "Al*",
}
},
"price": {"operator": "gt", "value": 1000},
},
],
),
sort: Sort | None = Query(
default=None,
title="Sort criteria",
description="The sort criteria to apply to the query. It is\n specified in the query parameters as a comma-separated list of\n field aliases with an optional prefix of a minus sign `-` for\n descending order. For example, to sort results by the\n `user.name` field in descending order, the sort criteria can be\n specified as `user.name,-price` in the query parameters.\n Additionally, the direction and nulls position can be piped\n using a colon `:` character. For example, to sort results by\n the `price` field in ascending order with nulls first, the sort\n criteria can be specified as `price:asc:nf` in the query\n parameters.",
examples=["user.name,-price", "price:asc:nf"],
),
limit: int | None = Query(
default=None,
gt=0,
title="Limit",
description="The maximum number of results to return. It is\n specified in the query parameters as an integer value. Defaults\n to the service configuration default page size if not\n specified.",
examples=[10, 20, 50],
),
offset: int | None = Query(
default=None,
ge=0,
title="Offset",
description="The number of results to skip before returning the\n results. It is specified in the query parameters as an integer\n value. Defaults to `0` if not specified.",
),
page: int | None = Query(
default=None,
gt=0,
title="Page",
description="The page number to return results for. It is\n specified in the query parameters as an integer value. Defaults\n to the first page if not specified.",
),
page_size: int | None = Query(
default=None,
gt=0,
title="Page size",
description="The number of results to return per page. It is\n specified in the query parameters as an integer value. The\n maximum page size is defined by the service configuration.\n Defaults to the service configuration default page size if not\n specified.",
),
dry_run: bool = Body(
default=False,
title="Dry-run",
description="Whether to run the transaction in dry-run mode. If\n set to `True`, the transaction will be rolled back after\n execution.",
),
) -> Any | None
Delete a collection of resource instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSessionDep
|
The async session dependency to use for the query. |
required |
selection
|
KeyList[CRUDSpec]
|
The key selection dependency to resolve the query. |
Selection()
|
return_result
|
bool
|
Whether to return the deletion result. |
Body(default=False, title='Return result', description='Whether to return the deleted result. If set to\n `False`, the transaction will be executed without returning\n the result.')
|
include
|
IncEx | None
|
The fields to include in the query results. |
Body(default=None, title='Include fields', description='The fields to include in the query results.', examples=[['user.name', 'user.email'], {'user': ['name', 'email'], 'product': False}])
|
exclude
|
IncEx | None
|
The fields to exclude from the query results. |
Body(default=None, title='Exclude fields', description='The fields to exclude from the query results.', examples=[['user.password', 'product.price'], {'user': ['password'], 'product': True}])
|
filter
|
Annotated[Filter | None, Depends(filter_dependency)]
|
The filter criteria to apply to the query. |
Body(default=None, title='Filter criteria', description='The filter criteria to apply to the query. It is\n specified in the request body as a dictionary of field aliases\n with their corresponding filter criteria. Additionally, it can\n be specified directly in the query parameters using a dot\n notation for field aliases and tilde `~` character for filter\n criteria. For example, to filter results where the `user.name`\n field starts with `Al`, the filter criteria can be specified as\n `.user.name=like~Al*` in the query parameters.', examples=['.user.name=like~Al*', '.price=gt~1000', '.user.name=like~Al*&.price=gt~1000', {'user': {'name': {'operator': 'like', 'value': 'Al*'}}, 'price': {'operator': 'gt', 'value': 1000}}])
|
sort
|
Sort | None
|
The sort criteria to apply to the query. |
Query(default=None, title='Sort criteria', description='The sort criteria to apply to the query. It is\n specified in the query parameters as a comma-separated list of\n field aliases with an optional prefix of a minus sign `-` for\n descending order. For example, to sort results by the\n `user.name` field in descending order, the sort criteria can be\n specified as `user.name,-price` in the query parameters.\n Additionally, the direction and nulls position can be piped\n using a colon `:` character. For example, to sort results by\n the `price` field in ascending order with nulls first, the sort\n criteria can be specified as `price:asc:nf` in the query\n parameters.', examples=['user.name,-price', 'price:asc:nf'])
|
limit
|
int | None
|
The maximum number of results to return. |
Query(default=None, gt=0, title='Limit', description='The maximum number of results to return. It is\n specified in the query parameters as an integer value. Defaults\n to the service configuration default page size if not\n specified.', examples=[10, 20, 50])
|
offset
|
int | None
|
The number of results to skip before returning the results. |
Query(default=None, ge=0, title='Offset', description='The number of results to skip before returning the\n results. It is specified in the query parameters as an integer\n value. Defaults to `0` if not specified.')
|
page
|
int | None
|
The page number to return results for. |
Query(default=None, gt=0, title='Page', description='The page number to return results for. It is\n specified in the query parameters as an integer value. Defaults\n to the first page if not specified.')
|
page_size
|
int | None
|
The number of results to return per page. |
Query(default=None, gt=0, title='Page size', description='The number of results to return per page. It is\n specified in the query parameters as an integer value. The\n maximum page size is defined by the service configuration.\n Defaults to the service configuration default page size if not\n specified.')
|
dry_run
|
bool
|
Whether to run the transaction in dry-run mode. |
Body(default=False, title='Dry-run', description='Whether to run the transaction in dry-run mode. If\n set to `True`, the transaction will be rolled back after\n execution.')
|
Returns:
Type | Description |
---|---|
Any | None
|
The collection of deleted resource instances or |
Any | None
|
result is disabled, i.e., |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 |
|
bind_service
bind_service(
service: BaseService,
facade: ServiceFacade | ServiceWithSpecFacade,
) -> None
Bind the service to a service facade.
It binds the service to a service facade, allowing the service to be used within the context of its facade owner.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service
|
BaseService
|
The service instance to bind to the service facade. |
required |
facade
|
ServiceFacade | ServiceWithSpecFacade
|
The service facade to bind the service to. |
required |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
copy_service
copy_service(service: BaseService) -> BaseService
Copy and unbind the service from a service facade.
It copies the service instance and unbinds it from the service facade, removing the service from the context of its current facade owner.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service
|
BaseService
|
The service instance to unbind from the service facade. |
required |
Returns:
Type | Description |
---|---|
BaseService
|
The copied service instance. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
load_service
load_service(
service: BaseService,
) -> dict[str, Callable[..., Any]] | None
Load the service implementation.
It loads the service implementation by validating the service owner and checking whether the service owner implements the service specification protocol. If the service owner is not concrete or does not implement the service specification protocol, it raises an error.
Finally, it wraps the service methods with the appropriate parameter and return annotations based on the provided specification and resource.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service
|
BaseService
|
The service instance to load. |
required |
Returns:
Type | Description |
---|---|
dict[str, Callable[..., Any]] | None
|
A dictionary of public methods of the service. |
Raises:
Type | Description |
---|---|
PlateformeError
|
If the service owner is not concrete or does not implement the service specification protocol. |
Source code in .venv/lib/python3.12/site-packages/plateforme/core/services.py
unbind_service
unbind_service(service: BaseService) -> None
Unbind the service from a service facade.
It unbinds the service from a service facade, removing the service from the context of its current facade owner.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service
|
BaseService
|
The service instance to unbind from the service facade. |
required |