Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit 0a77c8a

Browse files
author
peritz
committed
Update variable names for admin entities
1 parent 901905e commit 0a77c8a

File tree

5 files changed

+65
-52
lines changed

5 files changed

+65
-52
lines changed

pycti/entities/opencti_capability.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ def __init__(self, opencti):
1313
self.properties = """
1414
id
1515
entity_type
16+
parent_types
1617
name
1718
description
1819
attribute_order
20+
21+
created_at
22+
updated_at
1923
"""
2024

2125
def list(self, **kwargs) -> List[Dict]:
@@ -27,7 +31,7 @@ def list(self, **kwargs) -> List[Dict]:
2731
:return: List of capabilities
2832
:rtype: List[Dict]
2933
"""
30-
customAttributes = kwargs.get("customAttributes")
34+
custom_attributes = kwargs.get("customAttributes")
3135
self.opencti.admin_logger.info("Listing capabilities")
3236
query = (
3337
"""
@@ -36,7 +40,7 @@ def list(self, **kwargs) -> List[Dict]:
3640
edges {
3741
node {
3842
"""
39-
+ (self.properties if customAttributes is None else customAttributes)
43+
+ (self.properties if custom_attributes is None else custom_attributes)
4044
+ """
4145
}
4246
}

pycti/entities/opencti_group.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def __init__(self, opencti):
2929
name
3030
description
3131
32+
entity_type
33+
parent_types
3234
created_at
3335
updated_at
3436
@@ -125,7 +127,7 @@ def list(self, **kwargs) -> List[Dict]:
125127
orderMode = kwargs.get("orderMode", None)
126128
search = kwargs.get("search", None)
127129
filters = kwargs.get("filters", None)
128-
customAttributes = kwargs.get("customAttributes", None)
130+
custom_attributes = kwargs.get("customAttributes", None)
129131
getAll = kwargs.get("getAll", False)
130132
withPagination = kwargs.get("withPagination", False)
131133

@@ -142,7 +144,7 @@ def list(self, **kwargs) -> List[Dict]:
142144
edges {
143145
node {
144146
"""
145-
+ (self.properties if customAttributes is None else customAttributes)
147+
+ (self.properties if custom_attributes is None else custom_attributes)
146148
+ """
147149
}
148150
}
@@ -211,15 +213,15 @@ def read(self, **kwargs) -> Optional[Dict]:
211213
id = kwargs.get("id", None)
212214
filters = kwargs.get("filters", None)
213215
search = kwargs.get("search", None)
214-
customAttributes = kwargs.get("customAttributes", None)
216+
custom_attributes = kwargs.get("customAttributes", None)
215217
if id is not None:
216218
self.opencti.admin_logger.info("Fetching group with ID", {"id": id})
217219
query = (
218220
"""
219221
query Group($id: String!) {
220222
group(id: $id) {
221223
"""
222-
+ (self.properties if customAttributes is None else customAttributes)
224+
+ (self.properties if custom_attributes is None else custom_attributes)
223225
+ """
224226
}
225227
}
@@ -229,7 +231,7 @@ def read(self, **kwargs) -> Optional[Dict]:
229231
return self.opencti.process_multiple_fields(result["data"]["group"])
230232
elif filters is not None or search is not None:
231233
results = self.list(
232-
filters=filters, search=search, customAttributes=customAttributes
234+
filters=filters, search=search, customAttributes=custom_attributes
233235
)
234236
return results[0] if results else None
235237
else:
@@ -275,11 +277,11 @@ def create(self, **kwargs) -> Optional[Dict]:
275277
no_creators = kwargs.get("no_creators", False)
276278
restrict_delete = kwargs.get("restrict_delete", False)
277279
auto_new_marking = kwargs.get("auto_new_marking", False)
278-
customAttributes = kwargs.get("customAttributes", None)
280+
custom_attributes = kwargs.get("customAttributes", None)
279281

280282
if name is None or group_confidence_level is None:
281283
self.opencti.admin_logger.error(
282-
"[opencti_group] Missing parameters: name and " "group_confidence_level"
284+
"[opencti_group] Missing parameters: name and group_confidence_level"
283285
)
284286
return None
285287

@@ -300,7 +302,7 @@ def create(self, **kwargs) -> Optional[Dict]:
300302
mutation GroupAdd($input: GroupAddInput!) {
301303
groupAdd(input: $input) {
302304
"""
303-
+ (self.properties if customAttributes is None else customAttributes)
305+
+ (self.properties if custom_attributes is None else custom_attributes)
304306
+ """
305307
}
306308
}
@@ -352,7 +354,7 @@ def update_field(self, **kwargs) -> Optional[Dict]:
352354
"""
353355
id = kwargs.get("id", None)
354356
input = kwargs.get("input", None)
355-
customAttributes = kwargs.get("customAttributes", None)
357+
custom_attributes = kwargs.get("customAttributes", None)
356358

357359
if id is None or input is None:
358360
self.opencti.admin_logger.error(
@@ -367,7 +369,7 @@ def update_field(self, **kwargs) -> Optional[Dict]:
367369
groupEdit(id: $id) {
368370
fieldPatch(input: $input) {
369371
"""
370-
+ (self.properties if customAttributes is None else customAttributes)
372+
+ (self.properties if custom_attributes is None else custom_attributes)
371373
+ """
372374
}
373375
}
@@ -402,7 +404,7 @@ def add_member(self, **kwargs) -> Optional[Dict]:
402404
"Adding member to group", {"groupId": id, "userId": user_id}
403405
)
404406
query = """
405-
mutation MemberAdd($groupId: ID!, $userId: ID!) {
407+
mutation GroupEditMemberAdd($groupId: ID!, $userId: ID!) {
406408
groupEdit(id: $groupId) {
407409
relationAdd(input: {
408410
fromId: $userId,
@@ -449,7 +451,7 @@ def delete_member(self, **kwargs) -> Optional[Dict]:
449451
)
450452
query = (
451453
"""
452-
mutation MemberDelete ($groupId: ID!, $userId: StixRef!) {
454+
mutation GroupEditMemberDelete ($groupId: ID!, $userId: StixRef!) {
453455
groupEdit(id: $groupId) {
454456
relationDelete(fromId: $userId, relationship_type: "member-of") {
455457
"""
@@ -488,7 +490,7 @@ def add_role(self, **kwargs) -> Optional[Dict]:
488490
"Adding role to group", {"groupId": id, "roleId": role_id}
489491
)
490492
query = """
491-
mutation RoleAdd($groupId: ID!, $roleId: ID!) {
493+
mutation GroupEditRoleAdd($groupId: ID!, $roleId: ID!) {
492494
groupEdit(id: $groupId) {
493495
relationAdd(input: {
494496
toId: $roleId, relationship_type: "has-role"
@@ -534,7 +536,7 @@ def delete_role(self, **kwargs) -> Optional[Dict]:
534536
)
535537
query = (
536538
"""
537-
mutation RoleDelete($groupId: ID!, $roleId: StixRef!) {
539+
mutation GroupEditRoleDelete($groupId: ID!, $roleId: StixRef!) {
538540
groupEdit(id: $groupId) {
539541
relationDelete(toId: $roleId, relationship_type: "has-role") {
540542
"""
@@ -581,7 +583,7 @@ def edit_default_marking(self, **kwargs) -> Optional[Dict]:
581583
)
582584
query = (
583585
"""
584-
mutation EditDefaultMarking($id: ID!, $entity_type: String!, $values: [String!]) {
586+
mutation GroupEditEditDefaultMarking($id: ID!, $entity_type: String!, $values: [String!]) {
585587
groupEdit(id: $id) {
586588
editDefaultMarking(input: {
587589
entity_type: $entity_type,
@@ -699,7 +701,7 @@ def delete_allowed_marking(self, **kwargs) -> Optional[Dict]:
699701
)
700702
query = (
701703
"""
702-
mutation MarkingForbid($groupId: ID!, $markingId: StixRef!) {
704+
mutation GroupEditMarkingRemove($groupId: ID!, $markingId: StixRef!) {
703705
groupEdit(id: $groupId) {
704706
relationDelete(toId: $markingId, relationship_type: "accesses-to") {
705707
"""

pycti/entities/opencti_role.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ def list(self, **kwargs) -> List[Dict]:
7171
after = kwargs.get("after", None)
7272
orderBy = kwargs.get("orderBy", None)
7373
orderMode = kwargs.get("orderMode", None)
74-
customAttributes = kwargs.get("customAttributes", None)
74+
custom_attributes = kwargs.get("customAttributes", None)
7575
getAll = kwargs.get("getAll", False)
76-
withPagination = kwargs.get("withPagination", False)
76+
with_pagination = kwargs.get("withPagination", False)
7777

7878
self.opencti.admin_logger.info(
7979
"Searching roles matching search term", {"search": search}
@@ -89,7 +89,7 @@ def list(self, **kwargs) -> List[Dict]:
8989
edges {
9090
node {
9191
"""
92-
+ (self.properties if customAttributes is None else customAttributes)
92+
+ (self.properties if custom_attributes is None else custom_attributes)
9393
+ """
9494
}
9595
}
@@ -135,7 +135,7 @@ def list(self, **kwargs) -> List[Dict]:
135135
return final_data
136136
else:
137137
return self.opencti.process_multiple(
138-
result["data"]["roles"], withPagination
138+
result["data"]["roles"], with_pagination
139139
)
140140

141141
def read(self, **kwargs) -> Optional[Dict]:
@@ -155,7 +155,7 @@ def read(self, **kwargs) -> Optional[Dict]:
155155
"""
156156
id = kwargs.get("id", None)
157157
search = kwargs.get("search", None)
158-
customAttributes = kwargs.get("customAttributes", None)
158+
custom_attributes = kwargs.get("customAttributes", None)
159159

160160
if id is not None:
161161
self.opencti.admin_logger.info("Reading role", {"id": id})
@@ -164,7 +164,7 @@ def read(self, **kwargs) -> Optional[Dict]:
164164
query RoleRead($id: String!) {
165165
role(id: $id) {
166166
"""
167-
+ (self.properties if customAttributes is None else customAttributes)
167+
+ (self.properties if custom_attributes is None else custom_attributes)
168168
+ """
169169
}
170170
}
@@ -218,7 +218,7 @@ def create(self, **kwargs) -> Optional[Dict]:
218218
"""
219219
name = kwargs.get("name", None)
220220
description = kwargs.get("description", None)
221-
customAttributes = kwargs.get("customAttributes", None)
221+
custom_attributes = kwargs.get("customAttributes", None)
222222

223223
if name is None:
224224
self.opencti.admin_logger.error("[opencti_role] Missing parameter: name")
@@ -232,7 +232,7 @@ def create(self, **kwargs) -> Optional[Dict]:
232232
mutation RoleCreate($input: RoleAddInput!) {
233233
roleAdd(input: $input) {
234234
"""
235-
+ (self.properties if customAttributes is None else customAttributes)
235+
+ (self.properties if custom_attributes is None else custom_attributes)
236236
+ """
237237
}
238238
}
@@ -271,7 +271,7 @@ def update_field(self, **kwargs) -> Optional[Dict]:
271271
"""
272272
id = kwargs.get("id", None)
273273
input = kwargs.get("input", None)
274-
customAttributes = kwargs.get("customAttributes", None)
274+
custom_attributes = kwargs.get("customAttributes", None)
275275

276276
if id is None or input is None:
277277
self.opencti.admin_logger.error(
@@ -288,7 +288,7 @@ def update_field(self, **kwargs) -> Optional[Dict]:
288288
roleEdit(id: $id) {
289289
fieldPatch(input: $input) {
290290
"""
291-
+ (self.properties if customAttributes is None else customAttributes)
291+
+ (self.properties if custom_attributes is None else custom_attributes)
292292
+ """
293293
}
294294
}
@@ -325,7 +325,7 @@ def add_capability(self, **kwargs) -> Optional[Dict]:
325325
)
326326
query = (
327327
"""
328-
mutation RoleAddCapability($id: ID!, $input: InternalRelationshipAddInput!) {
328+
mutation RoleEditAddCapability($id: ID!, $input: InternalRelationshipAddInput!) {
329329
roleEdit(id: $id) {
330330
relationAdd(input: $input) {
331331
id
@@ -388,7 +388,7 @@ def delete_capability(self, **kwargs) -> Optional[Dict]:
388388
)
389389
query = (
390390
"""
391-
mutation RoleDeleteCapability($id: ID!, $toId: StixRef!) {
391+
mutation RoleEditDeleteCapability($id: ID!, $toId: StixRef!) {
392392
roleEdit(id: $id) {
393393
relationDelete(toId: $toId, relationship_type: "has-capability") {
394394
"""

pycti/entities/opencti_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def delete_message(self, **kwargs) -> Optional[Dict]:
360360

361361
query = (
362362
"""
363-
mutation SettingsDeleteMessage($id: ID!, $input: String!) {
363+
mutation SettingsEditDeleteMessage($id: ID!, $input: String!) {
364364
settingsEdit(id: $id) {
365365
deleteMessage(input: $input) {
366366
id

0 commit comments

Comments
 (0)