Module libnova.common.api.ObjectMetadataSchema
Expand source code
#!/usr/bin/env python
# coding: utf-8
import datetime
from enum import Enum
from libnova.common import api
from libnova.common.api.Serializable import Serializable
# Define Enum structs
class ObjectMetadataSchemaDescriptorDataType(Enum):
"""Object Metadata Schema Descriptor Data Type
"""
STRING = 1
LONGSTRING = 2
NUMBER = 3
DATE = 4
BOOL = 5
LINK_FIELDS = 6
ENUM = 7
OA_COLLECTION = 8
LS_AREA = 9
# Define main object structure
class ObjectMetadataSchema(Serializable):
"""Platform Object Metadata Schema
The main methods allows the interaction with the main structures related to Object Metadata Schemas hosted in the platform
"""
id: int = 0
name: str
description: str
creator: int
class ObjectMetadataSchemaDescriptor(Serializable):
"""Platform Object Metadata Schema Descriptor
The main methods allows the interaction with the main structures related to Object Metadata Schema Descriptors hosted in the platform
"""
id: int = 0
name: str
description: str = ''
iecode: str
iecode_normalized: str = ''
creator: int = 1
metadata_schema_id: int
metadata_schema_category_id: int = 1
data_type: ObjectMetadataSchemaDescriptorDataType = 1
index: int = 0
class ObjectMetadataSchemaDescriptorCategory(Serializable):
"""Platform Object Metadata Schema Descriptor Category
The main methods allows the interaction with the main structures related to Object Metadata Schema Descriptor Categories hosted in the platform
"""
id: int = 0
name: str
collapse: bool = True
index: int = 0
def get(schema_id) -> ObjectMetadataSchema:
"""Retrieve a Object Metadata Schema by its `schema_id`
Args:
schema_id (int): The `ObjectMetadataSchema` id
Returns:
ObjectMetadataSchema: A `ObjectMetadataSchema` if exists
"""
api_driver = api.Driver.get_instance()
return api_driver.serialize(
api_driver.get_single(
api_driver.get(
url_segment='objects/metadata/schema/' + str(schema_id)
),
),
ObjectMetadataSchema
)
def get_all():
"""Retrieve all Object Metadata Schemas
Returns:
list[ObjectMetadataSchema]: A list of existing `ObjectMetadataSchema`
"""
api_driver = api.Driver.get_instance()
return api_driver.serialize(
api_driver.get(
url_segment='objects/metadata/schema/'
),
ObjectMetadataSchema
)
def get_by_name(schema_name) -> ObjectMetadataSchema:
"""Retrieve a Object Metadata Schema by its `schema_name`
Args:
schema_name (str): The `ObjectMetadataSchema` name
Returns:
ObjectMetadataSchema: A `ObjectMetadataSchema` if exists
"""
return get_object_metadata_schema_by_condition({
'name': schema_name
})
def get_object_metadata_schema_by_condition(conditions) -> ObjectMetadataSchema:
"""Retrieve a single `ObjectMetadataSchema` using a given set of `conditions`
Args:
conditions (dict): The conditions of the query
Returns:
ObjectMetadataSchema: A `ObjectMetadataSchema` if found
"""
conditions_array = []
for condition_key, condition_value in conditions.items():
conditions_array.append({
condition_key: condition_value
})
query = {
"conditions": conditions_array
}
api_driver = api.Driver.get_instance()
return api_driver.serialize(
api_driver.get_single(
api_driver.get(
url_segment='objects/metadata/schema',
data=query
)
),
ObjectMetadataSchema
)
def create(name, description='') -> ObjectMetadataSchema:
"""Create a `ObjectMetadataSchema`
Args:
name (str): The name of the new `ObjectMetadataSchema`
description (str): (optional) The description of the new `ObjectMetadataSchema`
Returns:
ObjectMetadataSchema: The newly created `ObjectMetadataSchema`
"""
api_driver = api.Driver.get_instance()
return api_driver.serialize(
api_driver.post(
url_segment='objects/metadata/schema',
data={
'name': name,
'description': description
}
),
ObjectMetadataSchema
)
def get_object_metadata_schema_descriptor_by_condition(conditions) -> ObjectMetadataSchemaDescriptor:
"""Retrieve a single `ObjectMetadataSchemaDescriptor` using a given set of `conditions`
Args:
conditions (dict): The conditions of the query
Returns:
ObjectMetadataSchemaDescriptor: A `ObjectMetadataSchemaDescriptor` if found
"""
conditions_array = []
for condition_key, condition_value in conditions.items():
conditions_array.append({
condition_key: condition_value
})
query = {
"conditions": conditions_array
}
api_driver = api.Driver.get_instance()
return api_driver.serialize(
api_driver.get_single(
api_driver.get(
url_segment='objects/metadata/schema/descriptor',
data=query
)
),
ObjectMetadataSchemaDescriptor
)
def get_metadata_schema_descriptor_by_iecode(schema_id, iecode) -> ObjectMetadataSchemaDescriptor:
"""Retrieve a Object Metadata Schema Descriptor by its `iecode`
Args:
schema_id (int): The `ObjectMetadataSchemaDescriptor` schema_id
iecode (str): The `ObjectMetadataSchemaDescriptor` iecode
Returns:
ObjectMetadataSchemaDescriptor: A `ObjectMetadataSchemaDescriptor` if exists
"""
return get_object_metadata_schema_descriptor_by_condition({
'metadata_schema_id': schema_id,
'iecode': iecode
})
def get_descriptor(descriptor_id) -> ObjectMetadataSchemaDescriptor:
"""Retrieve a Object Metadata Schema Descriptor by its `descriptor_id`
Args:
descriptor_id (int): The `ObjectMetadataSchemaDescriptor` id
Returns:
ObjectMetadataSchemaDescriptor: A `ObjectMetadataSchemaDescriptor` if exists
"""
api_driver = api.Driver.get_instance()
return api_driver.serialize(
api_driver.get_single(
api_driver.get(
url_segment='objects/metadata/schema/descriptor/' + str(descriptor_id)
),
),
ObjectMetadataSchemaDescriptor
)
def create_descriptor(descriptor: ObjectMetadataSchemaDescriptor) -> ObjectMetadataSchemaDescriptor:
"""Create a `ObjectMetadataSchemaDescriptor`
Args:
descriptor (ObjectMetadataSchemaDescriptor): The new `ObjectMetadataSchemaDescriptor` to create
Returns:
ObjectMetadataSchemaDescriptor: The newly created `ObjectMetadataSchemaDescriptor`
"""
api_driver = api.Driver.get_instance()
data = {
'name': descriptor.name,
'description': descriptor.description,
'iecode': descriptor.iecode,
'data_type': descriptor.data_type.name,
'metadata_schema_category_id': descriptor.metadata_schema_category_id,
'enum_values': []
}
return api_driver.serialize(
api_driver.post_json(
url_segment='objects/metadata/schema/' + str(descriptor.metadata_schema_id) + '/descriptor',
data=data
),
ObjectMetadataSchemaDescriptor
)
def get_descriptor_category(category_id) -> ObjectMetadataSchemaDescriptorCategory:
"""Retrieve a Object Metadata Schema Descriptor Category by its `category_id`
Args:
category_id (id): The `ObjectMetadataSchemaDescriptorCategory` id
Returns:
ObjectMetadataSchemaDescriptorCategory: A `ObjectMetadataSchemaDescriptorCategory` if exists
"""
api_driver = api.Driver.get_instance()
return api_driver.serialize(
api_driver.get_single(
api_driver.get(
url_segment='objects/metadata/category/' + str(category_id)
),
),
ObjectMetadataSchemaDescriptorCategory
)
def get_object_metadata_schema_descriptor_category_by_condition(conditions) -> ObjectMetadataSchemaDescriptorCategory:
"""Retrieve a single `ObjectMetadataSchemaDescriptor` using a given set of `conditions`
Args:
conditions (dict): The conditions of the query
Returns:
ObjectMetadataSchemaDescriptor: A `ObjectMetadataSchemaDescriptor` if found
"""
conditions_array = []
for condition_key, condition_value in conditions.items():
conditions_array.append({
condition_key: condition_value
})
query = {
"conditions": conditions_array
}
api_driver = api.Driver.get_instance()
return api_driver.serialize(
api_driver.get_single(
api_driver.get(
url_segment='objects/metadata/category',
data=query
)
),
ObjectMetadataSchemaDescriptorCategory
)
def get_descriptor_category_by_name(category_name) -> ObjectMetadataSchemaDescriptorCategory:
"""Retrieve a Object Metadata Schema Descriptor Category by its `category_name`
Args:
category_name (str): The `ObjectMetadataSchemaDescriptorCategory` name
Returns:
ObjectMetadataSchemaDescriptorCategory: A `ObjectMetadataSchemaDescriptorCategory` if found
"""
return get_object_metadata_schema_descriptor_category_by_condition({
'name': category_name
})
def create_descriptor_category(descriptor_category: ObjectMetadataSchemaDescriptorCategory) -> ObjectMetadataSchemaDescriptorCategory:
"""Create a `ObjectMetadataSchemaDescriptorCategory`
Args:
descriptor_category (ObjectMetadataSchemaDescriptorCategory): The new `ObjectMetadataSchemaDescriptorCategory` to create
Returns:
ObjectMetadataSchemaDescriptorCategory: The newly created `ObjectMetadataSchemaDescriptorCategory`
"""
api_driver = api.Driver.get_instance()
data = {
'name': descriptor_category.name,
'collapse': descriptor_category.collapse,
'index': descriptor_category.index,
}
return api_driver.serialize(
api_driver.post_json(
url_segment='objects/metadata/category',
data=data
),
ObjectMetadataSchemaDescriptorCategory
)
Functions
def create(name, description='') ‑> ObjectMetadataSchema
-
Create a
ObjectMetadataSchema
Args
name
:str
- The name of the new
ObjectMetadataSchema
description
:str
- (optional) The description of the new
ObjectMetadataSchema
Returns
ObjectMetadataSchema
- The newly created
ObjectMetadataSchema
Expand source code
def create(name, description='') -> ObjectMetadataSchema: """Create a `ObjectMetadataSchema` Args: name (str): The name of the new `ObjectMetadataSchema` description (str): (optional) The description of the new `ObjectMetadataSchema` Returns: ObjectMetadataSchema: The newly created `ObjectMetadataSchema` """ api_driver = api.Driver.get_instance() return api_driver.serialize( api_driver.post( url_segment='objects/metadata/schema', data={ 'name': name, 'description': description } ), ObjectMetadataSchema )
def create_descriptor(descriptor: ObjectMetadataSchemaDescriptor) ‑> ObjectMetadataSchemaDescriptor
-
Create a
ObjectMetadataSchemaDescriptor
Args
descriptor
:ObjectMetadataSchemaDescriptor
- The new
ObjectMetadataSchemaDescriptor
to create
Returns
ObjectMetadataSchemaDescriptor
- The newly created
ObjectMetadataSchemaDescriptor
Expand source code
def create_descriptor(descriptor: ObjectMetadataSchemaDescriptor) -> ObjectMetadataSchemaDescriptor: """Create a `ObjectMetadataSchemaDescriptor` Args: descriptor (ObjectMetadataSchemaDescriptor): The new `ObjectMetadataSchemaDescriptor` to create Returns: ObjectMetadataSchemaDescriptor: The newly created `ObjectMetadataSchemaDescriptor` """ api_driver = api.Driver.get_instance() data = { 'name': descriptor.name, 'description': descriptor.description, 'iecode': descriptor.iecode, 'data_type': descriptor.data_type.name, 'metadata_schema_category_id': descriptor.metadata_schema_category_id, 'enum_values': [] } return api_driver.serialize( api_driver.post_json( url_segment='objects/metadata/schema/' + str(descriptor.metadata_schema_id) + '/descriptor', data=data ), ObjectMetadataSchemaDescriptor )
def create_descriptor_category(descriptor_category: ObjectMetadataSchemaDescriptorCategory) ‑> ObjectMetadataSchemaDescriptorCategory
-
Create a
ObjectMetadataSchemaDescriptorCategory
Args
descriptor_category
:ObjectMetadataSchemaDescriptorCategory
- The new
ObjectMetadataSchemaDescriptorCategory
to create
Returns
ObjectMetadataSchemaDescriptorCategory
- The newly created
ObjectMetadataSchemaDescriptorCategory
Expand source code
def create_descriptor_category(descriptor_category: ObjectMetadataSchemaDescriptorCategory) -> ObjectMetadataSchemaDescriptorCategory: """Create a `ObjectMetadataSchemaDescriptorCategory` Args: descriptor_category (ObjectMetadataSchemaDescriptorCategory): The new `ObjectMetadataSchemaDescriptorCategory` to create Returns: ObjectMetadataSchemaDescriptorCategory: The newly created `ObjectMetadataSchemaDescriptorCategory` """ api_driver = api.Driver.get_instance() data = { 'name': descriptor_category.name, 'collapse': descriptor_category.collapse, 'index': descriptor_category.index, } return api_driver.serialize( api_driver.post_json( url_segment='objects/metadata/category', data=data ), ObjectMetadataSchemaDescriptorCategory )
def get(schema_id) ‑> ObjectMetadataSchema
-
Retrieve a Object Metadata Schema by its
schema_id
Args
schema_id
:int
- The
ObjectMetadataSchema
id
Returns
ObjectMetadataSchema
- A
ObjectMetadataSchema
if exists
Expand source code
def get(schema_id) -> ObjectMetadataSchema: """Retrieve a Object Metadata Schema by its `schema_id` Args: schema_id (int): The `ObjectMetadataSchema` id Returns: ObjectMetadataSchema: A `ObjectMetadataSchema` if exists """ api_driver = api.Driver.get_instance() return api_driver.serialize( api_driver.get_single( api_driver.get( url_segment='objects/metadata/schema/' + str(schema_id) ), ), ObjectMetadataSchema )
def get_all()
-
Retrieve all Object Metadata Schemas
Returns
list[ObjectMetadataSchema]
- A list of existing
ObjectMetadataSchema
Expand source code
def get_all(): """Retrieve all Object Metadata Schemas Returns: list[ObjectMetadataSchema]: A list of existing `ObjectMetadataSchema` """ api_driver = api.Driver.get_instance() return api_driver.serialize( api_driver.get( url_segment='objects/metadata/schema/' ), ObjectMetadataSchema )
def get_by_name(schema_name) ‑> ObjectMetadataSchema
-
Retrieve a Object Metadata Schema by its
schema_name
Args
schema_name
:str
- The
ObjectMetadataSchema
name
Returns
ObjectMetadataSchema
- A
ObjectMetadataSchema
if exists
Expand source code
def get_by_name(schema_name) -> ObjectMetadataSchema: """Retrieve a Object Metadata Schema by its `schema_name` Args: schema_name (str): The `ObjectMetadataSchema` name Returns: ObjectMetadataSchema: A `ObjectMetadataSchema` if exists """ return get_object_metadata_schema_by_condition({ 'name': schema_name })
def get_descriptor(descriptor_id) ‑> ObjectMetadataSchemaDescriptor
-
Retrieve a Object Metadata Schema Descriptor by its
descriptor_id
Args
descriptor_id
:int
- The
ObjectMetadataSchemaDescriptor
id
Returns
Expand source code
def get_descriptor(descriptor_id) -> ObjectMetadataSchemaDescriptor: """Retrieve a Object Metadata Schema Descriptor by its `descriptor_id` Args: descriptor_id (int): The `ObjectMetadataSchemaDescriptor` id Returns: ObjectMetadataSchemaDescriptor: A `ObjectMetadataSchemaDescriptor` if exists """ api_driver = api.Driver.get_instance() return api_driver.serialize( api_driver.get_single( api_driver.get( url_segment='objects/metadata/schema/descriptor/' + str(descriptor_id) ), ), ObjectMetadataSchemaDescriptor )
def get_descriptor_category(category_id) ‑> ObjectMetadataSchemaDescriptorCategory
-
Retrieve a Object Metadata Schema Descriptor Category by its
category_id
Args
category_id
:id
- The
ObjectMetadataSchemaDescriptorCategory
id
Returns
Expand source code
def get_descriptor_category(category_id) -> ObjectMetadataSchemaDescriptorCategory: """Retrieve a Object Metadata Schema Descriptor Category by its `category_id` Args: category_id (id): The `ObjectMetadataSchemaDescriptorCategory` id Returns: ObjectMetadataSchemaDescriptorCategory: A `ObjectMetadataSchemaDescriptorCategory` if exists """ api_driver = api.Driver.get_instance() return api_driver.serialize( api_driver.get_single( api_driver.get( url_segment='objects/metadata/category/' + str(category_id) ), ), ObjectMetadataSchemaDescriptorCategory )
def get_descriptor_category_by_name(category_name) ‑> ObjectMetadataSchemaDescriptorCategory
-
Retrieve a Object Metadata Schema Descriptor Category by its
category_name
Args
category_name
:str
- The
ObjectMetadataSchemaDescriptorCategory
name
Returns
Expand source code
def get_descriptor_category_by_name(category_name) -> ObjectMetadataSchemaDescriptorCategory: """Retrieve a Object Metadata Schema Descriptor Category by its `category_name` Args: category_name (str): The `ObjectMetadataSchemaDescriptorCategory` name Returns: ObjectMetadataSchemaDescriptorCategory: A `ObjectMetadataSchemaDescriptorCategory` if found """ return get_object_metadata_schema_descriptor_category_by_condition({ 'name': category_name })
def get_metadata_schema_descriptor_by_iecode(schema_id, iecode) ‑> ObjectMetadataSchemaDescriptor
-
Retrieve a Object Metadata Schema Descriptor by its
iecode
Args
schema_id
:int
- The
ObjectMetadataSchemaDescriptor
schema_id iecode
:str
- The
ObjectMetadataSchemaDescriptor
iecode
Returns
Expand source code
def get_metadata_schema_descriptor_by_iecode(schema_id, iecode) -> ObjectMetadataSchemaDescriptor: """Retrieve a Object Metadata Schema Descriptor by its `iecode` Args: schema_id (int): The `ObjectMetadataSchemaDescriptor` schema_id iecode (str): The `ObjectMetadataSchemaDescriptor` iecode Returns: ObjectMetadataSchemaDescriptor: A `ObjectMetadataSchemaDescriptor` if exists """ return get_object_metadata_schema_descriptor_by_condition({ 'metadata_schema_id': schema_id, 'iecode': iecode })
def get_object_metadata_schema_by_condition(conditions) ‑> ObjectMetadataSchema
-
Retrieve a single
ObjectMetadataSchema
using a given set ofconditions
Args
conditions
:dict
- The conditions of the query
Returns
ObjectMetadataSchema
- A
ObjectMetadataSchema
if found
Expand source code
def get_object_metadata_schema_by_condition(conditions) -> ObjectMetadataSchema: """Retrieve a single `ObjectMetadataSchema` using a given set of `conditions` Args: conditions (dict): The conditions of the query Returns: ObjectMetadataSchema: A `ObjectMetadataSchema` if found """ conditions_array = [] for condition_key, condition_value in conditions.items(): conditions_array.append({ condition_key: condition_value }) query = { "conditions": conditions_array } api_driver = api.Driver.get_instance() return api_driver.serialize( api_driver.get_single( api_driver.get( url_segment='objects/metadata/schema', data=query ) ), ObjectMetadataSchema )
def get_object_metadata_schema_descriptor_by_condition(conditions) ‑> ObjectMetadataSchemaDescriptor
-
Retrieve a single
ObjectMetadataSchemaDescriptor
using a given set ofconditions
Args
conditions
:dict
- The conditions of the query
Returns
Expand source code
def get_object_metadata_schema_descriptor_by_condition(conditions) -> ObjectMetadataSchemaDescriptor: """Retrieve a single `ObjectMetadataSchemaDescriptor` using a given set of `conditions` Args: conditions (dict): The conditions of the query Returns: ObjectMetadataSchemaDescriptor: A `ObjectMetadataSchemaDescriptor` if found """ conditions_array = [] for condition_key, condition_value in conditions.items(): conditions_array.append({ condition_key: condition_value }) query = { "conditions": conditions_array } api_driver = api.Driver.get_instance() return api_driver.serialize( api_driver.get_single( api_driver.get( url_segment='objects/metadata/schema/descriptor', data=query ) ), ObjectMetadataSchemaDescriptor )
def get_object_metadata_schema_descriptor_category_by_condition(conditions) ‑> ObjectMetadataSchemaDescriptorCategory
-
Retrieve a single
ObjectMetadataSchemaDescriptor
using a given set ofconditions
Args
conditions
:dict
- The conditions of the query
Returns
Expand source code
def get_object_metadata_schema_descriptor_category_by_condition(conditions) -> ObjectMetadataSchemaDescriptorCategory: """Retrieve a single `ObjectMetadataSchemaDescriptor` using a given set of `conditions` Args: conditions (dict): The conditions of the query Returns: ObjectMetadataSchemaDescriptor: A `ObjectMetadataSchemaDescriptor` if found """ conditions_array = [] for condition_key, condition_value in conditions.items(): conditions_array.append({ condition_key: condition_value }) query = { "conditions": conditions_array } api_driver = api.Driver.get_instance() return api_driver.serialize( api_driver.get_single( api_driver.get( url_segment='objects/metadata/category', data=query ) ), ObjectMetadataSchemaDescriptorCategory )
Classes
class ObjectMetadataSchema (**entries: dict)
-
Platform Object Metadata Schema
The main methods allows the interaction with the main structures related to Object Metadata Schemas hosted in the platform
Expand source code
class ObjectMetadataSchema(Serializable): """Platform Object Metadata Schema The main methods allows the interaction with the main structures related to Object Metadata Schemas hosted in the platform """ id: int = 0 name: str description: str creator: int
Ancestors
Class variables
var creator : int
var description : str
var id : int
var name : str
class ObjectMetadataSchemaDescriptor (**entries: dict)
-
Platform Object Metadata Schema Descriptor
The main methods allows the interaction with the main structures related to Object Metadata Schema Descriptors hosted in the platform
Expand source code
class ObjectMetadataSchemaDescriptor(Serializable): """Platform Object Metadata Schema Descriptor The main methods allows the interaction with the main structures related to Object Metadata Schema Descriptors hosted in the platform """ id: int = 0 name: str description: str = '' iecode: str iecode_normalized: str = '' creator: int = 1 metadata_schema_id: int metadata_schema_category_id: int = 1 data_type: ObjectMetadataSchemaDescriptorDataType = 1 index: int = 0
Ancestors
Class variables
var creator : int
var data_type : ObjectMetadataSchemaDescriptorDataType
var description : str
var id : int
var iecode : str
var iecode_normalized : str
var index : int
var metadata_schema_category_id : int
var metadata_schema_id : int
var name : str
class ObjectMetadataSchemaDescriptorCategory (**entries: dict)
-
Platform Object Metadata Schema Descriptor Category
The main methods allows the interaction with the main structures related to Object Metadata Schema Descriptor Categories hosted in the platform
Expand source code
class ObjectMetadataSchemaDescriptorCategory(Serializable): """Platform Object Metadata Schema Descriptor Category The main methods allows the interaction with the main structures related to Object Metadata Schema Descriptor Categories hosted in the platform """ id: int = 0 name: str collapse: bool = True index: int = 0
Ancestors
Class variables
var collapse : bool
var id : int
var index : int
var name : str
class ObjectMetadataSchemaDescriptorDataType (value, names=None, *, module=None, qualname=None, type=None, start=1)
-
Object Metadata Schema Descriptor Data Type
Expand source code
class ObjectMetadataSchemaDescriptorDataType(Enum): """Object Metadata Schema Descriptor Data Type """ STRING = 1 LONGSTRING = 2 NUMBER = 3 DATE = 4 BOOL = 5 LINK_FIELDS = 6 ENUM = 7 OA_COLLECTION = 8 LS_AREA = 9
Ancestors
- enum.Enum
Class variables
var BOOL
var DATE
var ENUM
var LINK_FIELDS
var LONGSTRING
var LS_AREA
var NUMBER
var OA_COLLECTION
var STRING