def get_all_attributes(ctx): """ Get all the attributes in the system Args: None Returns: List[Attr]: A list of attribute complex models """ attrs = attributes.get_attributes(**ctx.in_header.__dict__) ret_attrs = [Attr(attr) for attr in attrs] return ret_attrs
def get_attributes_by_id(ctx, ID): """ Get a specific attribute by its ID. Args: ID (int): The ID of the attribute Returns: hydra_complexmodels.Attr: An attribute complex model. Returns None if no attribute is found. """ attrs = attributes.get_attribute_by_id(ID, **ctx.in_header.__dict__) return [Attr(attr) for attr in attrs]
def get_template_attributes(ctx, template_id): """ Get all the attributes in a template. Args param (int) template_id Returns List(Attr) """ attrs = attributes.get_template_attributes(template_id, **ctx.in_header.__dict__) return [Attr(a) for a in attrs]
def add_attributes(ctx, attrs): """ Add multiple generic attributes Args: attrs (List[Attr]): A list of attribute complex models, as described above. Returns: List[Attr]: A list of attribute complex models, reflecting the ones sent in. """ attrs = attributes.add_attributes(attrs, **ctx.in_header.__dict__) ret_attrs = [Attr(attr) for attr in attrs] return ret_attrs
def get_attribute(ctx, name, dimension): """ Get a specific attribute by its name and dimension (this combination is unique for attributes in Hydra Platform). Args: name (unicode): The name of the attribute dimension (unicode): The dimension of the attribute Returns: hydra_complexmodels.Attr: An attribute complex model. Returns None if no attribute is found. """ attr = attributes.get_attribute_by_name_and_dimension( name, dimension, **ctx.in_header.__dict__) if attr: return Attr(attr) return None
def update_attribute(ctx, attr): """ Update a generic attribute, which can then be used in creating a resource attribute, and put into a type. .. code-block:: python (Attr){ id = 1020 name = "Test Attr" dimen = "very big" description = "I am a very big attribute" } Args: attr (hydra_complexmodels.Attr): An attribute complex model, as described above. Returns: hydra_complexmodels.Attr: An attribute complex model, reflecting the one sent in. """ attr = attributes.update_attribute(attr, **ctx.in_header.__dict__) return Attr(attr)
def add_attribute(ctx, attr): """ Add a generic attribute, which can then be used in creating a resource attribute, and put into a type. .. code-block:: python (Attr){ name = "Test Attr" dimen = "very big" description = "I am a very big attribute" } Args: attr (hydra_complexmodels.Attr): An attribute object, as described above. Returns: hydra_complexmodels.Attr: An attribute object, similar to the one sent in but with an ID. """ attr = attributes.add_attribute(attr, **ctx.in_header.__dict__) return Attr(attr)