@@ -49,66 +49,22 @@ class EntityHub(object):
49
49
Args:
50
50
project_name (str): Name of project where changes will happen.
51
51
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.
56
52
57
53
"""
58
54
59
- def __init__ (
60
- self , project_name , connection = None , allow_data_changes = None
61
- ):
55
+ def __init__ (self , project_name , connection = None ):
62
56
if not connection :
63
57
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
71
58
72
59
self ._connection = connection
73
- self ._path_start_with_slash = path_start_with_slash
74
60
75
61
self ._project_name = project_name
76
62
self ._entities_by_id = {}
77
63
self ._entities_by_parent_id = collections .defaultdict (list )
78
64
self ._project_entity = UNKNOWN_VALUE
79
65
80
- self ._allow_data_changes = allow_data_changes
81
-
82
66
self ._path_reset_queue = None
83
67
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
-
112
68
@property
113
69
def project_name (self ):
114
70
"""Project name which is maintained by hub.
@@ -898,8 +854,7 @@ def _get_folder_fields(self) -> Set[str]:
898
854
self ._connection .get_default_fields_for_type ("folder" )
899
855
)
900
856
folder_fields .add ("hasProducts" )
901
- if self ._allow_data_changes :
902
- folder_fields .add ("data" )
857
+ folder_fields .add ("data" )
903
858
return folder_fields
904
859
905
860
def _get_task_fields (self ) -> Set [str ]:
@@ -1717,10 +1672,7 @@ def _get_default_changes(self):
1717
1672
1718
1673
"""
1719
1674
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 :
1724
1676
data_changes = self ._data .get_changes ()
1725
1677
if data_changes :
1726
1678
changes ["data" ] = data_changes
@@ -3149,10 +3101,8 @@ def get_path(self, dynamic_value=True):
3149
3101
if parent .entity_type == "folder" :
3150
3102
parent_path = parent .path
3151
3103
path = "/" .join ([parent_path , self .name ])
3152
- elif self ._entity_hub .path_start_with_slash :
3153
- path = "/{}" .format (self .name )
3154
3104
else :
3155
- path = self .name
3105
+ path = "/{}" . format ( self .name )
3156
3106
self ._path = path
3157
3107
return self ._path
3158
3108
@@ -3260,10 +3210,7 @@ def to_create_body_data(self):
3260
3210
if self .thumbnail_id is not UNKNOWN_VALUE :
3261
3211
output ["thumbnailId" ] = self .thumbnail_id
3262
3212
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 :
3267
3214
output ["data" ] = self ._data .get_new_entity_value ()
3268
3215
return output
3269
3216
@@ -3451,10 +3398,7 @@ def to_create_body_data(self):
3451
3398
if self .assignees :
3452
3399
output ["assignees" ] = self .assignees
3453
3400
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 :
3458
3402
output ["data" ] = self ._data .get_new_entity_value ()
3459
3403
return output
3460
3404
@@ -3561,10 +3505,7 @@ def to_create_body_data(self):
3561
3505
if self .tags :
3562
3506
output ["tags" ] = self .tags
3563
3507
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 :
3568
3509
output ["data" ] = self ._data .get_new_entity_value ()
3569
3510
return output
3570
3511
@@ -3693,9 +3634,6 @@ def to_create_body_data(self):
3693
3634
if self .status :
3694
3635
output ["status" ] = self .status
3695
3636
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 :
3700
3638
output ["data" ] = self ._data .get_new_entity_value ()
3701
3639
return output
0 commit comments