@@ -49,66 +49,22 @@ class EntityHub(object):
4949 Args:
5050 project_name (str): Name of project where changes will happen.
5151 connection (ServerAPI): Connection to server with logged user.
52- allow_data_changes (bool): This option gives ability to change 'data'
53- key on entities. This is not recommended as 'data' may be used for
54- secure information and would also slow down server queries. Content
55- of 'data' key can't be received only GraphQl.
5652
5753 """
5854
59- def __init__ (
60- self , project_name , connection = None , allow_data_changes = None
61- ):
55+ def __init__ (self , project_name , connection = None ):
6256 if not connection :
6357 connection = get_server_api_connection ()
64- major , minor , _ , _ , _ = connection .server_version_tuple
65- path_start_with_slash = True
66- if (major , minor ) < (0 , 6 ):
67- path_start_with_slash = False
68-
69- if allow_data_changes is None :
70- allow_data_changes = connection .graphql_allows_data_in_query
7158
7259 self ._connection = connection
73- self ._path_start_with_slash = path_start_with_slash
7460
7561 self ._project_name = project_name
7662 self ._entities_by_id = {}
7763 self ._entities_by_parent_id = collections .defaultdict (list )
7864 self ._project_entity = UNKNOWN_VALUE
7965
80- self ._allow_data_changes = allow_data_changes
81-
8266 self ._path_reset_queue = None
8367
84- @property
85- def allow_data_changes (self ):
86- """Entity hub allows changes of 'data' key on entities.
87-
88- Data are private and not all users may have access to them.
89-
90- Older version of AYON server allowed to get 'data' for entity only
91- using REST api calls, which means to query each entity on-by-one
92- from server.
93-
94- Returns:
95- bool: Data changes are allowed.
96-
97- """
98- return self ._allow_data_changes
99-
100- @property
101- def path_start_with_slash (self ):
102- """Folder path should start with slash.
103-
104- This changed in 0.6.x server version.
105-
106- Returns:
107- bool: Path starts with slash.
108-
109- """
110- return self ._path_start_with_slash
111-
11268 @property
11369 def project_name (self ):
11470 """Project name which is maintained by hub.
@@ -898,8 +854,7 @@ def _get_folder_fields(self) -> Set[str]:
898854 self ._connection .get_default_fields_for_type ("folder" )
899855 )
900856 folder_fields .add ("hasProducts" )
901- if self ._allow_data_changes :
902- folder_fields .add ("data" )
857+ folder_fields .add ("data" )
903858 return folder_fields
904859
905860 def _get_task_fields (self ) -> Set [str ]:
@@ -1717,10 +1672,7 @@ def _get_default_changes(self):
17171672
17181673 """
17191674 changes = {}
1720- if (
1721- self ._entity_hub .allow_data_changes
1722- and self ._data is not UNKNOWN_VALUE
1723- ):
1675+ if self ._data is not UNKNOWN_VALUE :
17241676 data_changes = self ._data .get_changes ()
17251677 if data_changes :
17261678 changes ["data" ] = data_changes
@@ -3149,10 +3101,8 @@ def get_path(self, dynamic_value=True):
31493101 if parent .entity_type == "folder" :
31503102 parent_path = parent .path
31513103 path = "/" .join ([parent_path , self .name ])
3152- elif self ._entity_hub .path_start_with_slash :
3153- path = "/{}" .format (self .name )
31543104 else :
3155- path = self .name
3105+ path = "/{}" . format ( self .name )
31563106 self ._path = path
31573107 return self ._path
31583108
@@ -3260,10 +3210,7 @@ def to_create_body_data(self):
32603210 if self .thumbnail_id is not UNKNOWN_VALUE :
32613211 output ["thumbnailId" ] = self .thumbnail_id
32623212
3263- if (
3264- self ._entity_hub .allow_data_changes
3265- and self ._data is not UNKNOWN_VALUE
3266- ):
3213+ if self ._data is not UNKNOWN_VALUE :
32673214 output ["data" ] = self ._data .get_new_entity_value ()
32683215 return output
32693216
@@ -3451,10 +3398,7 @@ def to_create_body_data(self):
34513398 if self .assignees :
34523399 output ["assignees" ] = self .assignees
34533400
3454- if (
3455- self ._entity_hub .allow_data_changes
3456- and self ._data is not UNKNOWN_VALUE
3457- ):
3401+ if self ._data is not UNKNOWN_VALUE :
34583402 output ["data" ] = self ._data .get_new_entity_value ()
34593403 return output
34603404
@@ -3561,10 +3505,7 @@ def to_create_body_data(self):
35613505 if self .tags :
35623506 output ["tags" ] = self .tags
35633507
3564- if (
3565- self ._entity_hub .allow_data_changes
3566- and self ._data is not UNKNOWN_VALUE
3567- ):
3508+ if self ._data is not UNKNOWN_VALUE :
35683509 output ["data" ] = self ._data .get_new_entity_value ()
35693510 return output
35703511
@@ -3693,9 +3634,6 @@ def to_create_body_data(self):
36933634 if self .status :
36943635 output ["status" ] = self .status
36953636
3696- if (
3697- self ._entity_hub .allow_data_changes
3698- and self ._data is not UNKNOWN_VALUE
3699- ):
3637+ if self ._data is not UNKNOWN_VALUE :
37003638 output ["data" ] = self ._data .get_new_entity_value ()
37013639 return output
0 commit comments