@@ -340,7 +340,7 @@ def new_representation_entity(
340340 return output
341341
342342
343- def new_workfile_info (
343+ def new_workfile_entity (
344344 filepath : str ,
345345 task_id : str ,
346346 status : Optional [str ] = None ,
@@ -396,6 +396,28 @@ def new_workfile_info(
396396 return output
397397
398398
399+ def new_workfile_info (
400+ filepath : str ,
401+ task_id : str ,
402+ status : Optional [str ] = None ,
403+ tags : Optional [list [str ]] = None ,
404+ attribs : Optional [dict [str , Any ]] = None ,
405+ description : Optional [str ] = None ,
406+ data : Optional [dict [str , Any ]] = None ,
407+ entity_id : Optional [str ] = None ,
408+ ) -> NewWorkfileDict :
409+ return new_workfile_entity (
410+ filepath ,
411+ task_id ,
412+ status ,
413+ tags ,
414+ attribs ,
415+ description ,
416+ data ,
417+ entity_id ,
418+ )
419+
420+
399421class AbstractOperation (ABC ):
400422 """Base operation class.
401423
@@ -1544,3 +1566,143 @@ def delete_representation(
15441566 return self .delete_entity (
15451567 project_name , "representation" , representation_id
15461568 )
1569+
1570+ def create_workfile_entity (
1571+ self ,
1572+ project_name : str ,
1573+ path : str ,
1574+ task_id : str ,
1575+ * ,
1576+ thumbnail_id : Optional [str ] = None ,
1577+ attrib : Optional [dict [str , Any ]] = None ,
1578+ data : Optional [dict [str , Any ]] = None ,
1579+ tags : Optional [list [str ]] = None ,
1580+ status : Optional [str ] = None ,
1581+ active : Optional [bool ] = None ,
1582+ workfile_id : Optional [str ] = None ,
1583+ ) -> CreateOperation :
1584+ """Create new workfile entity.
1585+
1586+ Args:
1587+ project_name (str): Project name.
1588+ path (str): Representation name.
1589+ task_id (str): Parent task id.
1590+ thumbnail_id (Optional[str]): Thumbnail id.
1591+ attrib (Optional[dict[str, Any]]): Representation attributes.
1592+ data (Optional[dict[str, Any]]): Representation data.
1593+ tags (Optional[Iterable[str]]): Representation tags.
1594+ status (Optional[str]): Representation status.
1595+ active (Optional[bool]): Representation active state.
1596+ workfile_id (Optional[str]): Workfile info id. If not
1597+ passed new id is generated.
1598+
1599+ Returns:
1600+ CreateOperation: Object of create operation.
1601+
1602+ """
1603+ if workfile_id is None :
1604+ workfile_id = create_entity_id ()
1605+
1606+ create_data = {
1607+ "id" : workfile_id ,
1608+ "path" : path ,
1609+ "taskId" : task_id ,
1610+ }
1611+ for key , value in (
1612+ ("thumbnailId" , thumbnail_id ),
1613+ ("attrib" , attrib ),
1614+ ("data" , data ),
1615+ ("tags" , tags ),
1616+ ("status" , status ),
1617+ ("active" , active ),
1618+ ):
1619+ if value is not None :
1620+ create_data [key ] = value
1621+
1622+ return self .create_entity (
1623+ project_name ,
1624+ "workfile" ,
1625+ create_data
1626+ )
1627+
1628+ def update_workfile_entity (
1629+ self ,
1630+ project_name : str ,
1631+ workfile_id : str ,
1632+ path : Optional [str ] = None ,
1633+ task_id : Optional [str ] = None ,
1634+ attrib : Optional [dict [str , Any ]] = None ,
1635+ data : Optional [dict [str , Any ]] = None ,
1636+ tags : Optional [Iterable [str ]] = None ,
1637+ status : Optional [str ] = None ,
1638+ active : Optional [bool ] = None ,
1639+ thumbnail_id : Optional [str ] = NOT_SET ,
1640+ created_by : Optional [str ] = None ,
1641+ updated_by : Optional [str ] = None ,
1642+ ) -> UpdateOperation :
1643+ """Update workfile entity on server.
1644+
1645+ Update of ``data`` will override existing value on folder entity.
1646+
1647+ Update of ``attrib`` does change only passed attributes. If you want
1648+ to unset value, use ``None``.
1649+
1650+ Args:
1651+ project_name (str): Project name.
1652+ workfile_id (str): Workfile id.
1653+ path (Optional[str]): New rootless workfile path..
1654+ task_id (Optional[str]): New parent task id.
1655+ attrib (Optional[dict[str, Any]]): New attributes.
1656+ data (Optional[dict[str, Any]]): New data.
1657+ tags (Optional[Iterable[str]]): New tags.
1658+ status (Optional[str]): New status.
1659+ active (Optional[bool]): New active state.
1660+ thumbnail_id (Optional[str]): New thumbnail id.
1661+ created_by (Optional[str]): New created by username.
1662+ updated_by (Optional[str]): New updated by username.
1663+
1664+ Returns:
1665+ UpdateOperation: Object of update operation.
1666+
1667+ """
1668+ update_data = {}
1669+ for key , value in (
1670+ ("path" , path ),
1671+ ("taskId" , task_id ),
1672+ ("attrib" , attrib ),
1673+ ("data" , data ),
1674+ ("tags" , tags ),
1675+ ("status" , status ),
1676+ ("active" , active ),
1677+ ("thumbnailId" , thumbnail_id ),
1678+ ("createdBy" , created_by ),
1679+ ("updatedBy" , updated_by ),
1680+ ):
1681+ if value is not None :
1682+ update_data [key ] = value
1683+
1684+ return self .update_entity (
1685+ project_name ,
1686+ "workfile" ,
1687+ workfile_id ,
1688+ update_data
1689+ )
1690+
1691+ def delete_workfile_entity (
1692+ self ,
1693+ project_name : str ,
1694+ workfile_id : str ,
1695+ ) -> DeleteOperation :
1696+ """Delete workfile entity.
1697+
1698+ Args:
1699+ project_name (str): Project name.
1700+ workfile_id (str): Workfile info id to delete.
1701+
1702+ Returns:
1703+ DeleteOperation: Object of delete operation.
1704+
1705+ """
1706+ return self .delete_entity (
1707+ project_name , "workfile" , workfile_id
1708+ )
0 commit comments