agency.api
Attributes
Classes
An API endpoint. |
|
An API endpoint. |
|
An API endpoint. |
Functions
|
Applies filters for several 'updated' comparisons. |
|
|
|
Returns the iso format of the modified or created field of item. |
Module Contents
- agency.api.filter_for_updated[T](filter_operation: str, filter_value: str | None, result: T) T[source]
Applies filters for several ‘updated’ comparisons. Refer to UPDATE_FILTER_PARAMS for all filter keywords.
- Parameters:
filter_operation – the updated filter operation to be applied. For allowed filters refer to UPDATE_FILTER_PARAMS
filter_value – the updated filter value to filter for
result – the results to apply the filters on
- Returns:
filter result
- class agency.api.ApisMixin[source]
-
- property agency_api: AgencyApiEndpoint[source]
- property person_api: PersonApiEndpoint[source]
- property membership_api: MembershipApiEndpoint[source]
- agency.api.get_modified_iso_format(item: onegov.core.orm.mixins.TimestampMixin) str[source]
Returns the iso format of the modified or created field of item.
- Parameters:
item – db item e.g. agency, people, membership
- Returns:
str iso representation of item last modification
- class agency.api.PersonApiEndpoint(request: onegov.core.request.CoreRequest, extra_parameters: dict[str, list[str]] | None = None, page: int | None = None)[source]
Bases:
onegov.api.ApiEndpoint[onegov.agency.models.ExtendedPerson],ApisMixinAn API endpoint.
API endpoints wrap collection and do some filter mapping.
To add a new endpoint, inherit from this class and provide the missing functions and properties at the bottom. Note that the collection is expected to be to provide the functionality of
onegov.core.collection.Pagination.- filters[source]
A mapping of the available filter params to their corresponding description or a collection of possible values. If possible values are specified it is assumed that the filter can be specfied multiple times.
The description is optional and should only be used for non-trivial filters that don’t just accept arbitrary strings.
- property collection: onegov.agency.collections.ExtendedPersonCollection[source]
Return an instance of the collection with filters and page set.
- item_data(item: onegov.agency.models.ExtendedPerson) dict[str, Any][source]
Return the data properties of the collection item as a dictionary.
For example:
{ 'name': 'Paul', 'age': 40 }
- item_links(item: onegov.agency.models.ExtendedPerson) dict[str, Any][source]
Return the link properties of the collection item as a dictionary. Links can either be string or a linkable object.
For example:
{ 'website': 'https://onegov.ch', 'friends': FriendsApiEndpoint(app).for_item(paul), 'home': ApiEndpointCollection(app) }
- class agency.api.AgencyApiEndpoint(request: onegov.core.request.CoreRequest, extra_parameters: dict[str, list[str]] | None = None, page: int | None = None)[source]
Bases:
onegov.api.ApiEndpoint[onegov.agency.models.ExtendedAgency],ApisMixinAn API endpoint.
API endpoints wrap collection and do some filter mapping.
To add a new endpoint, inherit from this class and provide the missing functions and properties at the bottom. Note that the collection is expected to be to provide the functionality of
onegov.core.collection.Pagination.- filters[source]
A mapping of the available filter params to their corresponding description or a collection of possible values. If possible values are specified it is assumed that the filter can be specfied multiple times.
The description is optional and should only be used for non-trivial filters that don’t just accept arbitrary strings.
- property collection: onegov.agency.collections.PaginatedAgencyCollection[source]
Return an instance of the collection with filters and page set.
- item_data(item: onegov.agency.models.ExtendedAgency) dict[str, Any][source]
Return the data properties of the collection item as a dictionary.
For example:
{ 'name': 'Paul', 'age': 40 }
- item_links(item: onegov.agency.models.ExtendedAgency) dict[str, Any][source]
Return the link properties of the collection item as a dictionary. Links can either be string or a linkable object.
For example:
{ 'website': 'https://onegov.ch', 'friends': FriendsApiEndpoint(app).for_item(paul), 'home': ApiEndpointCollection(app) }
- class agency.api.MembershipApiEndpoint(request: onegov.core.request.CoreRequest, extra_parameters: dict[str, list[str]] | None = None, page: int | None = None)[source]
Bases:
onegov.api.ApiEndpoint[onegov.agency.models.ExtendedAgencyMembership],ApisMixinAn API endpoint.
API endpoints wrap collection and do some filter mapping.
To add a new endpoint, inherit from this class and provide the missing functions and properties at the bottom. Note that the collection is expected to be to provide the functionality of
onegov.core.collection.Pagination.- filters[source]
A mapping of the available filter params to their corresponding description or a collection of possible values. If possible values are specified it is assumed that the filter can be specfied multiple times.
The description is optional and should only be used for non-trivial filters that don’t just accept arbitrary strings.
- property collection: onegov.agency.collections.PaginatedMembershipCollection[source]
Return an instance of the collection with filters and page set.
- item_data(item: onegov.agency.models.ExtendedAgencyMembership) dict[str, Any][source]
Return the data properties of the collection item as a dictionary.
For example:
{ 'name': 'Paul', 'age': 40 }
- item_links(item: onegov.agency.models.ExtendedAgencyMembership) dict[str, Any][source]
Return the link properties of the collection item as a dictionary. Links can either be string or a linkable object.
For example:
{ 'website': 'https://onegov.ch', 'friends': FriendsApiEndpoint(app).for_item(paul), 'home': ApiEndpointCollection(app) }