| Channel | Revision | Published | Runs on |
|---|---|---|---|
| latest/stable | 81 | 19 Nov 2024 | |
| latest/edge | 82 | 04 Dec 2024 |
juju deploy data-platform-libs
Deploy universal operators easily with Juju, the Universal Operator Lifecycle Manager.
Platform:
charms.data_platform_libs.v1.data_interfaces
-
- Last updated 24 Nov 2025
- Revision Library version 1.3
Library to manage the relation for the data-platform products.
This V1 has been specified in https://docs.google.com/document/d/1lnuonWnoQb36RWYwfHOBwU0VClLbawpTISXIC_yNKYo, and should be backward compatible with v0 clients.
This library contains the Requires and Provides classes for handling the relation between an application and multiple managed application supported by the data-team: MySQL, Postgresql, MongoDB, Redis, Kafka, and Karapace.
Models
This library exposes basic default models that can be used in most cases. If you need more complex models, you can subclass them.
from charms.data_platform_libs.v1.data_interfaces import RequirerCommonModel, ExtraSecretStr
class ExtendedCommonModel(RequirerCommonModel):
operator_password: ExtraSecretStr
Secret groups are handled using annotated types. If you wish to add extra secret groups, please follow the following model. The string metadata represents the secret group name, and OptionalSecretStr is a TypeAlias for SecretStr | None. Finally, SecretStr represents a field validating the URI pattern secret:.*
MyGroupSecretStr = Annotated[OptionalSecretStr, Field(exclude=True, default=None), "mygroup"]
Fields not specified as OptionalSecretStr and extended with a group name in the metadata will NOT get serialised.
Requirer Charm
This library is a uniform interface to a selection of common database metadata, with added custom events that add convenience to database management, and methods to consume the application related data.
from charms.data_platform_libs.v1.data_interfaces import (
RequirerCommonModel,
RequirerDataContractV1,
ResourceCreatedEvent,
ResourceEntityCreatedEvent,
ResourceProviderModel,
ResourceRequirerEventHandler,
)
class ClientCharm(CharmBase):
# Database charm that accepts connections from application charms.
def __init__(self, *args) -> None:
super().__init__(*args)
requests = [
RequirerCommonModel(
resource="clientdb",
),
RequirerCommonModel(
resource="clientbis",
),
RequirerCommonModel(
entity_type="USER",
)
]
self.database = ResourceRequirerEventHandler(
self,"database", requests, response_model=ResourceProviderModel
)
self.framework.observe(self.database.on.resource_created, self._on_resource_created)
self.framework.observe(self.database.on.resource_entity_created, self._on_resource_entity_created)
def _on_resource_created(self, event: ResourceCreatedEvent) -> None:
# Event triggered when a new database is created.
relation_id = event.relation.id
response = event.response # This is the response model
username = event.response.username
password = event.response.password
...
def _on_resource_entity_created(self, event: ResourceCreatedEvent) -> None:
# Event triggered when a new entity is created.
...
Compared to V0, this library makes heavy use of pydantic models, and allows for
multiple requests, specified as a list.
On the Requirer side, each response will trigger one custom event for that response.
This way, it allows for more strategic events to be emitted according to the request.
As show above, the library provides some custom events to handle specific situations, which are listed below:
- resource_created: event emitted when the requested database is created.
- resource_entity_created: event emitted when the requested entity is created.
- endpoints_changed: event emitted when the read/write endpoints of the database have changed.
- read_only_endpoints_changed: event emitted when the read-only endpoints of the database
have changed. Event is not triggered if read/write endpoints changed too.
If it is needed to connect multiple database clusters to the same relation endpoint
the application charm can implement the same code as if it would connect to only
one database cluster (like the above code example).
To differentiate multiple clusters connected to the same relation endpoint
the application charm can use the name of the remote application:
```python
def _on_resource_created(self, event: ResourceCreatedEvent) -> None:
# Get the remote app name of the cluster that triggered this event
cluster = event.relation.app.name
It is also possible to provide an alias for each different database cluster/relation.
So, it is possible to differentiate the clusters in two ways.
The first is to use the remote application name, i.e., event.relation.app.name, as above.
The second way is to use different event handlers to handle each cluster events. The implementation would be something like the following code:
from charms.data_platform_libs.v1.data_interfaces import (
RequirerCommonModel,
RequirerDataContractV1,
ResourceCreatedEvent,
ResourceEntityCreatedEvent,
ResourceProviderModel,
ResourceRequirerEventHandler,
)
class ApplicationCharm(CharmBase):
# Application charm that connects to database charms.
def __init__(self, *args):
super().__init__(*args)
requests = [
RequirerCommonModel(
resource="clientdb",
),
RequirerCommonModel(
resource="clientbis",
),
]
# Define the cluster aliases and one handler for each cluster database created event.
self.database = ResourceRequirerEventHandler(
self,
relation_name="database"
relations_aliases = ["cluster1", "cluster2"],
requests=
)
self.framework.observe(
self.database.on.cluster1_resource_created, self._on_cluster1_resource_created
)
self.framework.observe(
self.database.on.cluster2_resource_created, self._on_cluster2_resource_created
)
def _on_cluster1_resource_created(self, event: ResourceCreatedEvent) -> None:
# Handle the created database on the cluster named cluster1
# Create configuration file for app
config_file = self._render_app_config_file(
event.response.username,
event.response.password,
event.response.endpoints,
)
...
def _on_cluster2_resource_created(self, event: ResourceCreatedEvent) -> None:
# Handle the created database on the cluster named cluster2
# Create configuration file for app
config_file = self._render_app_config_file(
event.response.username,
event.response.password,
event.response.endpoints,
)
...
Provider Charm
Following an example of using the ResourceRequestedEvent, in the context of the database charm code:
from charms.data_platform_libs.v1.data_interfaces import (
ResourceProviderEventHandler,
ResourceProviderModel,
ResourceRequestedEvent,
RequirerCommonModel,
)
class SampleCharm(CharmBase):
def __init__(self, *args):
super().__init__(*args)
# Charm events defined in the database provides charm library.
self.provided_database = ResourceProviderEventHandler(self, "database", RequirerCommonModel)
self.framework.observe(self.provided_database.on.resource_requested,
self._on_resource_requested)
# Database generic helper
self.database = DatabaseHelper()
def _on_resource_requested(self, event: ResourceRequestedEvent) -> None:
# Handle the event triggered by a new database requested in the relation
# Retrieve the database name using the charm library.
db_name = event.request.resource
# generate a new user credential
username = self.database.generate_user(event.request.request_id)
password = self.database.generate_password(event.request.request_id)
# set the credentials for the relation
response = ResourceProviderModel(
salt=event.request.salt,
request_id=event.request.request_id,
resource=db_name,
username=username,
password=password,
...
)
self.provided_database.set_response(event.relation.id, response)
As shown above, the library provides a custom event (resource_requested) to handle the situation when an application charm requests a new database to be created. It's preferred to subscribe to this event instead of relation changed event to avoid creating a new database when other information other than a database name is exchanged in the relation databag.
class DataInterfacesError
Description
Common ancestor for DataInterfaces related exceptions. None
class SecretError
Description
Common ancestor for Secrets related exceptions. None
class SecretAlreadyExistsError
Description
A secret that was to be added already exists. None
class SecretsUnavailableError
Description
Secrets aren't yet available for Juju version used. None
class IllegalOperationError
Description
To be used when an operation is not allowed to be performed. None
def gen_salt()
Description
Generates a consistent salt. None
def
gen_hash(
resource_name: str,
salt: str
)
Description
Generates a consistent hash based on the resource name and salt. None
def ensure_leader_for_app(f)
Description
Decorator to ensure that only leader can perform given operation. None
Methods
ensure_leader_for_app. wrapper( self )
def
get_encoded_dict(
relation: Relation,
member,
field: str
)
Description
Retrieve and decode an encoded field from relation data. None
class Diff
A tuple for storing the diff between two data mappings.
Description
added - keys that were added changed - keys that still exist but have new values deleted - key that were deleted
def
diff(
old_data,
new_data
)
Retrieves the diff of the data in the relation changed databag for v1.
Arguments
dictionary of the stored data before the event.
dictionary of the received data to compute the diff.
Returns
a Diff instance containing the added, deleted and changed keys from the event relation databag.
def resource_added(diff: Diff)
Description
Ensures that one of the aliased resources has been added. None
def
store_new_data(
relation: Relation,
component,
new_data,
short_uuid,
global_data
)
Stores the new data in the databag for diff computation.
Arguments
The relation considered to write data to
The component databag to write data to
a dictionary containing the data to write
Only present in V1, the request-id of that data to write.
request-independent, global state data to be written.
class Scope
Description
Peer relations scope. None
class RelationStatusDict
Description
Base type for dict representation of RelationStatus dataclass. None
class CachedSecret
Locally cache a secret.
Description
The data structure is precisely reusing/simulating as in the actual Secret Storage
Methods
CachedSecret. __init__( self , model: Model , component , label: str , secret_uri )
CachedSecret. meta( self )
Description
Getting cached secret meta-information. None
CachedSecret. add_secret( self , content , relation , label )
Description
Create a new secret. None
CachedSecret. get_content( self )
Description
Getting cached secret content. None
CachedSecret. set_content( self , content )
Description
Setting cached secret content. None
CachedSecret. get_info( self )
Description
Wrapper function to apply the corresponding call on the Secret object within CachedSecret if any. None
CachedSecret. remove( self )
Description
Remove secret. None
class SecretCache
Description
A data structure storing CachedSecret objects. None
Methods
SecretCache. __init__( self , model: Model , component )
SecretCache. get( self , label: str , uri )
Description
Getting a secret from Juju Secret store or cache. None
SecretCache. add( self , label: str , content , relation: Relation )
Description
Adding a secret to Juju Secret. None
SecretCache. remove( self , label: str )
Description
Remove a secret from the cache. None
class PeerModel
Description
Common Model for all peer relations. None
Methods
PeerModel. extract_secrets( self , info: ValidationInfo )
Description
Extract all secret_fields into their local field. None
PeerModel. serialize_model( self , handler: SerializerFunctionWrapHandler , info: SerializationInfo )
Description
Serializes the model writing the secrets in their respective secrets. None
PeerModel. __getitem__( self , key )
Description
Dict like access to the model. None
PeerModel. __setitem__( self , key , value )
Description
Dict like setter for the model. None
PeerModel. __delitem__( self , key )
Description
Dict like deleter for the model. None
class BaseCommonModel
Description
Embeds the logic of parsing and serializing. None
Methods
BaseCommonModel. update( self: Self , model: Self )
Description
Updates a common Model with another one. None
BaseCommonModel. extract_secrets( self , info: ValidationInfo )
Description
Extract all secret_fields into their local field. None
BaseCommonModel. serialize_model( self , handler: SerializerFunctionWrapHandler , info: SerializationInfo )
Description
Serializes the model writing the secrets in their respective secrets. None
BaseCommonModel. short_uuid( self )
Description
The request id. None
BaseCommonModel. __getitem__( self , key )
Description
Dict like access to the model. None
BaseCommonModel. __setitem__( self , key , value )
Description
Dict like setter for the model. None
BaseCommonModel. __delitem__( self , key )
Description
Dict like deleter for the model. None
class CommonModel
Common Model for both requirer and provider.
Description
request_id stores the request identifier for easier access. salt is used to create a valid request id. resource is the requested resource.
Methods
CommonModel. short_uuid( self )
Description
The request id. None
class EntityPermissionModel
Description
Entity Permissions Model. None
class RequirerCommonModel
Requirer side of the request model.
Description
extra_user_roles is used to request more roles for that user. external_node_connectivity is used to indicate that the URI should be made for external clients when True
Methods
RequirerCommonModel. validate_fields( self )
Description
Validates that no inconsistent request is being sent. None
class ProviderCommonModel
Serialized fields added to the databag.
Description
endpoints stores the endpoints exposed to that client. secret_user is a secret URI mapping to the user credentials secret_tls is a secret URI mapping to the TLS certificate secret_extra is a secret URI for all additional secrets requested.
class ResourceProviderModel
Description
Extended model including the deserialized fields. None
class RequirerDataContractV0
Description
Backward compatibility. None
Methods
RequirerDataContractV0. ensure_original_field( cls , data: Any )
Description
Ensures that we keep the original field. None
class RequirerDataContractV1
Description
The new Data Contract. None
def discriminate_on_version(payload: Any)
Description
Use the version to discriminate. None
class DataContractV0
Description
The Data contract of the response, for V0. None
class DataContractV1
Description
The Data contract of the response, for V1. None
def is_topic_value_acceptable(value)
Description
Check whether the given Kafka topic value is acceptable. None
class KafkaRequestModel
Description
Specialised model for Kafka. None
class KafkaResponseModel
Description
Kafka response model. None
class RelationStatus
Description
Base model for status propagation on charm relations. None
Methods
RelationStatus. is_informational( self )
Description
Is this an informational status? None
RelationStatus. is_transitory( self )
Description
Is this a transitory status? None
RelationStatus. is_fatal( self )
Description
Is this a fatal status, requiring removing the relation? None
class AbstractRepository
Description
Abstract repository interface. None
Methods
AbstractRepository. get_secret( self , secret_group , secret_uri , short_uuid )
Description
Gets a secret from the secret cache by uri or label. None
AbstractRepository. get_secret_field( self , field: str , secret_group: SecretGroup , short_uuid )
Description
Gets a value for a field stored in a secret group. None
AbstractRepository. get_field( self , field: str )
Description
Gets the value for one field. None
AbstractRepository. get_fields( self )
Description
Gets the values for all provided fields. None
AbstractRepository. write_field( self , field: str , value: Any )
Description
Writes the value in the field, without any secret support. None
AbstractRepository. write_fields( self , mapping )
Description
Writes the values of mapping in the fields without any secret support (keys of mapping). None
AbstractRepository. write_secret_field( self , field: str , value: Any , group: SecretGroup )
Description
Writes a secret field. None
AbstractRepository. add_secret( self , field: str , value: Any , secret_group: SecretGroup , short_uuid )
Description
Gets a value for a field stored in a secret group. None
AbstractRepository. delete_secret( self , label: str )
Description
Deletes a secret by its label. None
AbstractRepository. delete_field( self , field: str )
Description
Deletes a field. None
AbstractRepository. delete_fields( self )
Description
Deletes all the provided fields. None
AbstractRepository. delete_secret_field( self , field: str , secret_group: SecretGroup )
Description
Delete a field stored in a secret group. None
AbstractRepository. register_secret( self , secret_group: SecretGroup , short_uuid )
Description
Registers a secret using the repository. None
AbstractRepository. get_data( self )
Description
Gets the whole data. None
AbstractRepository. secret_field( self , secret_group: SecretGroup , field )
Description
Builds a secret field. None
class OpsRepository
Description
Implementation for ops repositories, with some methods left out. None
Methods
OpsRepository. __init__( self , model: Model , relation , component )
OpsRepository. get_data( self )
OpsRepository. get_field( self , field: str )
OpsRepository. get_fields( self )
OpsRepository. write_field( self , field: str , value: Any )
OpsRepository. write_fields( self , mapping )
OpsRepository. write_secret_field( self , field: str , value: Any , secret_group: SecretGroup )
OpsRepository. delete_field( self , field: str )
OpsRepository. delete_fields( self )
OpsRepository. delete_secret_field( self , field: str , secret_group: SecretGroup )
OpsRepository. register_secret( self , uri: str , secret_group: SecretGroup , short_uuid )
Registers the secret group for this relation.
Description
[MAGIC HERE] If we fetch a secret using get_secret(id=<ID>, label=<arbitraty_label>), then <arbitraty_label> will be "stuck" on the Secret object, whenever it may appear (i.e. as an event attribute, or fetched manually) on future occasions.
This will allow us to uniquely identify the secret on Provider side (typically on 'secret-changed' events), and map it to the corresponding relation.
OpsRepository. get_secret( self , secret_group , secret_uri , short_uuid )
Description
Gets a secret from the secret cache by uri or label. None
OpsRepository. get_secret_field( self , field: str , secret_group: SecretGroup , uri , short_uuid )
Description
Gets a value for a field stored in a secret group. None
OpsRepository. add_secret( self , field: str , value: Any , secret_group: SecretGroup , short_uuid )
OpsRepository. delete_secret( self , label: str )
class OpsRelationRepository
Description
Implementation of the Abstract Repository for non peer relations. None
Methods
OpsRelationRepository. secret_field( self , secret_group: SecretGroup , field )
Description
Generates the field name to store in the peer relation. None
OpsRelationRepository. get_data( self )
class OpsPeerRepository
Description
Implementation of the Ops Repository for peer relations. None
Methods
OpsPeerRepository. scope( self )
Description
Returns a scope. None
OpsPeerRepository. secret_field( self , secret_group: SecretGroup , field )
Description
Generates the field name to store in the peer relation. None
class OpsPeerUnitRepository
Description
Implementation for a unit. None
Methods
OpsPeerUnitRepository. __init__( self , model: Model , relation , component: Unit )
class OpsOtherPeerUnitRepository
Description
Implementation for a remote unit. None
Methods
OpsOtherPeerUnitRepository. __init__( self , model: Model , relation , component: Unit )
OpsOtherPeerUnitRepository. write_field( self , field: str , value: Any )
OpsOtherPeerUnitRepository. write_fields( self , mapping )
OpsOtherPeerUnitRepository. add_secret( self , field: str , value: Any , secret_group: SecretGroup , short_uuid )
OpsOtherPeerUnitRepository. delete_field( self , field: str )
OpsOtherPeerUnitRepository. delete_fields( self )
OpsOtherPeerUnitRepository. delete_secret_field( self , field: str , secret_group: SecretGroup )
class RepositoryInterface
Description
Repository builder. None
Methods
RepositoryInterface. __init__( self , model: Model , relation_name: str , component , repository_type , data_model )
RepositoryInterface. relations( self )
Description
The list of Relation instances associated with this relation name. None
RepositoryInterface. repository( self , relation_id: int , component )
Description
Returns a repository for the relation. None
RepositoryInterface. build_model( self , relation_id: int , model , component )
RepositoryInterface. build_model( self , relation_id: int , model , component )
RepositoryInterface. build_model( self , relation_id: int , model , component )
RepositoryInterface. build_model( self , relation_id: int , model , component )
RepositoryInterface. build_model( self , relation_id: int , model , component )
Description
Builds a model using the repository for that relation. None
RepositoryInterface. write_model( self , relation_id: int , model: BaseModel , context )
Description
Writes the model using the repository. None
class OpsRelationRepositoryInterface
Description
Specialised Interface to build repositories for app peer relations. None
Methods
OpsRelationRepositoryInterface. __init__( self , model: Model , relation_name: str , data_model )
class OpsPeerRepositoryInterface
Description
Specialised Interface to build repositories for app peer relations. None
Methods
OpsPeerRepositoryInterface. __init__( self , model: Model , relation_name: str , data_model )
class OpsPeerUnitRepositoryInterface
Description
Specialised Interface to build repositories for this unit peer relations. None
Methods
OpsPeerUnitRepositoryInterface. __init__( self , model: Model , relation_name: str , data_model )
class OpsOtherPeerUnitRepositoryInterface
Description
Specialised Interface to build repositories for another unit peer relations. None
Methods
OpsOtherPeerUnitRepositoryInterface. __init__( self , model: Model , relation_name: str , unit: Unit , data_model )
def
build_model(
repository: AbstractRepository,
model
)
Description
Builds a common model using the provided repository and provided model structure. None
def
write_model(
repository: AbstractRepository,
model: BaseModel,
context
)
Description
Writes the data stored in the model using the repository object. None
class ResourceProviderEvent
Resource requested event.
Description
Contains the request that should be handled.
fields to serialize: relation, app, unit, request
Methods
ResourceProviderEvent. __init__( self , handle: Handle , relation: Relation , app , unit , request: TRequirerCommonModel )
ResourceProviderEvent. snapshot( self )
Description
Save the event information. None
ResourceProviderEvent. restore( self , snapshot )
Description
Restore event information. None
class ResourceRequestedEvent
Description
Resource requested event. None
class ResourceEntityRequestedEvent
Description
Resource Entity requested event. None
class ResourceEntityPermissionsChangedEvent
Description
Resource entity permissions changed event. None
class MtlsCertUpdatedEvent
Description
Resource entity permissions changed event. None
Methods
MtlsCertUpdatedEvent. __init__( self , handle: Handle , relation: Relation , app , unit , request: TRequirerCommonModel , old_mtls_cert )
MtlsCertUpdatedEvent. snapshot( self )
Description
Return a snapshot of the event. None
MtlsCertUpdatedEvent. restore( self , snapshot )
Description
Restore the event from a snapshot. None
class BulkResourcesRequestedEvent
Resource requested event.
Description
Contains the request that should be handled.
fields to serialize: relation, app, unit, request
Methods
BulkResourcesRequestedEvent. __init__( self , handle: Handle , relation: Relation , app , unit , requests )
BulkResourcesRequestedEvent. snapshot( self )
Description
Save the event information. None
BulkResourcesRequestedEvent. restore( self , snapshot )
Description
Restore event information. None
class ResourceProvidesEvents
Database events.
Description
This class defines the events that the database can emit.
class ResourceRequirerEvent
Resource created/changed event.
Description
Contains the request that should be handled.
fields to serialize: relation, app, unit, response
Methods
ResourceRequirerEvent. __init__( self , handle: Handle , relation: Relation , app , unit , response: TResourceProviderModel )
ResourceRequirerEvent. snapshot( self )
Description
Save the event information. None
ResourceRequirerEvent. restore( self , snapshot: dict )
Description
Restore event information. None
class ResourceCreatedEvent
Description
Resource has been created. None
class ResourceEntityCreatedEvent
Description
Resource entity has been created. None
class ResourceEndpointsChangedEvent
Description
Read/Write endpoints are changed. None
class ResourceReadOnlyEndpointsChangedEvent
Description
Read-only endpoints are changed. None
class AuthenticationUpdatedEvent
Description
Authentication was updated for a user. None
class StatusEventBase
Description
Base class for relation status change events. None
Methods
StatusEventBase. __init__( self , handle: Handle , relation: Relation , status: RelationStatus , app , unit )
StatusEventBase. snapshot( self )
Description
Return a snapshot of the event. None
StatusEventBase. restore( self , snapshot: dict )
Description
Restore the event from a snapshot. None
StatusEventBase. active_statuses( self )
Description
Returns a list of all currently active statuses on this relation. None
class StatusRaisedEvent
Description
Event emitted on the requirer when a new status is being raised by the provider on relation. None
class StatusResolvedEvent
Description
Event emitted on the requirer when a status is marked as resolved by the provider on relation. None
class ResourceRequiresEvents
Database events.
Description
This class defines the events that the database can emit.
class EventHandlers
Description
Requires-side of the relation. None
Methods
EventHandlers. __init__( self , charm: CharmBase , relation_name: str , unique_key: str )
Description
Manager of base client relations. None
EventHandlers. relations( self )
Description
Shortcut to get access to the relations. None
EventHandlers. get_remote_unit( self , relation: Relation )
Description
Gets the remote unit in the relation. None
EventHandlers. get_statuses( self , relation_id: int )
Return all currently active statuses on this relation. Can only be called on leader units.
Arguments
the identifier for a particular relation.
Returns
A mapping of status code to RelationStatus instances.
EventHandlers. compute_diff( self , relation: Relation , request , repository , store: bool )
Description
Computes, stores and returns a diff for that request. None
class ResourceProviderEventHandler
Description
Event Handler for resource provider. None
Methods
ResourceProviderEventHandler. __init__( self , charm: CharmBase , relation_name: str , request_model , unique_key: str , mtls_enabled: bool , bulk_event: bool , status_schema_path: OptionalPathLike )
Builds a resource provider event handler.
Arguments
The charm.
The relation name this event handler is listening to.
The request model that is expected to be received.
An optional unique key for that object.
If True, means the server supports MTLS integration.
If this is true, only one event will be emitted with all requests in the case of a v1 requirer.
Path to the JSON file defining status/error codes and their definitions.
ResourceProviderEventHandler. set_response( self , relation_id: int , response: ResourceProviderModel )
Sets a response in the databag.
Arguments
The specific relation id for that event.
The response to write in the databag.
Description
This function will react accordingly to the version number. If the version number is v0, then we write the data directly in the databag. If the version number is v1, then we write the data in the list of responses.
/!\ This function updates a response if it was already present in the databag!
ResourceProviderEventHandler. set_responses( self , relation_id: int , responses )
Sets a list of responses in the databag.
Arguments
The specific relation id for that event.
The response to write in the databag.
Description
This function will react accordingly to the version number. If the version number is v0, then we write the data directly in the databag. If the version number is v1, then we write the data in the list of responses.
/!\ This function updates a response if it was already present in the databag!
ResourceProviderEventHandler. requests( self , relation: Relation )
Description
Returns the list of requests that we got. None
ResourceProviderEventHandler. responses( self , relation: Relation , model )
Description
Returns the list of responses that we currently have. None
ResourceProviderEventHandler. raise_status( self , relation_id: int , status: int )
ResourceProviderEventHandler. raise_status( self , relation_id: int , status: RelationStatusDict )
ResourceProviderEventHandler. raise_status( self , relation_id: int , status: RelationStatus )
ResourceProviderEventHandler. raise_status( self , relation_id: int , status )
Raise a status on the relation. Can only be called on leader units.
Arguments
the identifier for a particular relation.
A representation of the status being raised, which could be either a RelationStatus, an appropriate dict, or the numeric status code.
ResourceProviderEventHandler. resolve_status( self , relation_id: int , status_code: int )
Set a previously raised status as resolved.
Arguments
the identifier for a particular relation.
the numeric code of the resolved status.
ResourceProviderEventHandler. clear_statuses( self , relation_id: int )
Clear all previously raised statuses.
Arguments
the identifier for a particular relation.
class ResourceRequirerEventHandler
Description
Event Handler for resource requirer. None
Methods
ResourceRequirerEventHandler. __init__( self , charm: CharmBase , relation_name: str , requests , response_model , unique_key: str , relation_aliases )
ResourceRequirerEventHandler. is_resource_created( self , rel_id: int , request_id: str , model )
Checks if a resource has been created or not.
Arguments
The relation id to check.
The specific request id to check.
An optional model to use (for performances).
ResourceRequirerEventHandler. are_all_resources_created( self , rel_id: int )
Checks that all resources have been created for a relation.
Arguments
The relation id to check.
ResourceRequirerEventHandler. is_postgresql_plugin_enabled( self , plugin: str , relation_index: int )
Returns whether a plugin is enabled in the database.
Arguments
name of the plugin to check.
Optional index to check the database (default: 0 - first relation).