diff --git a/Packs/BatchData/.pack-ignore b/Packs/BatchData/.pack-ignore new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/Packs/BatchData/.secrets-ignore b/Packs/BatchData/.secrets-ignore new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/Packs/BatchData/README.md b/Packs/BatchData/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/Packs/BatchData/Scripts/BatchData/BatchData.py b/Packs/BatchData/Scripts/BatchData/BatchData.py new file mode 100644 index 000000000000..a0d4cc2a8d1f --- /dev/null +++ b/Packs/BatchData/Scripts/BatchData/BatchData.py @@ -0,0 +1,20 @@ +import demistomock as demisto # noqa: F401 +from CommonServerPython import * # noqa: F401 + +batch_size = demisto.args()['batch_size'] +list_of_items = demisto.args()['data'] +context_path = demisto.args()['context_path'] + +list_of_items = list(list_of_items.split(",")) + +batch_size = int(batch_size) +batch_list = list() + +for i in range(0, len(list_of_items), batch_size): + batch_list.append(list_of_items[i:i + batch_size]) + +context = {"BatchedData": {context_path: batch_list}} +demisto.results({'Type': entryTypes['note'], + 'Contents': context, + 'ContentsFormat': formats['json'], + 'EntryContext': context}) diff --git a/Packs/BatchData/Scripts/BatchData/BatchData.yml b/Packs/BatchData/Scripts/BatchData/BatchData.yml new file mode 100644 index 000000000000..8d7f0f1134bf --- /dev/null +++ b/Packs/BatchData/Scripts/BatchData/BatchData.yml @@ -0,0 +1,39 @@ +args: +- description: number of items that will be returned in each dictionary items (must + be of type int) + name: batch_size + required: true +- description: comma separated list of items + name: data + required: true +- description: This nest the path under BatchedData in context. If you are running + this script multiple times/simultaneously in a playbook, your data will be over + written. + name: context_path + required: true +comment: 'This Automation takes in a string of comma separated items and returns a + dictionary of with the defined chunk size. ' +commonfields: + id: 29077d9b-fe3c-4366-8cf9-f117f987621d + version: -1 +contentitemexportablefields: + contentitemfields: + definitionid: "" + fromServerVersion: "" + itemVersion: "" + packID: f707aae3-25f5-4694-8911-872087659bca + propagationLabels: + - all + toServerVersion: "" +dockerimage: demisto/python3:3.10.1.26972 +enabled: true +engineinfo: {} +name: BatchData +pswd: "" +runas: DBotWeakRole +runonce: false +script: '' +scripttarget: 0 +subtype: python3 +tags: [] +type: python diff --git a/Packs/BatchData/Scripts/BatchData/README.md b/Packs/BatchData/Scripts/BatchData/README.md new file mode 100644 index 000000000000..facf7dad93c2 --- /dev/null +++ b/Packs/BatchData/Scripts/BatchData/README.md @@ -0,0 +1,22 @@ +This Automation takes in a string of comma separated items and returns a dictionary of with the defined chunk size. + +## Script Data +--- + +| **Name** | **Description** | +| --- | --- | +| Script Type | python3 | +| Tags | | + +## Inputs +--- + +| **Argument Name** | **Description** | +| --- | --- | +| batch_size | number of items that will be returned in each dictionary items \(must be of type int\) | +| data | comma separated list of items | +| context_path | This nest the path under BatchedData in context. If you are running this script multiple times/simultaneously in a playbook, your data will be over written. | + +## Outputs +--- +There are no outputs for this script. diff --git a/Packs/BatchData/pack_metadata.json b/Packs/BatchData/pack_metadata.json new file mode 100644 index 000000000000..4ff44583e5d6 --- /dev/null +++ b/Packs/BatchData/pack_metadata.json @@ -0,0 +1,17 @@ +{ + "name": "BatchData", + "description": "This script is used to split large list data sets into a defined batch size. A common use case is for api requests that can only handle a set number of items per request. ", + "support": "community", + "currentVersion": "1.0.0", + "author": "cstone112", + "url": "", + "email": "", + "created": "2022-03-02T16:40:15Z", + "categories": ["Utilities"], + "tags": [], + "useCases": [], + "keywords": [], + "githubUser": [ + "cstone112" + ] +}