-
Notifications
You must be signed in to change notification settings - Fork 17
/
array_element.json
106 lines (106 loc) · 3.3 KB
/
array_element.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
{
"id": "array_element",
"summary": "Get an element from an array",
"description": "Gives the element with the specified index or label from the array.\n\nEither the parameter `index` or `label` must be specified, otherwise the `ArrayElementParameterMissing` exception is thrown. If both parameters are set the `ArrayElementParameterConflict` exception is thrown.",
"categories": [
"arrays",
"reducer"
],
"parameters": [
{
"name": "data",
"description": "An array.",
"schema": {
"type": "array",
"items": {
"description": "Any data type is allowed."
}
}
},
{
"name": "index",
"description": "The zero-based index of the element to retrieve.",
"schema": {
"type": "integer",
"minimum": 0
},
"optional": true
},
{
"name": "label",
"description": "The label of the element to retrieve. Throws an `ArrayNotLabeled` exception, if the given array is not a labeled array and this parameter is set.",
"schema": [
{
"type": "number"
},
{
"type": "string"
}
],
"optional": true
},
{
"name": "return_nodata",
"description": "By default this process throws an `ArrayElementNotAvailable` exception if the index or label is invalid. If you want to return `null` instead, set this flag to `true`.",
"schema": {
"type": "boolean"
},
"default": false,
"optional": true
}
],
"returns": {
"description": "The value of the requested element.",
"schema": {
"description": "Any data type is allowed."
}
},
"exceptions": {
"ArrayElementNotAvailable": {
"message": "The array has no element with the specified index or label."
},
"ArrayElementParameterMissing": {
"message": "The process `array_element` requires either the `index` or `labels` parameter to be set."
},
"ArrayElementParameterConflict": {
"message": "The process `array_element` only allows that either the `index` or the `labels` parameter is set."
},
"ArrayNotLabeled": {
"message": "The array is not a labeled array, but the `label` parameter is set. Use the `index` instead."
}
},
"examples": [
{
"arguments": {
"data": [
9,
8,
7,
6,
5
],
"index": 2
},
"returns": 7
},
{
"arguments": {
"data": [
"A",
"B",
"C"
],
"index": 0
},
"returns": "A"
},
{
"arguments": {
"data": [],
"index": 0,
"return_nodata": true
},
"returns": null
}
]
}