Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 2 #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added Packs/BatchData/.pack-ignore
Empty file.
Empty file added Packs/BatchData/.secrets-ignore
Empty file.
Empty file added Packs/BatchData/README.md
Empty file.
20 changes: 20 additions & 0 deletions Packs/BatchData/Scripts/BatchData/BatchData.py
Original file line number Diff line number Diff line change
@@ -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})
39 changes: 39 additions & 0 deletions Packs/BatchData/Scripts/BatchData/BatchData.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions Packs/BatchData/Scripts/BatchData/README.md
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 17 additions & 0 deletions Packs/BatchData/pack_metadata.json
Original file line number Diff line number Diff line change
@@ -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"
]
}