CRUD

Take a look into the full example of Crud implementation Full CRUD example.

Abstract implementation

class py_ocpi.core.crud.Crud
abstract async create(module, role, data, *args, **kwargs)

Create an object

Parameters:
  • module (ModuleID) – The OCPI module

  • role (RoleEnum) – The role of the caller

  • data (dict) – The object details

  • auth_token – (str) The authentication token used by a third party

  • version – (VersionNumber) The version number of the caller OCPI module

  • party_id – (CiString(3)) The requested party ID

  • country_code – (CiString(2)) The requested Country code

  • token_type – (TokenType) The token type

  • command – (CommandType) The command type of the OCPP command

  • query_params – (dict) Charging profile request query params.

Returns:

The created object data

Return type:

Any

abstract async delete(module, role, id, *args, **kwargs)

Delete an object

Parameters:
  • module (ModuleID) – The OCPI module

  • role (RoleEnum) – The role of the caller

  • id – The ID of the object

  • auth_token – (str) The authentication token used by a third party

  • version – (VersionNumber) The version number of the caller OCPI module

abstract async do(module, role, action, *args, data=None, **kwargs)

Do an action (non-CRUD)

Parameters:
  • module (ModuleID) – The OCPI module

  • role (Optional[RoleEnum]) – The role of the caller

  • action (Action) – The action type

  • data (Optional[dict]) – The data required for the action

  • auth_token – (str) The authentication token used by a third party

  • version – (VersionNumber) The version number of the caller OCPI module

  • response_url – (str) Response url for actions which require sending response.

  • session – (Session) Session of charging profile action.

  • duration – (int) Length of the requested ActiveChargingProfile in seconds.

  • command – (CommandType) The command type of the OCPP command

  • (SetChargingProfile) (charging_profile) – Charging profile sent to be updated.

Returns:

The action result

Return type:

Any

abstract async get(module, role, id, *args, **kwargs)

Get an object

Parameters:
  • module (ModuleID) – The OCPI module

  • role (RoleEnum) – The role of the caller

  • id – The ID of the object

  • auth_token – (str) The authentication token used by a third party

  • version – (VersionNumber) The version number of the caller OCPI module

  • party_id – (CiString(3)) The requested party ID

  • country_code – (CiString(2)) The requested Country code

  • token_type – (TokenType) The token type

  • command – (CommandType) The command type of the OCPP command

  • command_data – Request body of command.

  • session_id – (str) Id of the charging profile corresponding session.

  • duration – (int) Length of the requested ActiveChargingProfile in seconds.

  • response_url – (str) Url where to send result of the action.

  • charging_profile – (SetChargingProfile) ChargingProfile body.

  • session_id – (str) Id of the charging profile corresponding session.

Returns:

The object data

Return type:

Any

abstract async list(module, role, filters, *args, **kwargs)

Get the list of objects

Parameters:
  • module (ModuleID) – The OCPI module

  • role (RoleEnum) – The role of the caller

  • filters (dict) – OCPI pagination filters

  • auth_token – (str) The authentication token used by a third party

  • version – (VersionNumber) The version number of the caller OCPI module

  • party_id – (CiString(3)) The requested party ID

  • country_code – (CiString(2)) The requested Country code

Returns:

Objects list, Total number of objects, if it’s the last page or not(for pagination)

Return type:

Tuple[list, int, bool]

abstract async update(module, role, data, id, *args, **kwargs)

Update an object

Parameters:
  • module (ModuleID) – The OCPI module

  • role (RoleEnum) – The role of the caller

  • data (dict) – The object details

  • id (Any) – The ID of the object

  • auth_token – (str) The authentication token used by a third party

  • version – (VersionNumber) The version number of the caller OCPI module

  • party_id – (CiString(3)) The requested party ID

  • country_code – (CiString(2)) The requested Country code

  • token_type – (TokenType) The token type

  • session_id – (str) Charging profile corresponding session id.

Returns:

The updated object data

Return type:

Any