From 51328b8b165278ee3c8c46f81789c2d735507a5e Mon Sep 17 00:00:00 2001 From: xsoar-bot Date: Wed, 2 Mar 2022 16:40:34 +0000 Subject: [PATCH 1/2] "pack contribution initial commit" --- Packs/BatchData/.pack-ignore | 0 Packs/BatchData/.secrets-ignore | 0 Packs/BatchData/README.md | 0 .../BatchData/Scripts/BatchData/BatchData.py | 20 ++++++++++ .../BatchData/Scripts/BatchData/BatchData.yml | 39 +++++++++++++++++++ Packs/BatchData/Scripts/BatchData/README.md | 22 +++++++++++ Packs/BatchData/pack_metadata.json | 17 ++++++++ 7 files changed, 98 insertions(+) create mode 100644 Packs/BatchData/.pack-ignore create mode 100644 Packs/BatchData/.secrets-ignore create mode 100644 Packs/BatchData/README.md create mode 100644 Packs/BatchData/Scripts/BatchData/BatchData.py create mode 100644 Packs/BatchData/Scripts/BatchData/BatchData.yml create mode 100644 Packs/BatchData/Scripts/BatchData/README.md create mode 100644 Packs/BatchData/pack_metadata.json 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..c03a54045089 --- /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": [], + "tags": [], + "useCases": [], + "keywords": [], + "githubUser": [ + "cstone112" + ] +} \ No newline at end of file From 9d8ba3dd6ac9b4a47b4d0b36bfb0afa2edd76246 Mon Sep 17 00:00:00 2001 From: cstone112 <88046504+cstone112@users.noreply.github.com> Date: Wed, 2 Mar 2022 15:07:25 -0600 Subject: [PATCH 2/2] Update pack_metadata.json Added categories to the metadata file --- Packs/BatchData/pack_metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Packs/BatchData/pack_metadata.json b/Packs/BatchData/pack_metadata.json index c03a54045089..4ff44583e5d6 100644 --- a/Packs/BatchData/pack_metadata.json +++ b/Packs/BatchData/pack_metadata.json @@ -7,11 +7,11 @@ "url": "", "email": "", "created": "2022-03-02T16:40:15Z", - "categories": [], + "categories": ["Utilities"], "tags": [], "useCases": [], "keywords": [], "githubUser": [ "cstone112" ] -} \ No newline at end of file +}