Skip to content

Commit 49537e3

Browse files
authored
Merge pull request #46 from JupiterOne/KNO-540
performance improvements!
2 parents ca14fd3 + e9fd2e3 commit 49537e3

File tree

3 files changed

+130
-153
lines changed

3 files changed

+130
-153
lines changed

README.md

Lines changed: 15 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,35 @@ the default of "https://api.us.jupiterone.io" is used.
4747

4848
```python
4949
QUERY = 'FIND Host'
50-
query_result = j1.query_v1(QUERY)
50+
query_result = j1.query_v1(query=QUERY)
5151

5252
# Including deleted entities
53-
query_result = j1.query_v1(QUERY, include_deleted=True)
53+
query_result = j1.query_v1(query=QUERY, include_deleted=True)
5454

5555
# Tree query
5656
QUERY = 'FIND Host RETURN TREE'
57-
query_result = j1.query_v1(QUERY)
57+
query_result = j1.query_v1(query=QUERY)
5858

59-
# Using cursor graphQL variable to return full set of paginated results
59+
# Using cursor query to return full set of paginated results
6060
QUERY = "FIND (Device | Person)"
61-
cursor_query_r = j1._cursor_query(QUERY)
61+
cursor_query_r = j1._cursor_query(query=QUERY)
6262

63+
# Using cursor query with parallel processing
64+
QUERY = "FIND (Device | Person)"
65+
cursor_query_r = j1._cursor_query(query=QUERY, max_workers=5)
66+
67+
# Using deferredResponse with J1QL to return large datasets
68+
QUERY = "FIND UnifiedDevice"
69+
deferred_response_query_r = j1.query_with_deferred_response(query=QUERY)
6370
```
6471

6572
##### Create an entity:
6673

6774
Note that the CreateEntity mutation behaves like an upsert, so a non-existent entity will be created or an existing entity will be updated.
6875

6976
```python
77+
import time
78+
7079
properties = {
7180
'myProperty': 'myValue',
7281
'tag.myTagProperty': 'value_will_be_a_tag'
@@ -80,7 +89,6 @@ entity = j1.create_entity(
8089
timestamp=int(time.time()) * 1000 # Optional, defaults to current datetime
8190
)
8291
print(entity['entity'])
83-
8492
```
8593

8694

@@ -96,7 +104,6 @@ j1.update_entity(
96104
entity_id='<id-of-entity-to-update>',
97105
properties=properties
98106
)
99-
100107
```
101108

102109

@@ -116,7 +123,6 @@ j1.create_relationship(
116123
from_entity_id='<id-of-source-entity>',
117124
to_entity_id='<id-of-destination-entity>'
118125
)
119-
120126
```
121127

122128
##### Update a relationship
@@ -128,35 +134,30 @@ j1.update_relationship(
128134
"<relationship-property-name>": "<relationship-property-updated-value>",
129135
},
130136
)
131-
132137
```
133138

134139
##### Delete a relationship
135140

136141
```python
137142
j1.delete_relationship(relationship_id='<id-of-relationship-to-delete>')
138-
139143
```
140144

141145
##### Fetch Graph Entity Properties
142146

143147
```python
144148
j1.fetch_all_entity_properties()
145-
146149
```
147150

148151
##### Fetch Graph Entity Tags
149152

150153
```python
151154
j1.fetch_all_entity_tags()
152-
153155
```
154156

155157
##### Fetch Entity Raw Data
156158

157159
```python
158160
j1.fetch_entity_raw_data(entity_id='<id-of-entity>')
159-
160161
```
161162

162163
##### Create Integration Instance
@@ -165,14 +166,12 @@ j1.fetch_entity_raw_data(entity_id='<id-of-entity>')
165166
j1.create_integration_instance(
166167
instance_name="Integration Name",
167168
instance_description="Description Text")
168-
169169
```
170170

171171
##### Start Synchronization Job
172172

173173
```python
174174
j1.start_sync_job(instance_id='<id-of-integration-instance>')
175-
176175
```
177176

178177
##### Upload Batch of Entities
@@ -204,7 +203,6 @@ entities_payload = [
204203

205204
j1.upload_entities_batch_json(instance_job_id='<id-of-integration-sync-job>',
206205
entities_list=entities_payload)
207-
208206
```
209207

210208
##### Upload Batch of Relationships
@@ -231,7 +229,6 @@ relationships_payload = [
231229

232230
j1.upload_relationships_batch_json(instance_job_id='<id-of-integration-sync-job>',
233231
relationships_list=relationships_payload)
234-
235232
```
236233

237234
##### Upload Batch of Entities and Relationships
@@ -283,14 +280,12 @@ combined_payload = {
283280

284281
j1.upload_combined_batch_json(instance_job_id='<id-of-integration-sync-job>',
285282
combined_payload=combined_payload)
286-
287283
```
288284

289285
##### Finalize Synchronization Job
290286

291287
```python
292288
j1.finalize_sync_job(instance_job_id='<id-of-integration-sync-job>')
293-
294289
```
295290

296291
##### Fetch Integration Instance Jobs
@@ -305,15 +300,13 @@ j1.fetch_integration_jobs(instance_id='<id-of-integration-instance>')
305300
```python
306301
j1.fetch_integration_job_events(instance_id='<id-of-integration-instance>',
307302
instance_job_id='<id-of-integration-instance-job>')
308-
309303
```
310304

311305
##### Create SmartClass
312306

313307
```python
314308
j1.create_smartclass(smartclass_name='SmartClassName',
315309
smartclass_description='SmartClass Description Text')
316-
317310
```
318311

319312
##### Create SmartClass Query
@@ -322,42 +315,36 @@ j1.create_smartclass(smartclass_name='SmartClassName',
322315
j1.create_smartclass_query(smartclass_id='<id-of-smartclass>',
323316
query='<J1QL-query-to-be-added>',
324317
query_description='Query Description Text')
325-
326318
```
327319

328320
##### Run SmartClass Evaluation
329321

330322
```python
331323
j1.evaluate_smartclass(smartclass_id='<id-of-smartclass>')
332-
333324
```
334325

335326
##### Get SmartClass Details
336327

337328
```python
338329
j1.get_smartclass_details(smartclass_id='<id-of-smartclass>')
339-
340330
```
341331

342332
##### Generate J1QL from Natural Language Prompt
343333

344334
```python
345335
j1.generate_j1ql(natural_language_prompt='<natural-language-input-text>')
346-
347336
```
348337

349338
##### List Alert Rules
350339

351340
```python
352341
j1.list_alert_rules()
353-
354342
```
355343

356344
##### Get Alert Rule Details
357345

358346
```python
359347
j1.get_alert_rule_details(rule_id='<id-of-alert-rule>')
360-
361348
```
362349

363350
##### Create Alert Rule
@@ -372,13 +359,11 @@ j1.create_alert_rule(name="create_alert_rule-name",
372359
polling_interval="DISABLED",
373360
severity="INFO",
374361
j1ql="find jupiterone_user")
375-
376362
```
377363

378364
##### Create Alert Rule with Action Config
379365

380366
```python
381-
382367
webhook_action_config = {
383368
"type": "WEBHOOK",
384369
"endpoint": "https://webhook.domain.here/endpoint",
@@ -443,21 +428,17 @@ j1.create_alert_rule(name="create_alert_rule-name",
443428
severity="INFO",
444429
j1ql="find jupiterone_user",
445430
action_configs=webhook_action_config)
446-
447431
```
448432

449433
##### Delete Alert Rule
450434

451435
```python
452-
453436
j1.delete_alert_rule(rule_id='<id-of-alert-rule')
454-
455437
```
456438

457439
##### Update Alert Rule
458440

459441
```python
460-
461442
# polling_interval can be DISABLED, THIRTY_MINUTES, ONE_HOUR, FOUR_HOURS, EIGHT_HOURS, TWELVE_HOURS, ONE_DAY, or ONE_WEEK
462443
# tag_op can be OVERWRITE or APPEND
463444
# severity can be INFO, LOW, MEDIUM, HIGH, or CRITICAL
@@ -572,108 +553,77 @@ j1.update_alert_rule(rule_id='<id-of-alert-rule>',
572553
j1.update_alert_rule(rule_id='<id-of-alert-rule>',
573554
tags=['additionalTag1', 'additionalTag2'],
574555
tag_op="APPEND")
575-
576556
```
577557

578558
##### Evaluate Alert Rule
579559

580560
```python
581-
582561
j1.evaluate_alert_rule(rule_id='<id-of-alert-rule>')
583-
584562
```
585563

586564
##### Get Compliance Framework Item
587565

588566
```python
589-
590567
j1.get_compliance_framework_item_details(item_id="<id-of-item>")
591-
592568
```
593569

594570
##### List Alert Rule Evaluation Results
595571

596572
```python
597-
598573
j1.list_alert_rule_evaluation_results(rule_id="<id-of-rule>")
599-
600574
```
601575

602576
##### Fetch Evaluation Result Download URL
603577

604578
```python
605-
606579
j1.fetch_evaluation_result_download_url(raw_data_key="RULE_EVALUATION/<id-of-evaluation>/query0.json")
607-
608580
```
609581

610582
##### Fetch Evaluation Result Download URL
611583

612584
```python
613-
614585
j1.fetch_evaluation_result_download_url(raw_data_key="RULE_EVALUATION/<id-of-evaluation>/query0.json")
615-
616586
```
617587

618588
##### Fetch Downloaded Evaluation Results
619589

620590
```python
621-
622591
j1.fetch_downloaded_evaluation_results(download_url="https://download.us.jupiterone.io/<id-of-rule>/RULE_EVALUATION/<id-of-evaluation>/<epoch>/query0.json?token=<TOKEN>&Expires=<epoch>")
623-
624592
```
625593

626594
##### Get Integration Definition Details
627595

628596
```python
629-
630597
# examples: 'aws', 'azure', 'google_cloud'
631-
632598
j1.get_integration_definition_details(integration_type="<integration-type>")
633-
634599
```
635600

636601
##### Fetch Integration Instances
637602

638603
```python
639-
640604
j1.fetch_integration_instances(definition_id="<id-of-definition>")
641-
642-
643605
```
644606

645607
##### Fetch Integration Instance Details
646608

647609
```python
648-
649610
j1.get_integration_instance_details(instance_id="<id-of-integration-instance>")
650-
651-
652611
```
653612

654613
##### Get Account Parameter Details
655614

656615
```python
657-
658616
j1.get_parameter_details(name="ParameterName")
659-
660-
661617
```
662618

663619
##### List Account Parameters
664620

665621
```python
666-
667622
j1.list_account_parameters()
668-
669-
670623
```
671624

672-
##### Create or Update Acount Parameter
625+
##### Create or Update Account Parameter
673626

674627
```python
675-
676628
j1.create_update_parameter(name="ParameterName", value="stored_value", secret=False)
677-
678-
679629
```

0 commit comments

Comments
 (0)