provenaclient.clients.registry_client

Created Date: Thursday June 6th 2024 +1000 Author: Peter Baker —– Last Modified: Thursday June 6th 2024 1:39:55 pm +1000 Modified By: Peter Baker —– Description: Incomplete Registry API L2 Client. —– HISTORY: Date By Comments ———- — ———————————————————

28-06-2024 | Parth Kulkarni | Completion of L2 Interface of Registry with General, Admin and Other endpoints. 18-06-2024 | Peter Baker | Initial structure setup to help dispatch into the various sub types in the L3.

Classes

GenericRegistryEndpoints

str(object='') -> str

RegistryAdminEndpoints

str(object='') -> str

RegistryAdminClient

This class interface just captures that the client has an instantiated auth

RegistryGeneralClient

This class interface just captures that the client has an instantiated auth

RegistryClient

This class interface just captures that the client has an instantiated auth

Module Contents

class provenaclient.clients.registry_client.GenericRegistryEndpoints[source]

Bases: str, ProvenaInterfaces.RegistryAPI.Enum

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

GET_HEALTH_CHECK = '/'
GET_CHECK_ACCESS_CHECK_ADMIN_ACCESS = '/check-access/check-admin-access'
GET_CHECK_ACCESS_CHECK_GENERAL_ACCESS = '/check-access/check-general-access'
GET_CHECK_ACCESS_CHECK_READ_ACCESS = '/check-access/check-read-access'
GET_CHECK_ACCESS_CHECK_WRITE_ACCESS = '/check-access/check-write-access'
GET_REGISTRY_GENERAL_ABOUT_VERSION = '/registry/general/about/version'
GET_REGISTRY_GENERAL_FETCH = '/registry/general/fetch'
POST_REGISTRY_GENERAL_LIST = '/registry/general/list'
class provenaclient.clients.registry_client.RegistryAdminEndpoints[source]

Bases: str, ProvenaInterfaces.RegistryAPI.Enum

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

GET_ADMIN_CONFIG = '/admin/config'
GET_ADMIN_EXPORT = '/admin/export'
GET_ADMIN_SENTRY_DEBUG = '/admin/sentry-debug'
POST_ADMIN_IMPORT = '/admin/import'
POST_ADMIN_RESTORE_FROM_TABLE = '/admin/restore_from_table'
class provenaclient.clients.registry_client.RegistryAdminClient(auth: provenaclient.clients.client_helpers.AuthManager, config: provenaclient.clients.client_helpers.Config)[source]

Bases: provenaclient.clients.client_helpers.ClientService

This class interface just captures that the client has an instantiated auth manager which allows for helper functions abstracted for L2 clients.

_auth
_config
_build_endpoint(endpoint: RegistryAdminEndpoints) str[source]
_build_subtype_endpoint(action: provenaclient.utils.registry_endpoints.RegistryAction, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) str[source]
async export_items() ProvenaInterfaces.RegistryAPI.RegistryExportResponse[source]

Exports all items from the registry.

Returns:

The response containing the exported items.

Return type:

RegistryExportResponse

async import_items(registry_import_request: ProvenaInterfaces.RegistryAPI.RegistryImportRequest) ProvenaInterfaces.RegistryAPI.RegistryImportResponse[source]

Imports items into the registry.

Parameters:

registry_import_request (RegistryImportRequest) – The import request containing the items to import.

Returns:

The response containing the result of the import operation.

Return type:

RegistryImportResponse

async restore_items_from_dynamo_table(restore_request: ProvenaInterfaces.RegistryAPI.RegistryRestoreRequest) ProvenaInterfaces.RegistryAPI.RegistryImportResponse[source]

Restores items from a DynamoDB table into the registry.

Parameters:

restore_request (RegistryRestoreRequest) – The restore request containing the details for restoration.

Returns:

The response containing the result of the restore operation.

Return type:

RegistryImportResponse

async generate_config_file(required_only: bool) str[source]

Generates a nicely formatted .env file of the current required/non-supplied properties.

Used to quickly bootstrap a local environment or to understand currently deployed API.

Parameters:

required_only (bool) – Whether to include only required properties. By default True.

Returns:

The generated .env file content.

Return type:

str

async delete_item(id: str, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) ProvenaInterfaces.RegistryAPI.StatusResponse[source]

Deletes an item from the registry.

Parameters:
  • id (str) – The ID of the item to delete.

  • item_subtype (ItemSubType) – The subtype of the item to delete.

Returns:

The status response indicating the result of the deletion.

Return type:

StatusResponse

class provenaclient.clients.registry_client.RegistryGeneralClient(auth: provenaclient.clients.client_helpers.AuthManager, config: provenaclient.clients.client_helpers.Config)[source]

Bases: provenaclient.clients.client_helpers.ClientService

This class interface just captures that the client has an instantiated auth manager which allows for helper functions abstracted for L2 clients.

_auth
_config
_build_subtype_endpoint(action: provenaclient.utils.registry_endpoints.RegistryAction, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) str[source]
_build_general_endpoint(endpoint: GenericRegistryEndpoints) str[source]
async list_general_registry_items(general_list_request: ProvenaInterfaces.RegistryAPI.GeneralListRequest) ProvenaInterfaces.RegistryAPI.PaginatedListResponse[source]

Lists general registry items based on filter criteria.

Parameters:

general_list_request (GeneralListRequest) – The request containing filter and sort criteria.

Returns:

The response containing the paginated list of registry items.

Return type:

PaginatedListResponse

async general_fetch_item(id: str) ProvenaInterfaces.RegistryAPI.UntypedFetchResponse[source]

Fetches a general item from the registry.

Parameters:

id (str) – The ID of the item to fetch.

Returns:

The fetch response containing the item details.

Return type:

UntypedFetchResponse

async get_current_provena_version() ProvenaInterfaces.RegistryAPI.VersionResponse[source]

Gets the current Provena version.

Returns:

The response containing the current Provena version.

Return type:

VersionResponse

class provenaclient.clients.registry_client.RegistryClient(auth: provenaclient.clients.client_helpers.AuthManager, config: provenaclient.clients.client_helpers.Config)[source]

Bases: provenaclient.clients.client_helpers.ClientService

This class interface just captures that the client has an instantiated auth manager which allows for helper functions abstracted for L2 clients.

admin: RegistryAdminClient
general: RegistryGeneralClient
_auth
_config
_build_subtype_endpoint(action: provenaclient.utils.registry_endpoints.RegistryAction, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) str[source]
_build_general_endpoint(endpoint: GenericRegistryEndpoints) str[source]
async get_health_check() provenaclient.models.general.HealthCheckResponse[source]

Health check the API

Returns:

Response

Return type:

HealthCheckResponse

async fetch_item(id: str, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType, fetch_response_model: ProvenaInterfaces.RegistryAPI.Type[provenaclient.clients.client_helpers.BaseModelType], seed_allowed: ProvenaInterfaces.RegistryAPI.Optional[bool] = None) provenaclient.clients.client_helpers.BaseModelType[source]

Ascertains the correct endpoint based on the subtype provided, then runs the fetch operation, parsing the data as the specified model.

Parameters:
  • id (str) – The id of the item to fetch.

  • item_subtype (ItemSubType) – The subtype of the item to fetch.

  • fetch_response_model (Type[BaseModelType]) – The response pydantic model to parse as e.g. OrganisationFetchResponse

  • seed_allowed (Optional[bool], optional) – Should the endpoint throw an error if the item is a seed item? Defaults to None.

Returns:

The fetch response parsed as the specified model.

Return type:

BaseModelType

async update_item(id: str, reason: ProvenaInterfaces.RegistryAPI.Optional[str], item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType, domain_info: ProvenaInterfaces.RegistryAPI.DomainInfoBase, update_response_model: ProvenaInterfaces.RegistryAPI.Type[provenaclient.clients.client_helpers.BaseModelType]) provenaclient.clients.client_helpers.BaseModelType[source]

Ascertains the correct endpoint then runs the update operation on an existing item by providing new domain info.

Parameters:
  • id (str) – The id of item to update.

  • reason (Optional[str]) – The reason for updating, if any

  • item_subtype (ItemSubType) – The subtype to update

  • domain_info (DomainInfoBase) – The domain info to replace existing item with

  • update_response_model (Type[BaseModelType]) – The response model to parse e.g. StatusResponse

Returns:

The response model parsed

Return type:

BaseModelType

async list_items(list_items_payload: ProvenaInterfaces.RegistryAPI.GeneralListRequest, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType, update_model_response: ProvenaInterfaces.RegistryAPI.Type[provenaclient.clients.client_helpers.BaseModelType]) provenaclient.clients.client_helpers.BaseModelType[source]

Lists items within the registry based on filter criteria.

Parameters:
  • list_items_payload (GeneralListRequest) – The request containing filter and sort criteria.

  • item_subtype (ItemSubType) – The subtype of the items to list.

  • update_model_response (Type[BaseModelType]) – The response model to parse.

Returns:

The response containing the list of items.

Return type:

BaseModelType

async seed_item(item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType, seed_model_response: ProvenaInterfaces.RegistryAPI.Type[provenaclient.clients.client_helpers.BaseModelType]) provenaclient.clients.client_helpers.BaseModelType[source]

Seeds an item in the registry.

Parameters:
  • item_subtype (ItemSubType) – The subtype of the item to seed.

  • seed_model_response (Type[BaseModelType]) – The response model to parse.

Returns:

The response containing the details of the seeded item.

Return type:

BaseModelType

async revert_item(revert_request: ProvenaInterfaces.RegistryAPI.ItemRevertRequest, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) ProvenaInterfaces.RegistryAPI.ItemRevertResponse[source]

Reverts an item in the registry.

Parameters:
  • revert_request (ItemRevertRequest) – The revert request.

  • item_subtype (ItemSubType) – The subtype of the item to revert.

Returns:

The revert response.

Return type:

ItemRevertResponse

async create_item(create_item_request: ProvenaInterfaces.RegistryAPI.DomainInfoBase, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType, create_response_model: ProvenaInterfaces.RegistryAPI.Type[provenaclient.clients.client_helpers.BaseModelType]) provenaclient.clients.client_helpers.BaseModelType[source]

Creates an item in the registry.

Parameters:
  • create_item_request (DomainInfoBase) – The domain information required to create the item.

  • item_subtype (ItemSubType) – The subtype of the item to create.

  • create_response_model (Type[BaseModelType]) – The response model to parse.

Returns:

The response containing the details of the created item.

Return type:

BaseModelType

async get_schema(item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) ProvenaInterfaces.RegistryAPI.JsonSchemaResponse[source]

Gets the schema for the item subtype.

Parameters:

item_subtype (ItemSubType) – The subtype of the item to get the schema for.

Returns:

The JSON schema response.

Return type:

JsonSchemaResponse

async validate_item(validate_request: ProvenaInterfaces.RegistryAPI.DomainInfoBase, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) ProvenaInterfaces.RegistryAPI.StatusResponse[source]

Validates an item in the registry.

Parameters:
  • validate_request (DomainInfoBase) – The domain information of the item to be validated.

  • item_subtype (ItemSubType) – The subtype of the item to validate.

Returns:

The status response indicating the result of the validation.

Return type:

StatusResponse

async evaluate_auth_access(id: str, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) ProvenaInterfaces.RegistryAPI.DescribeAccessResponse[source]

Evaluates the auth access for an item.

Parameters:
  • id (str) – The ID of the item to evaluate auth access for.

  • item_subtype (ItemSubType) – The subtype of the item to evaluate auth access for.

Returns:

The describe access response.

Return type:

DescribeAccessResponse

async get_auth_configuration(id: str, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) ProvenaInterfaces.RegistryAPI.AccessSettings[source]

Gets the auth configuration for an item.

Parameters:
  • id (str) – The ID of the item to get auth configuration for.

  • item_subtype (ItemSubType) – The subtype of the item to get auth configuration for.

Returns:

The access settings.

Return type:

AccessSettings

async modify_auth_configuration(id: str, auth_change_request: ProvenaInterfaces.RegistryAPI.AccessSettings, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) ProvenaInterfaces.RegistryAPI.StatusResponse[source]

Modifies the auth configuration for an item.

Parameters:
  • id (str) – The ID of the item to modify auth configuration for.

  • auth_change_request (AccessSettings) – The auth change request.

  • item_subtype (ItemSubType) – The subtype of the item to modify auth configuration for.

Returns:

The status response.

Return type:

StatusResponse

async get_auth_roles(item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) ProvenaInterfaces.RegistryAPI.AuthRolesResponse[source]

Gets the auth roles for the item subtype.

Parameters:

item_subtype (ItemSubType) – The subtype of the item to get auth roles for.

Returns:

The auth roles response.

Return type:

AuthRolesResponse

async lock_resource(lock_resource_request: ProvenaInterfaces.RegistryAPI.LockChangeRequest, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) ProvenaInterfaces.RegistryAPI.StatusResponse[source]

Locks a resource in the registry.

Parameters:
  • lock_resource_request (LockChangeRequest) – The lock resource request.

  • item_subtype (ItemSubType) – The subtype of the resource to lock.

Returns:

The status response.

Return type:

StatusResponse

async unlock_resource(unlock_resource_request: ProvenaInterfaces.RegistryAPI.LockChangeRequest, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) ProvenaInterfaces.RegistryAPI.StatusResponse[source]

Unlocks a resource in the registry.

Parameters:
  • unlock_resource_request (LockChangeRequest) – The unlock resource request.

  • item_subtype (ItemSubType) – The subtype of the resource to unlock.

Returns:

The status response.

Return type:

StatusResponse

async get_lock_history(handle_id: str, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) ProvenaInterfaces.RegistryAPI.LockHistoryResponse[source]

Gets the lock history for an item.

Parameters:
  • handle_id (str) – The handle ID of the item to get lock history for.

  • item_subtype (ItemSubType) – The subtype of the item to get lock history for.

Returns:

The lock history response.

Return type:

LockHistoryResponse

async get_lock_status(id: str, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) ProvenaInterfaces.RegistryAPI.LockStatusResponse[source]

Gets the lock status for an item.

Parameters:
  • id (str) – The item ID.

  • item_subtype (ItemSubType) – The subtype of the item to get lock status for.

Returns:

The lock status response.

Return type:

LockStatusResponse

async version(version_request: ProvenaInterfaces.RegistryAPI.VersionRequest, item_subtype: ProvenaInterfaces.RegistryAPI.ItemSubType) ProvenaInterfaces.RegistryAPI.VersionResponse[source]

Versions an item in the registry.

Parameters:
  • version_request (VersionRequest) – The version request containing the version details.

  • item_subtype (ItemSubType) – The subtype of the item to version.

Returns:

The version response.

Return type:

VersionResponse