Module libnova.common.api.Container
Expand source code
#!/usr/bin/env python
# coding: utf-8
import datetime
from enum import Enum
from libnova.common import api
# Define Enum structs
from libnova.common.api.Serializable import Serializable
class PermissionSource(Enum):
"""Container Permission Source
"""
INHERIT = 1
EXPLICIT = 2
class QuotaSource(Enum):
"""Container Quota Source
"""
INHERIT = 1
EXPLICIT = 2
DISABLED = 3
# Define main object structure
class Container(Serializable):
"""Platform Container
The main methods allows the interaction with the main structures related to containers hosted in the platform
"""
id: int = 0
parent: int
name: str
description: str
creator: int
checked_in_user: int
date_create: datetime.datetime
date_update: datetime.datetime
file_total: int
size_total: int
path: str
archived: bool = False
storage_id: int
container_metadata_id: int
metadata_schema_id: int
workflow_id: int
workflow_step_id: int
archival_structure_id: int
submission_area_id: int
permission_source: PermissionSource = 1
auto_check_in: bool = False
container_quota: QuotaSource = 1
container_quota_in_bytes: int
#Define main functions as "static"
def create(name, description, container_metadata_id, metadata_schema_id, workflow_id, archival_structure_id, storage_id):
"""Create a new container
Args:
name (str): The `Container` name
description (str): A description for the `Container`
container_metadata_id (int): The id of the `Container Metadata Schema`
metadata_schema_id (int): The id of the `File Metadata Schema` that will be used for all the `Files` within this `Container`
workflow_id (int): The id of the `Workflow` to use for this `Container`
archival_structure_id (int): The `Archival Structure` node id of the `Container`
storage_id (int): The id of the `Storage` to use for this `Container`
Returns:
Container: A new `Container`
"""
contaner_data = {
'name': name,
'description': description,
'container_metadata_id': container_metadata_id,
'metadata_schema_id': metadata_schema_id,
'workflow_id': workflow_id,
'archival_structure_id': archival_structure_id,
'storage_id': storage_id
}
api_driver = api.Driver.get_instance()
return api_driver.serialize(
api_driver.post(
url_segment='container',
data=contaner_data
),
Container
)
def get(id) -> Container:
"""Get an existing container
Args:
id: The id of the `Container` to retrieve
Returns:
Container: An existing `Container` if exists, None otherwise
"""
api_driver = api.Driver.get_instance()
return api_driver.serialize(
api_driver.get(
url_segment='container/' + str(id)
),
Container
)
if __name__ == "__main__":
print('This file cannot be executed directly!')
Functions
def create(name, description, container_metadata_id, metadata_schema_id, workflow_id, archival_structure_id, storage_id)
-
Create a new container
Args
name
:str
- The
Container
name description
:str
- A description for the
Container
container_metadata_id
:int
- The id of the
Container Metadata Schema
metadata_schema_id
:int
- The id of the
File Metadata Schema
that will be used for all theFiles
within thisContainer
workflow_id
:int
- The id of the
Workflow
to use for thisContainer
archival_structure_id
:int
- The
Archival Structure
node id of theContainer
storage_id
:int
- The id of the
Storage
to use for thisContainer
Returns
Expand source code
def create(name, description, container_metadata_id, metadata_schema_id, workflow_id, archival_structure_id, storage_id): """Create a new container Args: name (str): The `Container` name description (str): A description for the `Container` container_metadata_id (int): The id of the `Container Metadata Schema` metadata_schema_id (int): The id of the `File Metadata Schema` that will be used for all the `Files` within this `Container` workflow_id (int): The id of the `Workflow` to use for this `Container` archival_structure_id (int): The `Archival Structure` node id of the `Container` storage_id (int): The id of the `Storage` to use for this `Container` Returns: Container: A new `Container` """ contaner_data = { 'name': name, 'description': description, 'container_metadata_id': container_metadata_id, 'metadata_schema_id': metadata_schema_id, 'workflow_id': workflow_id, 'archival_structure_id': archival_structure_id, 'storage_id': storage_id } api_driver = api.Driver.get_instance() return api_driver.serialize( api_driver.post( url_segment='container', data=contaner_data ), Container )
def get(id) ‑> Container
-
Expand source code
def get(id) -> Container: """Get an existing container Args: id: The id of the `Container` to retrieve Returns: Container: An existing `Container` if exists, None otherwise """ api_driver = api.Driver.get_instance() return api_driver.serialize( api_driver.get( url_segment='container/' + str(id) ), Container )
Classes
class Container (**entries: dict)
-
Platform Container
The main methods allows the interaction with the main structures related to containers hosted in the platform
Expand source code
class Container(Serializable): """Platform Container The main methods allows the interaction with the main structures related to containers hosted in the platform """ id: int = 0 parent: int name: str description: str creator: int checked_in_user: int date_create: datetime.datetime date_update: datetime.datetime file_total: int size_total: int path: str archived: bool = False storage_id: int container_metadata_id: int metadata_schema_id: int workflow_id: int workflow_step_id: int archival_structure_id: int submission_area_id: int permission_source: PermissionSource = 1 auto_check_in: bool = False container_quota: QuotaSource = 1 container_quota_in_bytes: int
Ancestors
Class variables
var archival_structure_id : int
var archived : bool
var auto_check_in : bool
var checked_in_user : int
var container_metadata_id : int
var container_quota : QuotaSource
var container_quota_in_bytes : int
var creator : int
var date_create : datetime.datetime
var date_update : datetime.datetime
var description : str
var file_total : int
var id : int
var metadata_schema_id : int
var name : str
var parent : int
var path : str
var permission_source : PermissionSource
var size_total : int
var storage_id : int
var submission_area_id : int
var workflow_id : int
var workflow_step_id : int
class PermissionSource (value, names=None, *, module=None, qualname=None, type=None, start=1)
-
Container Permission Source
Expand source code
class PermissionSource(Enum): """Container Permission Source """ INHERIT = 1 EXPLICIT = 2
Ancestors
- enum.Enum
Class variables
var EXPLICIT
var INHERIT
class QuotaSource (value, names=None, *, module=None, qualname=None, type=None, start=1)
-
Container Quota Source
Expand source code
class QuotaSource(Enum): """Container Quota Source """ INHERIT = 1 EXPLICIT = 2 DISABLED = 3
Ancestors
- enum.Enum
Class variables
var DISABLED
var EXPLICIT
var INHERIT