@itentialopensource/allocate-a-pair-of-numbers
Version:
[Deprecated] A JST to find a pair of consecutive integers from within an array to allocate
1,177 lines • 34.9 kB
JSON
{
"metadata": {
"name": "@itentialopensource/allocate-a-pair-of-numbers",
"version": "0.0.13-2023.1.1",
"description": "[Deprecated] A JST to find a pair of consecutive integers from within an array to allocate ",
"license": "Apache-2.0",
"repository": {
"type": "gitlab",
"hostname": "gitlab.com",
"path": "itentialopensource/pre-built-automations"
},
"keywords": [
"Itential",
"IAP",
"artifacts",
"JST"
],
"author": "Itential Artifacts",
"IAPDependencies": {},
"gitlabId": 20916831
},
"manifest": {
"bundleName": "Allocate A Pair Of Resources",
"fingerprint": "5f510fffb8ded50ab72cc9af",
"createdEpoch": "1599148031602",
"artifacts": [
{
"id": "5f510ee4a1ff8106e83c1963",
"name": "allocateNewPair",
"type": "transformation",
"location": "/bundles/transformations/allocateNewPair.json",
"properties": {
"entryPoint": false
}
}
]
},
"bundles": [
{
"type": "transformation",
"data": {
"_id": "5f510ee4a1ff8106e83c1963",
"name": "allocateNewPair",
"description": "",
"incoming": [
{
"$id": "allocated",
"type": "array",
"items": {
"type": "integer",
"examples": [
1,
2,
3,
4,
6,
8,
9
]
}
},
{
"$id": "startRange",
"type": "integer",
"examples": [
5
]
},
{
"$id": "endRange",
"type": "integer",
"examples": [
15
]
}
],
"outgoing": [
{
"$id": "output",
"type": "object",
"properties": {
"assigned": {
"type": "integer",
"examples": [
5
]
}
},
"required": []
}
],
"steps": [
{
"id": 31,
"type": "declaration",
"library": "Object",
"method": "new Object",
"args": [
"{}"
],
"view": {
"row": 4,
"col": 2
}
},
{
"id": 36,
"type": "method",
"library": "Number",
"method": "parseInt",
"args": [
"0",
null
],
"view": {
"row": 5,
"col": 1
}
},
{
"id": 42,
"type": "assign",
"from": {
"location": "incoming",
"name": "allocated",
"ptr": ""
},
"to": {
"location": "method",
"name": 6,
"ptr": "/args/3/value"
}
},
{
"id": 34,
"type": "assign",
"from": {
"location": "declaration",
"name": 31,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 32,
"ptr": "/args/0/value"
}
},
{
"id": 37,
"type": "assign",
"from": {
"location": "method",
"name": 36,
"ptr": "/return"
},
"to": {
"location": "declaration",
"name": 35,
"ptr": "/args/0/value"
}
},
{
"id": 35,
"type": "declaration",
"library": "Boolean",
"method": "new Boolean",
"args": [
null
],
"view": {
"row": 5,
"col": 2
}
},
{
"id": 2,
"type": "method",
"library": "Math",
"method": "subtract",
"args": [
null,
null
],
"view": {
"row": 1,
"col": 1
}
},
{
"id": 5,
"type": "assign",
"from": {
"location": "method",
"name": 2,
"ptr": "/return"
},
"to": {
"location": "declaration",
"name": 1,
"ptr": "/args/0/value"
}
},
{
"id": 24,
"type": "assign",
"from": {
"location": "method",
"name": 2,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 13,
"ptr": "/args/3/value"
}
},
{
"id": 38,
"type": "assign",
"from": {
"location": "declaration",
"name": 35,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 32,
"ptr": "/args/2/value"
}
},
{
"id": 1,
"type": "declaration",
"library": "Array",
"method": "new Array",
"args": [
null
],
"view": {
"row": 1,
"col": 2
},
"polymorphIndex": 1
},
{
"id": 21,
"type": "assign",
"from": {
"location": "declaration",
"name": 1,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 13,
"ptr": "/args/0/value"
}
},
{
"id": 32,
"type": "method",
"library": "Object",
"method": "setProperty",
"args": [
null,
"assigned",
null
],
"view": {
"row": 4,
"col": 3
}
},
{
"id": 39,
"type": "assign",
"from": {
"location": "method",
"name": 32,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 27,
"ptr": "/args/1/value"
}
},
{
"id": 13,
"type": "method",
"library": "Array",
"method": "fill",
"args": [
null,
"false",
0,
null
],
"view": {
"row": 1,
"col": 3
}
},
{
"id": 22,
"type": "assign",
"from": {
"location": "method",
"name": 13,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 6,
"ptr": "/args/0/value"
}
},
{
"id": 6,
"type": "method",
"library": "Array",
"method": "reduce",
"args": [
null,
"ƒ_reduce_2",
"falsee",
null,
null,
null
],
"view": {
"row": 2,
"col": 2
}
},
{
"id": 26,
"type": "assign",
"from": {
"location": "method",
"name": 6,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 25,
"ptr": "/args/0/value"
}
},
{
"id": 40,
"type": "assign",
"from": {
"location": "method",
"name": 6,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 27,
"ptr": "/args/2/value"
}
},
{
"id": 25,
"type": "method",
"library": "Equality",
"method": "equality",
"args": [
null,
"falsee"
],
"view": {
"row": 2,
"col": 3
}
},
{
"id": 28,
"type": "assign",
"from": {
"location": "method",
"name": 25,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 27,
"ptr": "/args/0/value"
}
},
{
"id": 27,
"type": "method",
"library": "Conditional",
"method": "ternary",
"args": [
null,
null,
null
],
"view": {
"row": 3,
"col": 4
}
},
{
"id": 30,
"type": "assign",
"from": {
"location": "method",
"name": 27,
"ptr": "/return"
},
"to": {
"location": "outgoing",
"name": "output",
"ptr": ""
}
},
{
"id": 43,
"type": "assign",
"from": {
"location": "incoming",
"name": "startRange",
"ptr": ""
},
"to": {
"location": "method",
"name": 2,
"ptr": "/args/1/value"
}
},
{
"id": 44,
"type": "assign",
"from": {
"location": "incoming",
"name": "startRange",
"ptr": ""
},
"to": {
"location": "method",
"name": 6,
"ptr": "/args/4/value"
}
},
{
"id": 45,
"type": "assign",
"from": {
"location": "incoming",
"name": "endRange",
"ptr": ""
},
"to": {
"location": "method",
"name": 2,
"ptr": "/args/0/value"
}
},
{
"id": 46,
"type": "assign",
"from": {
"location": "incoming",
"name": "endRange",
"ptr": ""
},
"to": {
"location": "method",
"name": 6,
"ptr": "/args/5/value"
}
}
],
"functions": [
{
"incoming": [
{
"$id": "accumulator",
"type": [
"array",
"boolean",
"number",
"integer",
"string",
"object",
"null"
]
},
{
"type": [
"array",
"boolean",
"number",
"integer",
"string",
"object",
"null"
],
"$id": "currentValue"
},
{
"title": "index",
"type": "number",
"optional": true,
"$id": "index"
},
{
"type": "array",
"$id": "array",
"optional": true
},
{
"$id": "thisArg",
"type": "object",
"properties": {
"allocated": {
"$id": "allocated",
"type": "array",
"items": {
"type": "integer",
"examples": [
1,
2,
3,
4,
6,
8,
9
]
}
},
"startRange": {
"$id": "startRange",
"type": "integer",
"examples": [
5
]
},
"endRange": {
"$id": "endRange",
"type": "integer",
"examples": [
15
]
}
},
"isContext": true
}
],
"outgoing": [
{
"title": "accumulator",
"type": [
"array",
"boolean",
"number",
"integer",
"string",
"object",
"null"
],
"$id": "accumulator"
}
],
"functions": [],
"name": "reduceFunction",
"steps": [
{
"id": 2,
"type": "assign",
"from": {
"location": "incoming",
"name": "index",
"ptr": ""
},
"to": {
"location": "method",
"name": 1,
"ptr": "/args/0/value"
}
},
{
"id": 3,
"type": "assign",
"from": {
"location": "incoming",
"name": "thisArg",
"ptr": "/startRange"
},
"to": {
"location": "method",
"name": 1,
"ptr": "/args/1/value"
}
},
{
"id": 5,
"type": "assign",
"from": {
"location": "incoming",
"name": "thisArg",
"ptr": "/allocated"
},
"to": {
"location": "method",
"name": 4,
"ptr": "/args/0/value"
}
},
{
"id": 13,
"type": "assign",
"from": {
"location": "incoming",
"name": "accumulator",
"ptr": ""
},
"to": {
"location": "method",
"name": 12,
"ptr": "/args/0/value"
}
},
{
"id": 24,
"type": "assign",
"from": {
"location": "incoming",
"name": "accumulator",
"ptr": ""
},
"to": {
"location": "method",
"name": 7,
"ptr": "/args/2/value"
}
},
{
"id": 25,
"type": "declaration",
"library": "Object",
"method": "new Object",
"args": [
"{}"
],
"view": {
"row": 5,
"col": 1
}
},
{
"id": 32,
"type": "assign",
"from": {
"location": "incoming",
"name": "thisArg",
"ptr": "/allocated"
},
"to": {
"location": "method",
"name": 30,
"ptr": "/args/0/value"
}
},
{
"id": 37,
"type": "assign",
"from": {
"location": "incoming",
"name": "thisArg",
"ptr": "/endRange"
},
"to": {
"location": "method",
"name": 35,
"ptr": "/args/1/value"
}
},
{
"id": 12,
"type": "method",
"library": "Equality",
"method": "equality",
"args": [
null,
"falsee"
],
"view": {
"row": 4,
"col": 2
}
},
{
"id": 26,
"type": "assign",
"from": {
"location": "declaration",
"name": 25,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 16,
"ptr": "/args/0/value"
}
},
{
"id": 1,
"type": "method",
"library": "Math",
"method": "add",
"args": [
null,
null
],
"view": {
"row": 1,
"col": 1
}
},
{
"id": 14,
"type": "assign",
"from": {
"location": "method",
"name": 12,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 9,
"ptr": "/args/1/value"
}
},
{
"id": 6,
"type": "assign",
"from": {
"location": "method",
"name": 1,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 4,
"ptr": "/args/1/value"
}
},
{
"id": 29,
"type": "assign",
"from": {
"location": "method",
"name": 1,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 28,
"ptr": "/args/0/value"
}
},
{
"id": 46,
"type": "assign",
"from": {
"location": "method",
"name": 1,
"ptr": "/return"
},
"to": {
"location": "declaration",
"name": 45,
"ptr": "/args/0/value"
}
},
{
"id": 28,
"type": "method",
"library": "Math",
"method": "add",
"args": [
null,
1
],
"view": {
"row": 2,
"col": 2
}
},
{
"id": 4,
"type": "method",
"library": "Array",
"method": "includes",
"args": [
null,
null,
null
],
"view": {
"row": 1,
"col": 2
}
},
{
"id": 31,
"type": "assign",
"from": {
"location": "method",
"name": 28,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 30,
"ptr": "/args/1/value"
}
},
{
"id": 36,
"type": "assign",
"from": {
"location": "method",
"name": 28,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 35,
"ptr": "/args/0/value"
}
},
{
"id": 47,
"type": "assign",
"from": {
"location": "method",
"name": 28,
"ptr": "/return"
},
"to": {
"location": "declaration",
"name": 45,
"ptr": "/args/1/value"
}
},
{
"id": 22,
"type": "assign",
"from": {
"location": "method",
"name": 4,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 21,
"ptr": "/args/0/value"
}
},
{
"id": 21,
"type": "method",
"library": "Logical",
"method": "not",
"args": [
null
],
"view": {
"row": 1,
"col": 4
}
},
{
"id": 30,
"type": "method",
"library": "Array",
"method": "includes",
"args": [
null,
null,
null
],
"view": {
"row": 2,
"col": 3
}
},
{
"id": 35,
"type": "method",
"library": "Relational",
"method": "lessThanOrEqual",
"args": [
null,
null
],
"view": {
"row": 3,
"col": 2
}
},
{
"id": 23,
"type": "assign",
"from": {
"location": "method",
"name": 21,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 9,
"ptr": "/args/0/value"
}
},
{
"id": 34,
"type": "assign",
"from": {
"location": "method",
"name": 30,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 33,
"ptr": "/args/0/value"
}
},
{
"id": 40,
"type": "assign",
"from": {
"location": "method",
"name": 35,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 38,
"ptr": "/args/1/value"
}
},
{
"id": 33,
"type": "method",
"library": "Logical",
"method": "not",
"args": [
null
],
"view": {
"row": 2,
"col": 4
}
},
{
"id": 39,
"type": "assign",
"from": {
"location": "method",
"name": 33,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 38,
"ptr": "/args/0/value"
}
},
{
"id": 45,
"type": "declaration",
"library": "Array",
"method": "new Array",
"args": [
null,
null
],
"view": {
"row": 6,
"col": 1
},
"polymorphIndex": 0
},
{
"id": 48,
"type": "assign",
"from": {
"location": "declaration",
"name": 45,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 16,
"ptr": "/args/2/value"
}
},
{
"id": 9,
"type": "method",
"library": "Logical",
"method": "and",
"args": [
null,
null
],
"view": {
"row": 4,
"col": 3
}
},
{
"id": 44,
"type": "assign",
"from": {
"location": "method",
"name": 9,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 41,
"ptr": "/args/1/value"
}
},
{
"id": 16,
"type": "method",
"library": "Object",
"method": "setProperty",
"args": [
null,
"assigned",
null
],
"view": {
"row": 5,
"col": 2
}
},
{
"id": 19,
"type": "assign",
"from": {
"location": "method",
"name": 16,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 7,
"ptr": "/args/1/value"
}
},
{
"id": 38,
"type": "method",
"library": "Logical",
"method": "and",
"args": [
null,
null
],
"view": {
"row": 3,
"col": 3
}
},
{
"id": 43,
"type": "assign",
"from": {
"location": "method",
"name": 38,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 41,
"ptr": "/args/0/value"
}
},
{
"id": 41,
"type": "method",
"library": "Logical",
"method": "and",
"args": [
null,
null
],
"view": {
"row": 3,
"col": 4
}
},
{
"id": 42,
"type": "assign",
"from": {
"location": "method",
"name": 41,
"ptr": "/return"
},
"to": {
"location": "method",
"name": 7,
"ptr": "/args/0/value"
}
},
{
"id": 7,
"type": "method",
"library": "Conditional",
"method": "ternary",
"args": [
null,
null,
null
],
"view": {
"row": 3,
"col": 5
}
},
{
"id": 27,
"type": "assign",
"from": {
"location": "method",
"name": 7,
"ptr": "/return"
},
"to": {
"location": "outgoing",
"name": "accumulator",
"ptr": ""
}
}
],
"view": {
"col": 5,
"row": 7
},
"id": "ƒ_reduce_2",
"comments": []
}
],
"view": {
"col": 4,
"row": 6
},
"created": "2020-12-18T21:23:22.317Z",
"createdBy": {
"_id": "5f36a3352554207e49a23f0b",
"provenance": "Itential AAA LDAP",
"username": "itential-artifacts"
},
"lastUpdated": "2020-12-21T22:21:22.698Z",
"lastUpdatedBy": {
"_id": "5f36a3352554207e49a23f0b",
"provenance": "Itential AAA LDAP",
"username": "itential-artifacts"
}
}
}
],
"readme": "<!-- This is a comment in md (Markdown) format, it will not be visible to the end user -->\n## _Deprecation Notice_\nThis Pre-Built has been deprecated as of 01-15-2024 and will be end of life on 01-15-2025. The capabilities of this Pre-Built have been replaced by the [IAP - Data Manipulation](https://gitlab.com/itentialopensource/pre-built-automations/iap-data-manipulation)\n\n<!-- Update the below line with your artifact name -->\n# Allocate a Pair of Numbers\n\n<!-- Leave TOC intact unless you've added or removed headers -->\n## Table of Contents\n\n* [Overview](#overview)\n* [Installation Prerequisites](#installation-prerequisites)\n* [Features](#features)\n* [Future Enhancements](#future-enhancements)\n* [How to Install](#how-to-install)\n* [How to Run](#how-to-run)\n* [Additional Information](#additional-information)\n\n## Overview\nThis Pre-Built consists of a JST document that finds the first available consecutive pair of numbers from a given starting integer, a given ending integer, and a given array of already allocated integers (`allocated`).\n\nFor instance, a range is defined by start and end values: ex: 0 through 255. These values are assumed for the following examples.\n\nExample 1: `allocated: [12,200,199,0,2,4,100,101,150]`. The output from this JST is an object containing the next available consecutive pair of numbers availible in the range. `{ \"assigned\": [5,6] }`.\n\nExample 2: `allocated: [187,19,0,1,2,18,10,140]` The output for this JST will be `{ \"assigned\": [3,4] }`.\n\nIn case the range is all allocated, the output object will be: `{ \"assigned\": false }`\n\nExample use cases when this JST can be used: an array of ports, an array of IP addresses (can only handle 1 quadrant: 0-255), etc.\n<!-- Write a few sentences about the artifact and explain the use case(s) -->\n<!-- Ex.: The Migration Wizard enables IAP users to conveniently move their automation use cases between different IAP environments -->\n<!-- (e.g. from Dev to Pre-Production or from Lab to Production). -->\n\n<!-- Workflow(s) Image Placeholder - TO BE ADDED DIRECTLY TO GitLab -->\n<!-- REPLACE COMMENT BELOW WITH IMAGE OF YOUR MAIN WORKFLOW -->\n\n<!-- REPLACE COMMENT ABOVE WITH IMAGE OF YOUR MAIN WORKFLOW -->\n\n<!-- ADD ESTIMATED RUN TIME HERE -->\n<!-- e.g. Estimated Run Time: 34 min. -->\n_Estimated Run Time_: depends on the size of the array. usually within second(s)\n\n## Installation Prerequisites\n\nUsers must satisfy the following pre-requisites:\n\n<!-- Include any other required apps or adapters in this list -->\n<!-- Ex.: EC2 Adapter -->\n* Itential Automation Platform\n * `^2022.1.x`\n\n\n## Features\n\nThe main benefits and features of the Pre-Built are outlined below.\n * Finds the first available consecutive pair of numbers within an array. \n<!-- Unordered list highlighting the most exciting features of the artifact -->\n<!-- EXAMPLE -->\n<!-- * Automatically checks for device type -->\n<!-- * Displays dry-run to user (asking for confirmation) prior to pushing config to the device -->\n<!-- * Verifies downloaded file integrity (using md5), will try to download again if failed -->\n\n\n## Future Enhancements\n * Increasing an algorithm's efficiency by converting logic onto a recursive call.\n<!-- OPTIONAL - Mention if the artifact will be enhanced with additional features on the road map -->\n<!-- Ex.: This artifact would support Cisco XR and F5 devices -->\n\n## How to Install\n\nTo install the artifact:\n\n* Verify you are running a supported version of the Itential Automation Platform (IAP) as listed above in the [Requirements](#requirements) section in order to install the Pre-Built.\n* The Pre-Built can be installed from within App-Admin_Essential. Simply search for the name of your desired artifact and click the install button.\n\n<!-- OPTIONAL - Explain if external components are required outside of IAP -->\n<!-- Ex.: The Ansible roles required for this artifact can be found in the repository located at https://gitlab.com/itentialopensource/pre-built-automations/hello-world -->\n\n## How to Run\n\nIn order to run this JST, add the appropriate JST task onto the workflow, then search for \"allocateNewPair\" and\nassign values to all incoming variables:\n\n startRange: INT\n endRange: INT\n allocated: ARRAY of INT\n<!-- Explain the main entrypoint(s) for this artifact: Automation Catalog item, Workflow, Postman, etc. -->\n\n## Additional Information\n\nPlease use your Itential Customer Success account if you need support when using this Pre-Built Transformation.\n"
}