Storage Configuration

Models

class wrapica.storage_configuration.ProjectToStorageMappingDictModel

Bases: TypedDict

id: str
name: str
prefix: NotRequired[str]
storageConfigurationId: str
class wrapica.storage_configuration.StorageConfigurationObjectModel

Bases: TypedDict

bucketName: str
id: str
keyPrefix: str
storageCredentialId: str

Functions

wrapica.storage_configuration.convert_icav2_uri_to_s3_uri(icav2_uri)

Convert ICAv2 URI to S3 URI

Parameters:

icav2_uri (str) – The ICAv2 URI to convert, expected to be in the format icav2://{project_id}/{path/to/data_obj}

Returns:

The corresponding S3 URI, in the format s3://{bucket_name}/{key_prefix}/{path/to/data_obj}

Return type:

str

wrapica.storage_configuration.convert_project_data_obj_to_s3_uri(project_data_obj)

Convert a ProjectData object to an S3 URI, this will use the project id and path of the ProjectData object to determine the corresponding S3 URI

Parameters:

project_data_obj (ProjectData) – The ProjectData object to convert to an S3 URI

Returns:

The corresponding S3 URI, in the format s3://{bucket_name}/{key_prefix}/{path/to/data_obj}

Return type:

str

wrapica.storage_configuration.convert_s3_uri_to_icav2_uri(s3_uri)

Convert S3 URI to ICAv2 URI

Parameters:

s3_uri (str) – The S3 URI to convert, expected to be in the format s3://{bucket_name}/{key_prefix}/{path/to/data_obj}

Returns:

The corresponding ICAv2 URI, in the format icav2://{project_id}/{path/to/data_obj}

Return type:

str

wrapica.storage_configuration.convert_s3_uri_to_project_data_obj(s3_uri, create_data_if_not_found=False)

Convert an S3 URI to a ProjectData object, this will use the project id and path of the S3 URI to determine the corresponding ProjectData object

Parameters:
  • s3_uri (str) – The S3 URI to convert, expected to be in the format s3://{bucket_name}/{key_prefix}/{path/to/data_obj}

  • create_data_if_not_found (bool) – If true, create the data if it cannot be found, this is only applicable to paths or uris, if the data cannot be found and this parameter is false, an error will be raised

Returns:

The corresponding ProjectData object

Return type:

ProjectData

wrapica.storage_configuration.get_project_id_by_s3_key_prefix(s3_key_prefix)

Get the project id by the s3 key prefix

Parameters:

s3_key_prefix (str) – The s3 key prefix

Returns:

The project id, or None if no project id can be found for this

Return type:

Optional[str]

wrapica.storage_configuration.get_project_to_storage_configuration_mapping_list()

Get the project to storage configuration mapping list, this will first check if the list has already been set, if not it will set the list using the _set_project_to_storage_configuration_mapping function The project to storage configuration mapping list is expected to be a list of projects with the following format: - id: str - name: str - storageConfigurationId: str - prefix: Optional[str]

Returns:

The project to storage configuration mapping list

Return type:

List[ProjectToStorageMappingDictModel]

wrapica.storage_configuration.get_s3_key_prefix_by_project_id(project_id)

Get the s3 key prefix for a project id, this is the root s3 key prefix that is used for this project, including any project specific subfolder if they have a self managed storage configuration

Parameters:

project_id (Union[UUID, str]) – The project id

Returns:

The s3 key prefix for this project, or None if no s3 key prefix can be found for this project id

Return type:

Optional[str]

wrapica.storage_configuration.get_storage_configuration_list()

Get the storage configuration list, this will first check if the list has already been set, if not it will set the list using the _set_storage_configuration_list function

The storage configuration list is expected to be a list of storage configurations with the following format: - id: str - bucketName: str - keyPrefix: str

Returns:

The storage configuration list

Return type:

List[StorageConfigurationObjectModel]

wrapica.storage_configuration.unpack_s3_uri(uri)

Unpack an S3 URI into the project id and path, this will use the project id and path of the S3 URI to determine the corresponding project id and path

Parameters:

uri (str) – The S3 URI to unpack, expected to be in the format s3://{bucket_name}/{key_prefix}/{path/to/data_obj}

Returns:

A tuple of the project id and path, where the project id is the id of the project that this S3 URI belongs to, and the path is the path to the data object within the project

Return type:

Tuple[str, str]