id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
list | docstring
stringlengths 4
11.8k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 86
226
|
|---|---|---|---|---|---|---|---|---|---|---|---|
13,700
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
getPosition
|
function getPosition(el) {
var p = { left: el.offsetLeft, top: el.offsetTop };
el = el.offsetParent;
while (el) {
p.left += el.offsetLeft;
p.top += el.offsetTop;
if (el !== doc.body && el !== doc.documentElement) {
p.left -= el.scrollLeft;
p.top -= el.scrollTop;
}
el = el.offsetParent;
}
return p;
}
|
javascript
|
function getPosition(el) {
var p = { left: el.offsetLeft, top: el.offsetTop };
el = el.offsetParent;
while (el) {
p.left += el.offsetLeft;
p.top += el.offsetTop;
if (el !== doc.body && el !== doc.documentElement) {
p.left -= el.scrollLeft;
p.top -= el.scrollTop;
}
el = el.offsetParent;
}
return p;
}
|
[
"function",
"getPosition",
"(",
"el",
")",
"{",
"var",
"p",
"=",
"{",
"left",
":",
"el",
".",
"offsetLeft",
",",
"top",
":",
"el",
".",
"offsetTop",
"}",
";",
"el",
"=",
"el",
".",
"offsetParent",
";",
"while",
"(",
"el",
")",
"{",
"p",
".",
"left",
"+=",
"el",
".",
"offsetLeft",
";",
"p",
".",
"top",
"+=",
"el",
".",
"offsetTop",
";",
"if",
"(",
"el",
"!==",
"doc",
".",
"body",
"&&",
"el",
"!==",
"doc",
".",
"documentElement",
")",
"{",
"p",
".",
"left",
"-=",
"el",
".",
"scrollLeft",
";",
"p",
".",
"top",
"-=",
"el",
".",
"scrollTop",
";",
"}",
"el",
"=",
"el",
".",
"offsetParent",
";",
"}",
"return",
"p",
";",
"}"
] |
Loop up the node tree and add offsetWidth and offsetHeight to get the
total page offset for a given element. Used by Opera and iOS on hover and
all browsers on point click.
@param {Object} el
|
[
"Loop",
"up",
"the",
"node",
"tree",
"and",
"add",
"offsetWidth",
"and",
"offsetHeight",
"to",
"get",
"the",
"total",
"page",
"offset",
"for",
"a",
"given",
"element",
".",
"Used",
"by",
"Opera",
"and",
"iOS",
"on",
"hover",
"and",
"all",
"browsers",
"on",
"point",
"click",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L12423-L12436
|
13,701
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
placeBox
|
function placeBox(boxWidth, boxHeight, outerLeft, outerTop, outerWidth, outerHeight, point) {
// keep the box within the chart area
var pointX = point.x,
pointY = point.y,
x = pointX - boxWidth + outerLeft - 25,
y = pointY - boxHeight + outerTop + 10,
alignedRight;
// it is too far to the left, adjust it
if (x < 7) {
x = outerLeft + pointX + 15;
}
// Test to see if the tooltip is to far to the right,
// if it is, move it back to be inside and then up to not cover the point.
if ((x + boxWidth) > (outerLeft + outerWidth)) {
// PATCH by Simon Fishel
//
// if the tooltip is too wide for the plot area, clip it left not right
//
// - x -= (x + boxWidth) - (outerLeft + outerWidth);
// + if(boxWidth > outerWidth) {
// + x = 7;
// + }
// + else {
// + x -= (x + boxWidth) - (outerLeft + outerWidth);
// + }
if(boxWidth > outerWidth) {
x = 7;
}
else {
x -= (x + boxWidth) - (outerLeft + outerWidth);
}
y -= boxHeight;
alignedRight = true;
}
if (y < 5) {
y = 5; // above
// If the tooltip is still covering the point, move it below instead
if (alignedRight && pointY >= y && pointY <= (y + boxHeight)) {
y = pointY + boxHeight - 5; // below
}
} else if (y + boxHeight > outerTop + outerHeight) {
y = outerTop + outerHeight - boxHeight - 5; // below
}
return {x: x, y: y};
}
|
javascript
|
function placeBox(boxWidth, boxHeight, outerLeft, outerTop, outerWidth, outerHeight, point) {
// keep the box within the chart area
var pointX = point.x,
pointY = point.y,
x = pointX - boxWidth + outerLeft - 25,
y = pointY - boxHeight + outerTop + 10,
alignedRight;
// it is too far to the left, adjust it
if (x < 7) {
x = outerLeft + pointX + 15;
}
// Test to see if the tooltip is to far to the right,
// if it is, move it back to be inside and then up to not cover the point.
if ((x + boxWidth) > (outerLeft + outerWidth)) {
// PATCH by Simon Fishel
//
// if the tooltip is too wide for the plot area, clip it left not right
//
// - x -= (x + boxWidth) - (outerLeft + outerWidth);
// + if(boxWidth > outerWidth) {
// + x = 7;
// + }
// + else {
// + x -= (x + boxWidth) - (outerLeft + outerWidth);
// + }
if(boxWidth > outerWidth) {
x = 7;
}
else {
x -= (x + boxWidth) - (outerLeft + outerWidth);
}
y -= boxHeight;
alignedRight = true;
}
if (y < 5) {
y = 5; // above
// If the tooltip is still covering the point, move it below instead
if (alignedRight && pointY >= y && pointY <= (y + boxHeight)) {
y = pointY + boxHeight - 5; // below
}
} else if (y + boxHeight > outerTop + outerHeight) {
y = outerTop + outerHeight - boxHeight - 5; // below
}
return {x: x, y: y};
}
|
[
"function",
"placeBox",
"(",
"boxWidth",
",",
"boxHeight",
",",
"outerLeft",
",",
"outerTop",
",",
"outerWidth",
",",
"outerHeight",
",",
"point",
")",
"{",
"// keep the box within the chart area\r",
"var",
"pointX",
"=",
"point",
".",
"x",
",",
"pointY",
"=",
"point",
".",
"y",
",",
"x",
"=",
"pointX",
"-",
"boxWidth",
"+",
"outerLeft",
"-",
"25",
",",
"y",
"=",
"pointY",
"-",
"boxHeight",
"+",
"outerTop",
"+",
"10",
",",
"alignedRight",
";",
"// it is too far to the left, adjust it\r",
"if",
"(",
"x",
"<",
"7",
")",
"{",
"x",
"=",
"outerLeft",
"+",
"pointX",
"+",
"15",
";",
"}",
"// Test to see if the tooltip is to far to the right,\r",
"// if it is, move it back to be inside and then up to not cover the point.\r",
"if",
"(",
"(",
"x",
"+",
"boxWidth",
")",
">",
"(",
"outerLeft",
"+",
"outerWidth",
")",
")",
"{",
"// PATCH by Simon Fishel\r",
"//\r",
"// if the tooltip is too wide for the plot area, clip it left not right\r",
"//\r",
"// - x -= (x + boxWidth) - (outerLeft + outerWidth);\r",
"// + if(boxWidth > outerWidth) {\r",
"// + x = 7;\r",
"// + }\r",
"// + else {\r",
"// + x -= (x + boxWidth) - (outerLeft + outerWidth);\r",
"// + }\r",
"if",
"(",
"boxWidth",
">",
"outerWidth",
")",
"{",
"x",
"=",
"7",
";",
"}",
"else",
"{",
"x",
"-=",
"(",
"x",
"+",
"boxWidth",
")",
"-",
"(",
"outerLeft",
"+",
"outerWidth",
")",
";",
"}",
"y",
"-=",
"boxHeight",
";",
"alignedRight",
"=",
"true",
";",
"}",
"if",
"(",
"y",
"<",
"5",
")",
"{",
"y",
"=",
"5",
";",
"// above\r",
"// If the tooltip is still covering the point, move it below instead\r",
"if",
"(",
"alignedRight",
"&&",
"pointY",
">=",
"y",
"&&",
"pointY",
"<=",
"(",
"y",
"+",
"boxHeight",
")",
")",
"{",
"y",
"=",
"pointY",
"+",
"boxHeight",
"-",
"5",
";",
"// below\r",
"}",
"}",
"else",
"if",
"(",
"y",
"+",
"boxHeight",
">",
"outerTop",
"+",
"outerHeight",
")",
"{",
"y",
"=",
"outerTop",
"+",
"outerHeight",
"-",
"boxHeight",
"-",
"5",
";",
"// below\r",
"}",
"return",
"{",
"x",
":",
"x",
",",
"y",
":",
"y",
"}",
";",
"}"
] |
Utility method extracted from Tooltip code that places a tooltip in a chart without spilling over
and not covering the point it self.
|
[
"Utility",
"method",
"extracted",
"from",
"Tooltip",
"code",
"that",
"places",
"a",
"tooltip",
"in",
"a",
"chart",
"without",
"spilling",
"over",
"and",
"not",
"covering",
"the",
"point",
"it",
"self",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L12470-L12521
|
13,702
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
stableSort
|
function stableSort(arr, sortFunction) {
var length = arr.length,
i;
// Add index to each item
for (i = 0; i < length; i++) {
arr[i].ss_i = i; // stable sort index
}
arr.sort(function (a, b) {
var sortValue = sortFunction(a, b);
return sortValue === 0 ? a.ss_i - b.ss_i : sortValue;
});
// Remove index from items
for (i = 0; i < length; i++) {
delete arr[i].ss_i; // stable sort index
}
}
|
javascript
|
function stableSort(arr, sortFunction) {
var length = arr.length,
i;
// Add index to each item
for (i = 0; i < length; i++) {
arr[i].ss_i = i; // stable sort index
}
arr.sort(function (a, b) {
var sortValue = sortFunction(a, b);
return sortValue === 0 ? a.ss_i - b.ss_i : sortValue;
});
// Remove index from items
for (i = 0; i < length; i++) {
delete arr[i].ss_i; // stable sort index
}
}
|
[
"function",
"stableSort",
"(",
"arr",
",",
"sortFunction",
")",
"{",
"var",
"length",
"=",
"arr",
".",
"length",
",",
"i",
";",
"// Add index to each item\r",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"arr",
"[",
"i",
"]",
".",
"ss_i",
"=",
"i",
";",
"// stable sort index\r",
"}",
"arr",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"sortValue",
"=",
"sortFunction",
"(",
"a",
",",
"b",
")",
";",
"return",
"sortValue",
"===",
"0",
"?",
"a",
".",
"ss_i",
"-",
"b",
".",
"ss_i",
":",
"sortValue",
";",
"}",
")",
";",
"// Remove index from items\r",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"delete",
"arr",
"[",
"i",
"]",
".",
"ss_i",
";",
"// stable sort index\r",
"}",
"}"
] |
Utility method that sorts an object array and keeping the order of equal items.
ECMA script standard does not specify the behaviour when items are equal.
|
[
"Utility",
"method",
"that",
"sorts",
"an",
"object",
"array",
"and",
"keeping",
"the",
"order",
"of",
"equal",
"items",
".",
"ECMA",
"script",
"standard",
"does",
"not",
"specify",
"the",
"behaviour",
"when",
"items",
"are",
"equal",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L12527-L12545
|
13,703
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function (start, end, pos, complete) {
var ret = [],
i = start.length,
startVal;
if (pos === 1) { // land on the final path without adjustment points appended in the ends
ret = complete;
} else if (i === end.length && pos < 1) {
while (i--) {
startVal = parseFloat(start[i]);
ret[i] =
isNaN(startVal) ? // a letter instruction like M or L
start[i] :
pos * (parseFloat(end[i] - startVal)) + startVal;
}
} else { // if animation is finished or length not matching, land on right value
ret = end;
}
return ret;
}
|
javascript
|
function (start, end, pos, complete) {
var ret = [],
i = start.length,
startVal;
if (pos === 1) { // land on the final path without adjustment points appended in the ends
ret = complete;
} else if (i === end.length && pos < 1) {
while (i--) {
startVal = parseFloat(start[i]);
ret[i] =
isNaN(startVal) ? // a letter instruction like M or L
start[i] :
pos * (parseFloat(end[i] - startVal)) + startVal;
}
} else { // if animation is finished or length not matching, land on right value
ret = end;
}
return ret;
}
|
[
"function",
"(",
"start",
",",
"end",
",",
"pos",
",",
"complete",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
",",
"i",
"=",
"start",
".",
"length",
",",
"startVal",
";",
"if",
"(",
"pos",
"===",
"1",
")",
"{",
"// land on the final path without adjustment points appended in the ends\r",
"ret",
"=",
"complete",
";",
"}",
"else",
"if",
"(",
"i",
"===",
"end",
".",
"length",
"&&",
"pos",
"<",
"1",
")",
"{",
"while",
"(",
"i",
"--",
")",
"{",
"startVal",
"=",
"parseFloat",
"(",
"start",
"[",
"i",
"]",
")",
";",
"ret",
"[",
"i",
"]",
"=",
"isNaN",
"(",
"startVal",
")",
"?",
"// a letter instruction like M or L\r",
"start",
"[",
"i",
"]",
":",
"pos",
"*",
"(",
"parseFloat",
"(",
"end",
"[",
"i",
"]",
"-",
"startVal",
")",
")",
"+",
"startVal",
";",
"}",
"}",
"else",
"{",
"// if animation is finished or length not matching, land on right value\r",
"ret",
"=",
"end",
";",
"}",
"return",
"ret",
";",
"}"
] |
Interpolate each value of the path and return the array
|
[
"Interpolate",
"each",
"value",
"of",
"the",
"path",
"and",
"return",
"the",
"array"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L12637-L12658
|
|
13,704
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function () {
var element = this.element,
childNodes = element.childNodes,
i = childNodes.length;
while (i--) {
element.removeChild(childNodes[i]);
}
}
|
javascript
|
function () {
var element = this.element,
childNodes = element.childNodes,
i = childNodes.length;
while (i--) {
element.removeChild(childNodes[i]);
}
}
|
[
"function",
"(",
")",
"{",
"var",
"element",
"=",
"this",
".",
"element",
",",
"childNodes",
"=",
"element",
".",
"childNodes",
",",
"i",
"=",
"childNodes",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"element",
".",
"removeChild",
"(",
"childNodes",
"[",
"i",
"]",
")",
";",
"}",
"}"
] |
Empty a group element
|
[
"Empty",
"a",
"group",
"element"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L14257-L14265
|
|
13,705
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function (points, width) {
// points format: [M, 0, 0, L, 100, 0]
// normalize to a crisp line
if (points[1] === points[4]) {
points[1] = points[4] = mathRound(points[1]) + (width % 2 / 2);
}
if (points[2] === points[5]) {
points[2] = points[5] = mathRound(points[2]) + (width % 2 / 2);
}
return points;
}
|
javascript
|
function (points, width) {
// points format: [M, 0, 0, L, 100, 0]
// normalize to a crisp line
if (points[1] === points[4]) {
points[1] = points[4] = mathRound(points[1]) + (width % 2 / 2);
}
if (points[2] === points[5]) {
points[2] = points[5] = mathRound(points[2]) + (width % 2 / 2);
}
return points;
}
|
[
"function",
"(",
"points",
",",
"width",
")",
"{",
"// points format: [M, 0, 0, L, 100, 0]\r",
"// normalize to a crisp line\r",
"if",
"(",
"points",
"[",
"1",
"]",
"===",
"points",
"[",
"4",
"]",
")",
"{",
"points",
"[",
"1",
"]",
"=",
"points",
"[",
"4",
"]",
"=",
"mathRound",
"(",
"points",
"[",
"1",
"]",
")",
"+",
"(",
"width",
"%",
"2",
"/",
"2",
")",
";",
"}",
"if",
"(",
"points",
"[",
"2",
"]",
"===",
"points",
"[",
"5",
"]",
")",
"{",
"points",
"[",
"2",
"]",
"=",
"points",
"[",
"5",
"]",
"=",
"mathRound",
"(",
"points",
"[",
"2",
"]",
")",
"+",
"(",
"width",
"%",
"2",
"/",
"2",
")",
";",
"}",
"return",
"points",
";",
"}"
] |
Make a straight line crisper by not spilling out to neighbour pixels
@param {Array} points
@param {Number} width
|
[
"Make",
"a",
"straight",
"line",
"crisper",
"by",
"not",
"spilling",
"out",
"to",
"neighbour",
"pixels"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L14572-L14582
|
|
13,706
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function (x, y, r, innerR, start, end) {
// arcs are defined as symbols for the ability to set
// attributes in attr and animate
if (isObject(x)) {
y = x.y;
r = x.r;
innerR = x.innerR;
start = x.start;
end = x.end;
x = x.x;
}
return this.symbol('arc', x || 0, y || 0, r || 0, {
innerR: innerR || 0,
start: start || 0,
end: end || 0
});
}
|
javascript
|
function (x, y, r, innerR, start, end) {
// arcs are defined as symbols for the ability to set
// attributes in attr and animate
if (isObject(x)) {
y = x.y;
r = x.r;
innerR = x.innerR;
start = x.start;
end = x.end;
x = x.x;
}
return this.symbol('arc', x || 0, y || 0, r || 0, {
innerR: innerR || 0,
start: start || 0,
end: end || 0
});
}
|
[
"function",
"(",
"x",
",",
"y",
",",
"r",
",",
"innerR",
",",
"start",
",",
"end",
")",
"{",
"// arcs are defined as symbols for the ability to set\r",
"// attributes in attr and animate\r",
"if",
"(",
"isObject",
"(",
"x",
")",
")",
"{",
"y",
"=",
"x",
".",
"y",
";",
"r",
"=",
"x",
".",
"r",
";",
"innerR",
"=",
"x",
".",
"innerR",
";",
"start",
"=",
"x",
".",
"start",
";",
"end",
"=",
"x",
".",
"end",
";",
"x",
"=",
"x",
".",
"x",
";",
"}",
"return",
"this",
".",
"symbol",
"(",
"'arc'",
",",
"x",
"||",
"0",
",",
"y",
"||",
"0",
",",
"r",
"||",
"0",
",",
"{",
"innerR",
":",
"innerR",
"||",
"0",
",",
"start",
":",
"start",
"||",
"0",
",",
"end",
":",
"end",
"||",
"0",
"}",
")",
";",
"}"
] |
Draw and return an arc
@param {Number} x X position
@param {Number} y Y position
@param {Number} r Radius
@param {Number} innerR Inner radius like used in donut charts
@param {Number} start Starting angle
@param {Number} end Ending angle
|
[
"Draw",
"and",
"return",
"an",
"arc"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L14623-L14641
|
|
13,707
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function (name) {
var elem = this.createElement('g');
return defined(name) ? elem.attr({ 'class': PREFIX + name }) : elem;
}
|
javascript
|
function (name) {
var elem = this.createElement('g');
return defined(name) ? elem.attr({ 'class': PREFIX + name }) : elem;
}
|
[
"function",
"(",
"name",
")",
"{",
"var",
"elem",
"=",
"this",
".",
"createElement",
"(",
"'g'",
")",
";",
"return",
"defined",
"(",
"name",
")",
"?",
"elem",
".",
"attr",
"(",
"{",
"'class'",
":",
"PREFIX",
"+",
"name",
"}",
")",
":",
"elem",
";",
"}"
] |
Create a group
@param {String} name The group will be given a class name of 'highcharts-{name}'.
This can be used for styling and scripting.
|
[
"Create",
"a",
"group"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L14700-L14703
|
|
13,708
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function (x, y, width, height) {
var wrapper,
id = PREFIX + idCounter++,
clipPath = this.createElement('clipPath').attr({
id: id
}).add(this.defs);
wrapper = this.rect(x, y, width, height, 0).add(clipPath);
wrapper.id = id;
wrapper.clipPath = clipPath;
return wrapper;
}
|
javascript
|
function (x, y, width, height) {
var wrapper,
id = PREFIX + idCounter++,
clipPath = this.createElement('clipPath').attr({
id: id
}).add(this.defs);
wrapper = this.rect(x, y, width, height, 0).add(clipPath);
wrapper.id = id;
wrapper.clipPath = clipPath;
return wrapper;
}
|
[
"function",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
"{",
"var",
"wrapper",
",",
"id",
"=",
"PREFIX",
"+",
"idCounter",
"++",
",",
"clipPath",
"=",
"this",
".",
"createElement",
"(",
"'clipPath'",
")",
".",
"attr",
"(",
"{",
"id",
":",
"id",
"}",
")",
".",
"add",
"(",
"this",
".",
"defs",
")",
";",
"wrapper",
"=",
"this",
".",
"rect",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
",",
"0",
")",
".",
"add",
"(",
"clipPath",
")",
";",
"wrapper",
".",
"id",
"=",
"id",
";",
"wrapper",
".",
"clipPath",
"=",
"clipPath",
";",
"return",
"wrapper",
";",
"}"
] |
Define a clipping rectangle
@param {String} id
@param {Number} x
@param {Number} y
@param {Number} width
@param {Number} height
|
[
"Define",
"a",
"clipping",
"rectangle"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L14922-L14935
|
|
13,709
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function (color, elem, prop) {
var colorObject,
regexRgba = /^rgba/;
if (color && color.linearGradient) {
var renderer = this,
strLinearGradient = 'linearGradient',
linearGradient = color[strLinearGradient],
id = PREFIX + idCounter++,
gradientObject,
stopColor,
stopOpacity;
gradientObject = renderer.createElement(strLinearGradient).attr({
id: id,
gradientUnits: 'userSpaceOnUse',
x1: linearGradient[0],
y1: linearGradient[1],
x2: linearGradient[2],
y2: linearGradient[3]
}).add(renderer.defs);
// Keep a reference to the gradient object so it is possible to destroy it later
renderer.gradients.push(gradientObject);
// The gradient needs to keep a list of stops to be able to destroy them
gradientObject.stops = [];
each(color.stops, function (stop) {
var stopObject;
if (regexRgba.test(stop[1])) {
colorObject = Color(stop[1]);
stopColor = colorObject.get('rgb');
stopOpacity = colorObject.get('a');
} else {
stopColor = stop[1];
stopOpacity = 1;
}
stopObject = renderer.createElement('stop').attr({
offset: stop[0],
'stop-color': stopColor,
'stop-opacity': stopOpacity
}).add(gradientObject);
// Add the stop element to the gradient
gradientObject.stops.push(stopObject);
});
return 'url(' + this.url + '#' + id + ')';
// Webkit and Batik can't show rgba.
} else if (regexRgba.test(color)) {
colorObject = Color(color);
attr(elem, prop + '-opacity', colorObject.get('a'));
return colorObject.get('rgb');
} else {
// Remove the opacity attribute added above. Does not throw if the attribute is not there.
elem.removeAttribute(prop + '-opacity');
return color;
}
}
|
javascript
|
function (color, elem, prop) {
var colorObject,
regexRgba = /^rgba/;
if (color && color.linearGradient) {
var renderer = this,
strLinearGradient = 'linearGradient',
linearGradient = color[strLinearGradient],
id = PREFIX + idCounter++,
gradientObject,
stopColor,
stopOpacity;
gradientObject = renderer.createElement(strLinearGradient).attr({
id: id,
gradientUnits: 'userSpaceOnUse',
x1: linearGradient[0],
y1: linearGradient[1],
x2: linearGradient[2],
y2: linearGradient[3]
}).add(renderer.defs);
// Keep a reference to the gradient object so it is possible to destroy it later
renderer.gradients.push(gradientObject);
// The gradient needs to keep a list of stops to be able to destroy them
gradientObject.stops = [];
each(color.stops, function (stop) {
var stopObject;
if (regexRgba.test(stop[1])) {
colorObject = Color(stop[1]);
stopColor = colorObject.get('rgb');
stopOpacity = colorObject.get('a');
} else {
stopColor = stop[1];
stopOpacity = 1;
}
stopObject = renderer.createElement('stop').attr({
offset: stop[0],
'stop-color': stopColor,
'stop-opacity': stopOpacity
}).add(gradientObject);
// Add the stop element to the gradient
gradientObject.stops.push(stopObject);
});
return 'url(' + this.url + '#' + id + ')';
// Webkit and Batik can't show rgba.
} else if (regexRgba.test(color)) {
colorObject = Color(color);
attr(elem, prop + '-opacity', colorObject.get('a'));
return colorObject.get('rgb');
} else {
// Remove the opacity attribute added above. Does not throw if the attribute is not there.
elem.removeAttribute(prop + '-opacity');
return color;
}
}
|
[
"function",
"(",
"color",
",",
"elem",
",",
"prop",
")",
"{",
"var",
"colorObject",
",",
"regexRgba",
"=",
"/",
"^rgba",
"/",
";",
"if",
"(",
"color",
"&&",
"color",
".",
"linearGradient",
")",
"{",
"var",
"renderer",
"=",
"this",
",",
"strLinearGradient",
"=",
"'linearGradient'",
",",
"linearGradient",
"=",
"color",
"[",
"strLinearGradient",
"]",
",",
"id",
"=",
"PREFIX",
"+",
"idCounter",
"++",
",",
"gradientObject",
",",
"stopColor",
",",
"stopOpacity",
";",
"gradientObject",
"=",
"renderer",
".",
"createElement",
"(",
"strLinearGradient",
")",
".",
"attr",
"(",
"{",
"id",
":",
"id",
",",
"gradientUnits",
":",
"'userSpaceOnUse'",
",",
"x1",
":",
"linearGradient",
"[",
"0",
"]",
",",
"y1",
":",
"linearGradient",
"[",
"1",
"]",
",",
"x2",
":",
"linearGradient",
"[",
"2",
"]",
",",
"y2",
":",
"linearGradient",
"[",
"3",
"]",
"}",
")",
".",
"add",
"(",
"renderer",
".",
"defs",
")",
";",
"// Keep a reference to the gradient object so it is possible to destroy it later\r",
"renderer",
".",
"gradients",
".",
"push",
"(",
"gradientObject",
")",
";",
"// The gradient needs to keep a list of stops to be able to destroy them\r",
"gradientObject",
".",
"stops",
"=",
"[",
"]",
";",
"each",
"(",
"color",
".",
"stops",
",",
"function",
"(",
"stop",
")",
"{",
"var",
"stopObject",
";",
"if",
"(",
"regexRgba",
".",
"test",
"(",
"stop",
"[",
"1",
"]",
")",
")",
"{",
"colorObject",
"=",
"Color",
"(",
"stop",
"[",
"1",
"]",
")",
";",
"stopColor",
"=",
"colorObject",
".",
"get",
"(",
"'rgb'",
")",
";",
"stopOpacity",
"=",
"colorObject",
".",
"get",
"(",
"'a'",
")",
";",
"}",
"else",
"{",
"stopColor",
"=",
"stop",
"[",
"1",
"]",
";",
"stopOpacity",
"=",
"1",
";",
"}",
"stopObject",
"=",
"renderer",
".",
"createElement",
"(",
"'stop'",
")",
".",
"attr",
"(",
"{",
"offset",
":",
"stop",
"[",
"0",
"]",
",",
"'stop-color'",
":",
"stopColor",
",",
"'stop-opacity'",
":",
"stopOpacity",
"}",
")",
".",
"add",
"(",
"gradientObject",
")",
";",
"// Add the stop element to the gradient\r",
"gradientObject",
".",
"stops",
".",
"push",
"(",
"stopObject",
")",
";",
"}",
")",
";",
"return",
"'url('",
"+",
"this",
".",
"url",
"+",
"'#'",
"+",
"id",
"+",
"')'",
";",
"// Webkit and Batik can't show rgba.\r",
"}",
"else",
"if",
"(",
"regexRgba",
".",
"test",
"(",
"color",
")",
")",
"{",
"colorObject",
"=",
"Color",
"(",
"color",
")",
";",
"attr",
"(",
"elem",
",",
"prop",
"+",
"'-opacity'",
",",
"colorObject",
".",
"get",
"(",
"'a'",
")",
")",
";",
"return",
"colorObject",
".",
"get",
"(",
"'rgb'",
")",
";",
"}",
"else",
"{",
"// Remove the opacity attribute added above. Does not throw if the attribute is not there.\r",
"elem",
".",
"removeAttribute",
"(",
"prop",
"+",
"'-opacity'",
")",
";",
"return",
"color",
";",
"}",
"}"
] |
Take a color and return it if it's a string, make it a gradient if it's a
gradient configuration object
@param {Object} color The color or config object
|
[
"Take",
"a",
"color",
"and",
"return",
"it",
"if",
"it",
"s",
"a",
"string",
"make",
"it",
"a",
"gradient",
"if",
"it",
"s",
"a",
"gradient",
"configuration",
"object"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L14944-L15006
|
|
13,710
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function (renderer, nodeName) {
var markup = ['<', nodeName, ' filled="f" stroked="f"'],
style = ['position: ', ABSOLUTE, ';'];
// divs and shapes need size
if (nodeName === 'shape' || nodeName === DIV) {
style.push('left:0;top:0;width:10px;height:10px;');
}
if (docMode8) {
style.push('visibility: ', nodeName === DIV ? HIDDEN : VISIBLE);
}
markup.push(' style="', style.join(''), '"/>');
// create element with default attributes and style
if (nodeName) {
markup = nodeName === DIV || nodeName === 'span' || nodeName === 'img' ?
markup.join('')
: renderer.prepVML(markup);
this.element = createElement(markup);
}
this.renderer = renderer;
}
|
javascript
|
function (renderer, nodeName) {
var markup = ['<', nodeName, ' filled="f" stroked="f"'],
style = ['position: ', ABSOLUTE, ';'];
// divs and shapes need size
if (nodeName === 'shape' || nodeName === DIV) {
style.push('left:0;top:0;width:10px;height:10px;');
}
if (docMode8) {
style.push('visibility: ', nodeName === DIV ? HIDDEN : VISIBLE);
}
markup.push(' style="', style.join(''), '"/>');
// create element with default attributes and style
if (nodeName) {
markup = nodeName === DIV || nodeName === 'span' || nodeName === 'img' ?
markup.join('')
: renderer.prepVML(markup);
this.element = createElement(markup);
}
this.renderer = renderer;
}
|
[
"function",
"(",
"renderer",
",",
"nodeName",
")",
"{",
"var",
"markup",
"=",
"[",
"'<'",
",",
"nodeName",
",",
"' filled=\"f\" stroked=\"f\"'",
"]",
",",
"style",
"=",
"[",
"'position: '",
",",
"ABSOLUTE",
",",
"';'",
"]",
";",
"// divs and shapes need size\r",
"if",
"(",
"nodeName",
"===",
"'shape'",
"||",
"nodeName",
"===",
"DIV",
")",
"{",
"style",
".",
"push",
"(",
"'left:0;top:0;width:10px;height:10px;'",
")",
";",
"}",
"if",
"(",
"docMode8",
")",
"{",
"style",
".",
"push",
"(",
"'visibility: '",
",",
"nodeName",
"===",
"DIV",
"?",
"HIDDEN",
":",
"VISIBLE",
")",
";",
"}",
"markup",
".",
"push",
"(",
"' style=\"'",
",",
"style",
".",
"join",
"(",
"''",
")",
",",
"'\"/>'",
")",
";",
"// create element with default attributes and style\r",
"if",
"(",
"nodeName",
")",
"{",
"markup",
"=",
"nodeName",
"===",
"DIV",
"||",
"nodeName",
"===",
"'span'",
"||",
"nodeName",
"===",
"'img'",
"?",
"markup",
".",
"join",
"(",
"''",
")",
":",
"renderer",
".",
"prepVML",
"(",
"markup",
")",
";",
"this",
".",
"element",
"=",
"createElement",
"(",
"markup",
")",
";",
"}",
"this",
".",
"renderer",
"=",
"renderer",
";",
"}"
] |
Initialize a new VML element wrapper. It builds the markup as a string
to minimize DOM traffic.
@param {Object} renderer
@param {Object} nodeName
|
[
"Initialize",
"a",
"new",
"VML",
"element",
"wrapper",
".",
"It",
"builds",
"the",
"markup",
"as",
"a",
"string",
"to",
"minimize",
"DOM",
"traffic",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L15070-L15093
|
|
13,711
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function () {
var wrapper = this;
if (wrapper.destroyClip) {
wrapper.destroyClip();
}
return SVGElement.prototype.destroy.apply(wrapper);
}
|
javascript
|
function () {
var wrapper = this;
if (wrapper.destroyClip) {
wrapper.destroyClip();
}
return SVGElement.prototype.destroy.apply(wrapper);
}
|
[
"function",
"(",
")",
"{",
"var",
"wrapper",
"=",
"this",
";",
"if",
"(",
"wrapper",
".",
"destroyClip",
")",
"{",
"wrapper",
".",
"destroyClip",
"(",
")",
";",
"}",
"return",
"SVGElement",
".",
"prototype",
".",
"destroy",
".",
"apply",
"(",
"wrapper",
")",
";",
"}"
] |
Extend element.destroy by removing it from the clip members array
|
[
"Extend",
"element",
".",
"destroy",
"by",
"removing",
"it",
"from",
"the",
"clip",
"members",
"array"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L15401-L15409
|
|
13,712
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function (eventType, handler) {
// simplest possible event model for internal use
this.element['on' + eventType] = function () {
var evt = win.event;
evt.target = evt.srcElement;
handler(evt);
};
return this;
}
|
javascript
|
function (eventType, handler) {
// simplest possible event model for internal use
this.element['on' + eventType] = function () {
var evt = win.event;
evt.target = evt.srcElement;
handler(evt);
};
return this;
}
|
[
"function",
"(",
"eventType",
",",
"handler",
")",
"{",
"// simplest possible event model for internal use\r",
"this",
".",
"element",
"[",
"'on'",
"+",
"eventType",
"]",
"=",
"function",
"(",
")",
"{",
"var",
"evt",
"=",
"win",
".",
"event",
";",
"evt",
".",
"target",
"=",
"evt",
".",
"srcElement",
";",
"handler",
"(",
"evt",
")",
";",
"}",
";",
"return",
"this",
";",
"}"
] |
Add an event listener. VML override for normalizing event parameters.
@param {String} eventType
@param {Function} handler
|
[
"Add",
"an",
"event",
"listener",
".",
"VML",
"override",
"for",
"normalizing",
"event",
"parameters",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L15459-L15467
|
|
13,713
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function (str, x, y) {
var defaultChartStyle = defaultOptions.chart.style;
return this.createElement('span')
.attr({
text: str,
x: mathRound(x),
y: mathRound(y)
})
.css({
whiteSpace: 'nowrap',
fontFamily: defaultChartStyle.fontFamily,
fontSize: defaultChartStyle.fontSize
});
}
|
javascript
|
function (str, x, y) {
var defaultChartStyle = defaultOptions.chart.style;
return this.createElement('span')
.attr({
text: str,
x: mathRound(x),
y: mathRound(y)
})
.css({
whiteSpace: 'nowrap',
fontFamily: defaultChartStyle.fontFamily,
fontSize: defaultChartStyle.fontSize
});
}
|
[
"function",
"(",
"str",
",",
"x",
",",
"y",
")",
"{",
"var",
"defaultChartStyle",
"=",
"defaultOptions",
".",
"chart",
".",
"style",
";",
"return",
"this",
".",
"createElement",
"(",
"'span'",
")",
".",
"attr",
"(",
"{",
"text",
":",
"str",
",",
"x",
":",
"mathRound",
"(",
"x",
")",
",",
"y",
":",
"mathRound",
"(",
"y",
")",
"}",
")",
".",
"css",
"(",
"{",
"whiteSpace",
":",
"'nowrap'",
",",
"fontFamily",
":",
"defaultChartStyle",
".",
"fontFamily",
",",
"fontSize",
":",
"defaultChartStyle",
".",
"fontSize",
"}",
")",
";",
"}"
] |
Create rotated and aligned text
@param {String} str
@param {Number} x
@param {Number} y
|
[
"Create",
"rotated",
"and",
"aligned",
"text"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L15858-L15873
|
|
13,714
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function () {
var value = this.value,
ret;
if (dateTimeLabelFormat) { // datetime axis
ret = dateFormat(dateTimeLabelFormat, value);
} else if (tickInterval % 1000000 === 0) { // use M abbreviation
ret = (value / 1000000) + 'M';
} else if (tickInterval % 1000 === 0) { // use k abbreviation
ret = (value / 1000) + 'k';
} else if (!categories && value >= 1000) { // add thousands separators
ret = numberFormat(value, 0);
} else { // strings (categories) and small numbers
ret = value;
}
return ret;
}
|
javascript
|
function () {
var value = this.value,
ret;
if (dateTimeLabelFormat) { // datetime axis
ret = dateFormat(dateTimeLabelFormat, value);
} else if (tickInterval % 1000000 === 0) { // use M abbreviation
ret = (value / 1000000) + 'M';
} else if (tickInterval % 1000 === 0) { // use k abbreviation
ret = (value / 1000) + 'k';
} else if (!categories && value >= 1000) { // add thousands separators
ret = numberFormat(value, 0);
} else { // strings (categories) and small numbers
ret = value;
}
return ret;
}
|
[
"function",
"(",
")",
"{",
"var",
"value",
"=",
"this",
".",
"value",
",",
"ret",
";",
"if",
"(",
"dateTimeLabelFormat",
")",
"{",
"// datetime axis\r",
"ret",
"=",
"dateFormat",
"(",
"dateTimeLabelFormat",
",",
"value",
")",
";",
"}",
"else",
"if",
"(",
"tickInterval",
"%",
"1000000",
"===",
"0",
")",
"{",
"// use M abbreviation\r",
"ret",
"=",
"(",
"value",
"/",
"1000000",
")",
"+",
"'M'",
";",
"}",
"else",
"if",
"(",
"tickInterval",
"%",
"1000",
"===",
"0",
")",
"{",
"// use k abbreviation\r",
"ret",
"=",
"(",
"value",
"/",
"1000",
")",
"+",
"'k'",
";",
"}",
"else",
"if",
"(",
"!",
"categories",
"&&",
"value",
">=",
"1000",
")",
"{",
"// add thousands separators\r",
"ret",
"=",
"numberFormat",
"(",
"value",
",",
"0",
")",
";",
"}",
"else",
"{",
"// strings (categories) and small numbers\r",
"ret",
"=",
"value",
";",
"}",
"return",
"ret",
";",
"}"
] |
can be overwritten by dynamic format
|
[
"can",
"be",
"overwritten",
"by",
"dynamic",
"format"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L16283-L16303
|
|
13,715
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
Tick
|
function Tick(pos, minor) {
var tick = this;
tick.pos = pos;
tick.minor = minor;
tick.isNew = true;
if (!minor) {
tick.addLabel();
}
}
|
javascript
|
function Tick(pos, minor) {
var tick = this;
tick.pos = pos;
tick.minor = minor;
tick.isNew = true;
if (!minor) {
tick.addLabel();
}
}
|
[
"function",
"Tick",
"(",
"pos",
",",
"minor",
")",
"{",
"var",
"tick",
"=",
"this",
";",
"tick",
".",
"pos",
"=",
"pos",
";",
"tick",
".",
"minor",
"=",
"minor",
";",
"tick",
".",
"isNew",
"=",
"true",
";",
"if",
"(",
"!",
"minor",
")",
"{",
"tick",
".",
"addLabel",
"(",
")",
";",
"}",
"}"
] |
The Tick class
|
[
"The",
"Tick",
"class"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L16320-L16329
|
13,716
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
StackItem
|
function StackItem(options, isNegative, x, stackOption) {
var stackItem = this;
// Tells if the stack is negative
stackItem.isNegative = isNegative;
// Save the options to be able to style the label
stackItem.options = options;
// Save the x value to be able to position the label later
stackItem.x = x;
// Save the stack option on the series configuration object
stackItem.stack = stackOption;
// The align options and text align varies on whether the stack is negative and
// if the chart is inverted or not.
// First test the user supplied value, then use the dynamic.
stackItem.alignOptions = {
align: options.align || (inverted ? (isNegative ? 'left' : 'right') : 'center'),
verticalAlign: options.verticalAlign || (inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
y: pick(options.y, inverted ? 4 : (isNegative ? 14 : -6)),
x: pick(options.x, inverted ? (isNegative ? -6 : 6) : 0)
};
stackItem.textAlign = options.textAlign || (inverted ? (isNegative ? 'right' : 'left') : 'center');
}
|
javascript
|
function StackItem(options, isNegative, x, stackOption) {
var stackItem = this;
// Tells if the stack is negative
stackItem.isNegative = isNegative;
// Save the options to be able to style the label
stackItem.options = options;
// Save the x value to be able to position the label later
stackItem.x = x;
// Save the stack option on the series configuration object
stackItem.stack = stackOption;
// The align options and text align varies on whether the stack is negative and
// if the chart is inverted or not.
// First test the user supplied value, then use the dynamic.
stackItem.alignOptions = {
align: options.align || (inverted ? (isNegative ? 'left' : 'right') : 'center'),
verticalAlign: options.verticalAlign || (inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
y: pick(options.y, inverted ? 4 : (isNegative ? 14 : -6)),
x: pick(options.x, inverted ? (isNegative ? -6 : 6) : 0)
};
stackItem.textAlign = options.textAlign || (inverted ? (isNegative ? 'right' : 'left') : 'center');
}
|
[
"function",
"StackItem",
"(",
"options",
",",
"isNegative",
",",
"x",
",",
"stackOption",
")",
"{",
"var",
"stackItem",
"=",
"this",
";",
"// Tells if the stack is negative\r",
"stackItem",
".",
"isNegative",
"=",
"isNegative",
";",
"// Save the options to be able to style the label\r",
"stackItem",
".",
"options",
"=",
"options",
";",
"// Save the x value to be able to position the label later\r",
"stackItem",
".",
"x",
"=",
"x",
";",
"// Save the stack option on the series configuration object\r",
"stackItem",
".",
"stack",
"=",
"stackOption",
";",
"// The align options and text align varies on whether the stack is negative and\r",
"// if the chart is inverted or not.\r",
"// First test the user supplied value, then use the dynamic.\r",
"stackItem",
".",
"alignOptions",
"=",
"{",
"align",
":",
"options",
".",
"align",
"||",
"(",
"inverted",
"?",
"(",
"isNegative",
"?",
"'left'",
":",
"'right'",
")",
":",
"'center'",
")",
",",
"verticalAlign",
":",
"options",
".",
"verticalAlign",
"||",
"(",
"inverted",
"?",
"'middle'",
":",
"(",
"isNegative",
"?",
"'bottom'",
":",
"'top'",
")",
")",
",",
"y",
":",
"pick",
"(",
"options",
".",
"y",
",",
"inverted",
"?",
"4",
":",
"(",
"isNegative",
"?",
"14",
":",
"-",
"6",
")",
")",
",",
"x",
":",
"pick",
"(",
"options",
".",
"x",
",",
"inverted",
"?",
"(",
"isNegative",
"?",
"-",
"6",
":",
"6",
")",
":",
"0",
")",
"}",
";",
"stackItem",
".",
"textAlign",
"=",
"options",
".",
"textAlign",
"||",
"(",
"inverted",
"?",
"(",
"isNegative",
"?",
"'right'",
":",
"'left'",
")",
":",
"'center'",
")",
";",
"}"
] |
The class for stack items
|
[
"The",
"class",
"for",
"stack",
"items"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L16725-L16751
|
13,717
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
correctFloat
|
function correctFloat(num) {
var invMag, ret = num;
magnitude = pick(magnitude, math.pow(10, mathFloor(math.log(tickInterval) / math.LN10)));
if (magnitude < 1) {
invMag = mathRound(1 / magnitude) * 10;
ret = mathRound(num * invMag) / invMag;
}
return ret;
}
|
javascript
|
function correctFloat(num) {
var invMag, ret = num;
magnitude = pick(magnitude, math.pow(10, mathFloor(math.log(tickInterval) / math.LN10)));
if (magnitude < 1) {
invMag = mathRound(1 / magnitude) * 10;
ret = mathRound(num * invMag) / invMag;
}
return ret;
}
|
[
"function",
"correctFloat",
"(",
"num",
")",
"{",
"var",
"invMag",
",",
"ret",
"=",
"num",
";",
"magnitude",
"=",
"pick",
"(",
"magnitude",
",",
"math",
".",
"pow",
"(",
"10",
",",
"mathFloor",
"(",
"math",
".",
"log",
"(",
"tickInterval",
")",
"/",
"math",
".",
"LN10",
")",
")",
")",
";",
"if",
"(",
"magnitude",
"<",
"1",
")",
"{",
"invMag",
"=",
"mathRound",
"(",
"1",
"/",
"magnitude",
")",
"*",
"10",
";",
"ret",
"=",
"mathRound",
"(",
"num",
"*",
"invMag",
")",
"/",
"invMag",
";",
"}",
"return",
"ret",
";",
"}"
] |
Fix JS round off float errors
@param {Number} num
|
[
"Fix",
"JS",
"round",
"off",
"float",
"errors"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L17252-L17261
|
13,718
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
setCategories
|
function setCategories(newCategories, doRedraw) {
// set the categories
axis.categories = userOptions.categories = categories = newCategories;
// force reindexing tooltips
each(associatedSeries, function (series) {
series.translate();
series.setTooltipPoints(true);
});
// optionally redraw
axis.isDirty = true;
if (pick(doRedraw, true)) {
chart.redraw();
}
}
|
javascript
|
function setCategories(newCategories, doRedraw) {
// set the categories
axis.categories = userOptions.categories = categories = newCategories;
// force reindexing tooltips
each(associatedSeries, function (series) {
series.translate();
series.setTooltipPoints(true);
});
// optionally redraw
axis.isDirty = true;
if (pick(doRedraw, true)) {
chart.redraw();
}
}
|
[
"function",
"setCategories",
"(",
"newCategories",
",",
"doRedraw",
")",
"{",
"// set the categories\r",
"axis",
".",
"categories",
"=",
"userOptions",
".",
"categories",
"=",
"categories",
"=",
"newCategories",
";",
"// force reindexing tooltips\r",
"each",
"(",
"associatedSeries",
",",
"function",
"(",
"series",
")",
"{",
"series",
".",
"translate",
"(",
")",
";",
"series",
".",
"setTooltipPoints",
"(",
"true",
")",
";",
"}",
")",
";",
"// optionally redraw\r",
"axis",
".",
"isDirty",
"=",
"true",
";",
"if",
"(",
"pick",
"(",
"doRedraw",
",",
"true",
")",
")",
"{",
"chart",
".",
"redraw",
"(",
")",
";",
"}",
"}"
] |
Set new axis categories and optionally redraw
@param {Array} newCategories
@param {Boolean} doRedraw
|
[
"Set",
"new",
"axis",
"categories",
"and",
"optionally",
"redraw"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L17942-L17959
|
13,719
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
Toolbar
|
function Toolbar() {
var buttons = {};
/*jslint unparam: true*//* allow the unused param title until Toolbar rewrite*/
function add(id, text, title, fn) {
if (!buttons[id]) {
var button = renderer.text(
text,
0,
0
)
.css(options.toolbar.itemStyle)
.align({
align: 'right',
x: -marginRight - 20,
y: plotTop + 30
})
.on('click', fn)
/*.on('touchstart', function(e) {
e.stopPropagation(); // don't fire the container event
fn();
})*/
.attr({
align: 'right',
zIndex: 20
})
.add();
buttons[id] = button;
}
}
/*jslint unparam: false*/
function remove(id) {
discardElement(buttons[id].element);
buttons[id] = null;
}
// public
return {
add: add,
remove: remove
};
}
|
javascript
|
function Toolbar() {
var buttons = {};
/*jslint unparam: true*//* allow the unused param title until Toolbar rewrite*/
function add(id, text, title, fn) {
if (!buttons[id]) {
var button = renderer.text(
text,
0,
0
)
.css(options.toolbar.itemStyle)
.align({
align: 'right',
x: -marginRight - 20,
y: plotTop + 30
})
.on('click', fn)
/*.on('touchstart', function(e) {
e.stopPropagation(); // don't fire the container event
fn();
})*/
.attr({
align: 'right',
zIndex: 20
})
.add();
buttons[id] = button;
}
}
/*jslint unparam: false*/
function remove(id) {
discardElement(buttons[id].element);
buttons[id] = null;
}
// public
return {
add: add,
remove: remove
};
}
|
[
"function",
"Toolbar",
"(",
")",
"{",
"var",
"buttons",
"=",
"{",
"}",
";",
"/*jslint unparam: true*/",
"/* allow the unused param title until Toolbar rewrite*/",
"function",
"add",
"(",
"id",
",",
"text",
",",
"title",
",",
"fn",
")",
"{",
"if",
"(",
"!",
"buttons",
"[",
"id",
"]",
")",
"{",
"var",
"button",
"=",
"renderer",
".",
"text",
"(",
"text",
",",
"0",
",",
"0",
")",
".",
"css",
"(",
"options",
".",
"toolbar",
".",
"itemStyle",
")",
".",
"align",
"(",
"{",
"align",
":",
"'right'",
",",
"x",
":",
"-",
"marginRight",
"-",
"20",
",",
"y",
":",
"plotTop",
"+",
"30",
"}",
")",
".",
"on",
"(",
"'click'",
",",
"fn",
")",
"/*.on('touchstart', function(e) {\r\n\t\t\t\t\te.stopPropagation(); // don't fire the container event\r\n\t\t\t\t\tfn();\r\n\t\t\t\t})*/",
".",
"attr",
"(",
"{",
"align",
":",
"'right'",
",",
"zIndex",
":",
"20",
"}",
")",
".",
"add",
"(",
")",
";",
"buttons",
"[",
"id",
"]",
"=",
"button",
";",
"}",
"}",
"/*jslint unparam: false*/",
"function",
"remove",
"(",
"id",
")",
"{",
"discardElement",
"(",
"buttons",
"[",
"id",
"]",
".",
"element",
")",
";",
"buttons",
"[",
"id",
"]",
"=",
"null",
";",
"}",
"// public\r",
"return",
"{",
"add",
":",
"add",
",",
"remove",
":",
"remove",
"}",
";",
"}"
] |
end Axis
The toolbar object
|
[
"end",
"Axis",
"The",
"toolbar",
"object"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L18055-L18097
|
13,720
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
defaultFormatter
|
function defaultFormatter() {
var pThis = this,
items = pThis.points || splat(pThis),
xAxis = items[0].series.xAxis,
x = pThis.x,
isDateTime = xAxis && xAxis.options.type === 'datetime',
useHeader = isString(x) || isDateTime,
s;
// build the header
s = useHeader ?
['<span style="font-size: 10px">' +
(isDateTime ? dateFormat('%A, %b %e, %Y', x) : x) +
'</span>'] : [];
// build the values
each(items, function (item) {
s.push(item.point.tooltipFormatter(useHeader));
});
return s.join('<br/>');
}
|
javascript
|
function defaultFormatter() {
var pThis = this,
items = pThis.points || splat(pThis),
xAxis = items[0].series.xAxis,
x = pThis.x,
isDateTime = xAxis && xAxis.options.type === 'datetime',
useHeader = isString(x) || isDateTime,
s;
// build the header
s = useHeader ?
['<span style="font-size: 10px">' +
(isDateTime ? dateFormat('%A, %b %e, %Y', x) : x) +
'</span>'] : [];
// build the values
each(items, function (item) {
s.push(item.point.tooltipFormatter(useHeader));
});
return s.join('<br/>');
}
|
[
"function",
"defaultFormatter",
"(",
")",
"{",
"var",
"pThis",
"=",
"this",
",",
"items",
"=",
"pThis",
".",
"points",
"||",
"splat",
"(",
"pThis",
")",
",",
"xAxis",
"=",
"items",
"[",
"0",
"]",
".",
"series",
".",
"xAxis",
",",
"x",
"=",
"pThis",
".",
"x",
",",
"isDateTime",
"=",
"xAxis",
"&&",
"xAxis",
".",
"options",
".",
"type",
"===",
"'datetime'",
",",
"useHeader",
"=",
"isString",
"(",
"x",
")",
"||",
"isDateTime",
",",
"s",
";",
"// build the header\r",
"s",
"=",
"useHeader",
"?",
"[",
"'<span style=\"font-size: 10px\">'",
"+",
"(",
"isDateTime",
"?",
"dateFormat",
"(",
"'%A, %b %e, %Y'",
",",
"x",
")",
":",
"x",
")",
"+",
"'</span>'",
"]",
":",
"[",
"]",
";",
"// build the values\r",
"each",
"(",
"items",
",",
"function",
"(",
"item",
")",
"{",
"s",
".",
"push",
"(",
"item",
".",
"point",
".",
"tooltipFormatter",
"(",
"useHeader",
")",
")",
";",
"}",
")",
";",
"return",
"s",
".",
"join",
"(",
"'<br/>'",
")",
";",
"}"
] |
In case no user defined formatter is given, this will be used
|
[
"In",
"case",
"no",
"user",
"defined",
"formatter",
"is",
"given",
"this",
"will",
"be",
"used"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L18163-L18183
|
13,721
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
onmousemove
|
function onmousemove(e) {
var point,
points,
hoverPoint = chart.hoverPoint,
hoverSeries = chart.hoverSeries,
i,
j,
distance = chartWidth,
index = inverted ? e.chartY : e.chartX - plotLeft; // wtf?
// shared tooltip
if (tooltip && options.shared) {
points = [];
// loop over all series and find the ones with points closest to the mouse
i = series.length;
for (j = 0; j < i; j++) {
if (series[j].visible && series[j].tooltipPoints.length) {
point = series[j].tooltipPoints[index];
point._dist = mathAbs(index - point.plotX);
distance = mathMin(distance, point._dist);
points.push(point);
}
}
// remove furthest points
i = points.length;
while (i--) {
if (points[i]._dist > distance) {
points.splice(i, 1);
}
}
// refresh the tooltip if necessary
if (points.length && (points[0].plotX !== hoverX)) {
tooltip.refresh(points);
hoverX = points[0].plotX;
}
}
// separate tooltip and general mouse events
if (hoverSeries && hoverSeries.tracker) { // only use for line-type series with common tracker
// get the point
point = hoverSeries.tooltipPoints[index];
// a new point is hovered, refresh the tooltip
if (point && point !== hoverPoint) {
// trigger the events
point.onMouseOver();
}
}
}
|
javascript
|
function onmousemove(e) {
var point,
points,
hoverPoint = chart.hoverPoint,
hoverSeries = chart.hoverSeries,
i,
j,
distance = chartWidth,
index = inverted ? e.chartY : e.chartX - plotLeft; // wtf?
// shared tooltip
if (tooltip && options.shared) {
points = [];
// loop over all series and find the ones with points closest to the mouse
i = series.length;
for (j = 0; j < i; j++) {
if (series[j].visible && series[j].tooltipPoints.length) {
point = series[j].tooltipPoints[index];
point._dist = mathAbs(index - point.plotX);
distance = mathMin(distance, point._dist);
points.push(point);
}
}
// remove furthest points
i = points.length;
while (i--) {
if (points[i]._dist > distance) {
points.splice(i, 1);
}
}
// refresh the tooltip if necessary
if (points.length && (points[0].plotX !== hoverX)) {
tooltip.refresh(points);
hoverX = points[0].plotX;
}
}
// separate tooltip and general mouse events
if (hoverSeries && hoverSeries.tracker) { // only use for line-type series with common tracker
// get the point
point = hoverSeries.tooltipPoints[index];
// a new point is hovered, refresh the tooltip
if (point && point !== hoverPoint) {
// trigger the events
point.onMouseOver();
}
}
}
|
[
"function",
"onmousemove",
"(",
"e",
")",
"{",
"var",
"point",
",",
"points",
",",
"hoverPoint",
"=",
"chart",
".",
"hoverPoint",
",",
"hoverSeries",
"=",
"chart",
".",
"hoverSeries",
",",
"i",
",",
"j",
",",
"distance",
"=",
"chartWidth",
",",
"index",
"=",
"inverted",
"?",
"e",
".",
"chartY",
":",
"e",
".",
"chartX",
"-",
"plotLeft",
";",
"// wtf?\r",
"// shared tooltip\r",
"if",
"(",
"tooltip",
"&&",
"options",
".",
"shared",
")",
"{",
"points",
"=",
"[",
"]",
";",
"// loop over all series and find the ones with points closest to the mouse\r",
"i",
"=",
"series",
".",
"length",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"i",
";",
"j",
"++",
")",
"{",
"if",
"(",
"series",
"[",
"j",
"]",
".",
"visible",
"&&",
"series",
"[",
"j",
"]",
".",
"tooltipPoints",
".",
"length",
")",
"{",
"point",
"=",
"series",
"[",
"j",
"]",
".",
"tooltipPoints",
"[",
"index",
"]",
";",
"point",
".",
"_dist",
"=",
"mathAbs",
"(",
"index",
"-",
"point",
".",
"plotX",
")",
";",
"distance",
"=",
"mathMin",
"(",
"distance",
",",
"point",
".",
"_dist",
")",
";",
"points",
".",
"push",
"(",
"point",
")",
";",
"}",
"}",
"// remove furthest points\r",
"i",
"=",
"points",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"if",
"(",
"points",
"[",
"i",
"]",
".",
"_dist",
">",
"distance",
")",
"{",
"points",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"}",
"}",
"// refresh the tooltip if necessary\r",
"if",
"(",
"points",
".",
"length",
"&&",
"(",
"points",
"[",
"0",
"]",
".",
"plotX",
"!==",
"hoverX",
")",
")",
"{",
"tooltip",
".",
"refresh",
"(",
"points",
")",
";",
"hoverX",
"=",
"points",
"[",
"0",
"]",
".",
"plotX",
";",
"}",
"}",
"// separate tooltip and general mouse events\r",
"if",
"(",
"hoverSeries",
"&&",
"hoverSeries",
".",
"tracker",
")",
"{",
"// only use for line-type series with common tracker\r",
"// get the point\r",
"point",
"=",
"hoverSeries",
".",
"tooltipPoints",
"[",
"index",
"]",
";",
"// a new point is hovered, refresh the tooltip\r",
"if",
"(",
"point",
"&&",
"point",
"!==",
"hoverPoint",
")",
"{",
"// trigger the events\r",
"point",
".",
"onMouseOver",
"(",
")",
";",
"}",
"}",
"}"
] |
With line type charts with a single tracker, get the point closest to the mouse
|
[
"With",
"line",
"type",
"charts",
"with",
"a",
"single",
"tracker",
"get",
"the",
"point",
"closest",
"to",
"the",
"mouse"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L18530-L18582
|
13,722
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
drop
|
function drop() {
if (selectionMarker) {
var selectionData = {
xAxis: [],
yAxis: []
},
selectionBox = selectionMarker.getBBox(),
selectionLeft = selectionBox.x - plotLeft,
selectionTop = selectionBox.y - plotTop;
// a selection has been made
if (hasDragged) {
// record each axis' min and max
each(axes, function (axis) {
var translate = axis.translate,
isXAxis = axis.isXAxis,
isHorizontal = inverted ? !isXAxis : isXAxis,
selectionMin = translate(
isHorizontal ?
selectionLeft :
plotHeight - selectionTop - selectionBox.height,
true,
0,
0,
1
),
selectionMax = translate(
isHorizontal ?
selectionLeft + selectionBox.width :
plotHeight - selectionTop,
true,
0,
0,
1
);
selectionData[isXAxis ? 'xAxis' : 'yAxis'].push({
axis: axis,
min: mathMin(selectionMin, selectionMax), // for reversed axes,
max: mathMax(selectionMin, selectionMax)
});
});
fireEvent(chart, 'selection', selectionData, zoom);
}
selectionMarker = selectionMarker.destroy();
}
chart.mouseIsDown = mouseIsDown = hasDragged = false;
removeEvent(doc, hasTouch ? 'touchend' : 'mouseup', drop);
}
|
javascript
|
function drop() {
if (selectionMarker) {
var selectionData = {
xAxis: [],
yAxis: []
},
selectionBox = selectionMarker.getBBox(),
selectionLeft = selectionBox.x - plotLeft,
selectionTop = selectionBox.y - plotTop;
// a selection has been made
if (hasDragged) {
// record each axis' min and max
each(axes, function (axis) {
var translate = axis.translate,
isXAxis = axis.isXAxis,
isHorizontal = inverted ? !isXAxis : isXAxis,
selectionMin = translate(
isHorizontal ?
selectionLeft :
plotHeight - selectionTop - selectionBox.height,
true,
0,
0,
1
),
selectionMax = translate(
isHorizontal ?
selectionLeft + selectionBox.width :
plotHeight - selectionTop,
true,
0,
0,
1
);
selectionData[isXAxis ? 'xAxis' : 'yAxis'].push({
axis: axis,
min: mathMin(selectionMin, selectionMax), // for reversed axes,
max: mathMax(selectionMin, selectionMax)
});
});
fireEvent(chart, 'selection', selectionData, zoom);
}
selectionMarker = selectionMarker.destroy();
}
chart.mouseIsDown = mouseIsDown = hasDragged = false;
removeEvent(doc, hasTouch ? 'touchend' : 'mouseup', drop);
}
|
[
"function",
"drop",
"(",
")",
"{",
"if",
"(",
"selectionMarker",
")",
"{",
"var",
"selectionData",
"=",
"{",
"xAxis",
":",
"[",
"]",
",",
"yAxis",
":",
"[",
"]",
"}",
",",
"selectionBox",
"=",
"selectionMarker",
".",
"getBBox",
"(",
")",
",",
"selectionLeft",
"=",
"selectionBox",
".",
"x",
"-",
"plotLeft",
",",
"selectionTop",
"=",
"selectionBox",
".",
"y",
"-",
"plotTop",
";",
"// a selection has been made\r",
"if",
"(",
"hasDragged",
")",
"{",
"// record each axis' min and max\r",
"each",
"(",
"axes",
",",
"function",
"(",
"axis",
")",
"{",
"var",
"translate",
"=",
"axis",
".",
"translate",
",",
"isXAxis",
"=",
"axis",
".",
"isXAxis",
",",
"isHorizontal",
"=",
"inverted",
"?",
"!",
"isXAxis",
":",
"isXAxis",
",",
"selectionMin",
"=",
"translate",
"(",
"isHorizontal",
"?",
"selectionLeft",
":",
"plotHeight",
"-",
"selectionTop",
"-",
"selectionBox",
".",
"height",
",",
"true",
",",
"0",
",",
"0",
",",
"1",
")",
",",
"selectionMax",
"=",
"translate",
"(",
"isHorizontal",
"?",
"selectionLeft",
"+",
"selectionBox",
".",
"width",
":",
"plotHeight",
"-",
"selectionTop",
",",
"true",
",",
"0",
",",
"0",
",",
"1",
")",
";",
"selectionData",
"[",
"isXAxis",
"?",
"'xAxis'",
":",
"'yAxis'",
"]",
".",
"push",
"(",
"{",
"axis",
":",
"axis",
",",
"min",
":",
"mathMin",
"(",
"selectionMin",
",",
"selectionMax",
")",
",",
"// for reversed axes,\r",
"max",
":",
"mathMax",
"(",
"selectionMin",
",",
"selectionMax",
")",
"}",
")",
";",
"}",
")",
";",
"fireEvent",
"(",
"chart",
",",
"'selection'",
",",
"selectionData",
",",
"zoom",
")",
";",
"}",
"selectionMarker",
"=",
"selectionMarker",
".",
"destroy",
"(",
")",
";",
"}",
"chart",
".",
"mouseIsDown",
"=",
"mouseIsDown",
"=",
"hasDragged",
"=",
"false",
";",
"removeEvent",
"(",
"doc",
",",
"hasTouch",
"?",
"'touchend'",
":",
"'mouseup'",
",",
"drop",
")",
";",
"}"
] |
Mouse up or outside the plot area
|
[
"Mouse",
"up",
"or",
"outside",
"the",
"plot",
"area"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L18611-L18665
|
13,723
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
hideTooltipOnMouseMove
|
function hideTooltipOnMouseMove(e) {
var pageX = defined(e.pageX) ? e.pageX : e.page.x, // In mootools the event is wrapped and the page x/y position is named e.page.x
pageY = defined(e.pageX) ? e.pageY : e.page.y; // Ref: http://mootools.net/docs/core/Types/DOMEvent
if (chartPosition &&
!isInsidePlot(pageX - chartPosition.left - plotLeft,
pageY - chartPosition.top - plotTop)) {
resetTracker();
}
}
|
javascript
|
function hideTooltipOnMouseMove(e) {
var pageX = defined(e.pageX) ? e.pageX : e.page.x, // In mootools the event is wrapped and the page x/y position is named e.page.x
pageY = defined(e.pageX) ? e.pageY : e.page.y; // Ref: http://mootools.net/docs/core/Types/DOMEvent
if (chartPosition &&
!isInsidePlot(pageX - chartPosition.left - plotLeft,
pageY - chartPosition.top - plotTop)) {
resetTracker();
}
}
|
[
"function",
"hideTooltipOnMouseMove",
"(",
"e",
")",
"{",
"var",
"pageX",
"=",
"defined",
"(",
"e",
".",
"pageX",
")",
"?",
"e",
".",
"pageX",
":",
"e",
".",
"page",
".",
"x",
",",
"// In mootools the event is wrapped and the page x/y position is named e.page.x\r",
"pageY",
"=",
"defined",
"(",
"e",
".",
"pageX",
")",
"?",
"e",
".",
"pageY",
":",
"e",
".",
"page",
".",
"y",
";",
"// Ref: http://mootools.net/docs/core/Types/DOMEvent\r",
"if",
"(",
"chartPosition",
"&&",
"!",
"isInsidePlot",
"(",
"pageX",
"-",
"chartPosition",
".",
"left",
"-",
"plotLeft",
",",
"pageY",
"-",
"chartPosition",
".",
"top",
"-",
"plotTop",
")",
")",
"{",
"resetTracker",
"(",
")",
";",
"}",
"}"
] |
Special handler for mouse move that will hide the tooltip when the mouse leaves the plotarea.
|
[
"Special",
"handler",
"for",
"mouse",
"move",
"that",
"will",
"hide",
"the",
"tooltip",
"when",
"the",
"mouse",
"leaves",
"the",
"plotarea",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L18670-L18679
|
13,724
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
destroy
|
function destroy() {
// Destroy the tracker group element
if (chart.trackerGroup) {
chart.trackerGroup = trackerGroup = chart.trackerGroup.destroy();
}
removeEvent(doc, 'mousemove', hideTooltipOnMouseMove);
container.onclick = container.onmousedown = container.onmousemove = container.ontouchstart = container.ontouchend = container.ontouchmove = null;
}
|
javascript
|
function destroy() {
// Destroy the tracker group element
if (chart.trackerGroup) {
chart.trackerGroup = trackerGroup = chart.trackerGroup.destroy();
}
removeEvent(doc, 'mousemove', hideTooltipOnMouseMove);
container.onclick = container.onmousedown = container.onmousemove = container.ontouchstart = container.ontouchend = container.ontouchmove = null;
}
|
[
"function",
"destroy",
"(",
")",
"{",
"// Destroy the tracker group element\r",
"if",
"(",
"chart",
".",
"trackerGroup",
")",
"{",
"chart",
".",
"trackerGroup",
"=",
"trackerGroup",
"=",
"chart",
".",
"trackerGroup",
".",
"destroy",
"(",
")",
";",
"}",
"removeEvent",
"(",
"doc",
",",
"'mousemove'",
",",
"hideTooltipOnMouseMove",
")",
";",
"container",
".",
"onclick",
"=",
"container",
".",
"onmousedown",
"=",
"container",
".",
"onmousemove",
"=",
"container",
".",
"ontouchstart",
"=",
"container",
".",
"ontouchend",
"=",
"container",
".",
"ontouchmove",
"=",
"null",
";",
"}"
] |
Destroys the MouseTracker object and disconnects DOM events.
|
[
"Destroys",
"the",
"MouseTracker",
"object",
"and",
"disconnects",
"DOM",
"events",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L18911-L18919
|
13,725
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
destroyItem
|
function destroyItem(item) {
var checkbox = item.checkbox;
// pull out from the array
//erase(allItems, item);
// destroy SVG elements
each(['legendItem', 'legendLine', 'legendSymbol'], function (key) {
if (item[key]) {
item[key].destroy();
}
});
if (checkbox) {
discardElement(item.checkbox);
}
}
|
javascript
|
function destroyItem(item) {
var checkbox = item.checkbox;
// pull out from the array
//erase(allItems, item);
// destroy SVG elements
each(['legendItem', 'legendLine', 'legendSymbol'], function (key) {
if (item[key]) {
item[key].destroy();
}
});
if (checkbox) {
discardElement(item.checkbox);
}
}
|
[
"function",
"destroyItem",
"(",
"item",
")",
"{",
"var",
"checkbox",
"=",
"item",
".",
"checkbox",
";",
"// pull out from the array\r",
"//erase(allItems, item);\r",
"// destroy SVG elements\r",
"each",
"(",
"[",
"'legendItem'",
",",
"'legendLine'",
",",
"'legendSymbol'",
"]",
",",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"item",
"[",
"key",
"]",
")",
"{",
"item",
"[",
"key",
"]",
".",
"destroy",
"(",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"checkbox",
")",
"{",
"discardElement",
"(",
"item",
".",
"checkbox",
")",
";",
"}",
"}"
] |
Destroy a single legend item
@param {Object} item The series or point
|
[
"Destroy",
"a",
"single",
"legend",
"item"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L19079-L19097
|
13,726
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function () {
if (!this.hasImportedEvents) {
var point = this,
options = merge(point.series.options.point, point.options),
events = options.events,
eventType;
point.events = events;
for (eventType in events) {
addEvent(point, eventType, events[eventType]);
}
this.hasImportedEvents = true;
}
}
|
javascript
|
function () {
if (!this.hasImportedEvents) {
var point = this,
options = merge(point.series.options.point, point.options),
events = options.events,
eventType;
point.events = events;
for (eventType in events) {
addEvent(point, eventType, events[eventType]);
}
this.hasImportedEvents = true;
}
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"hasImportedEvents",
")",
"{",
"var",
"point",
"=",
"this",
",",
"options",
"=",
"merge",
"(",
"point",
".",
"series",
".",
"options",
".",
"point",
",",
"point",
".",
"options",
")",
",",
"events",
"=",
"options",
".",
"events",
",",
"eventType",
";",
"point",
".",
"events",
"=",
"events",
";",
"for",
"(",
"eventType",
"in",
"events",
")",
"{",
"addEvent",
"(",
"point",
",",
"eventType",
",",
"events",
"[",
"eventType",
"]",
")",
";",
"}",
"this",
".",
"hasImportedEvents",
"=",
"true",
";",
"}",
"}"
] |
Import events from the series' and point's options. Only do it on
demand, to save processing time on hovering.
|
[
"Import",
"events",
"from",
"the",
"series",
"and",
"point",
"s",
"options",
".",
"Only",
"do",
"it",
"on",
"demand",
"to",
"save",
"processing",
"time",
"on",
"hovering",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L20996-L21011
|
|
13,727
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function () {
var series = this,
options = series.options,
xIncrement = series.xIncrement;
xIncrement = pick(xIncrement, options.pointStart, 0);
series.pointInterval = pick(series.pointInterval, options.pointInterval, 1);
series.xIncrement = xIncrement + series.pointInterval;
return xIncrement;
}
|
javascript
|
function () {
var series = this,
options = series.options,
xIncrement = series.xIncrement;
xIncrement = pick(xIncrement, options.pointStart, 0);
series.pointInterval = pick(series.pointInterval, options.pointInterval, 1);
series.xIncrement = xIncrement + series.pointInterval;
return xIncrement;
}
|
[
"function",
"(",
")",
"{",
"var",
"series",
"=",
"this",
",",
"options",
"=",
"series",
".",
"options",
",",
"xIncrement",
"=",
"series",
".",
"xIncrement",
";",
"xIncrement",
"=",
"pick",
"(",
"xIncrement",
",",
"options",
".",
"pointStart",
",",
"0",
")",
";",
"series",
".",
"pointInterval",
"=",
"pick",
"(",
"series",
".",
"pointInterval",
",",
"options",
".",
"pointInterval",
",",
"1",
")",
";",
"series",
".",
"xIncrement",
"=",
"xIncrement",
"+",
"series",
".",
"pointInterval",
";",
"return",
"xIncrement",
";",
"}"
] |
Return an auto incremented x value based on the pointStart and pointInterval options.
This is only used if an x value is not given for the point that calls autoIncrement.
|
[
"Return",
"an",
"auto",
"incremented",
"x",
"value",
"based",
"on",
"the",
"pointStart",
"and",
"pointInterval",
"options",
".",
"This",
"is",
"only",
"used",
"if",
"an",
"x",
"value",
"is",
"not",
"given",
"for",
"the",
"point",
"that",
"calls",
"autoIncrement",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L21143-L21154
|
|
13,728
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function () {
var series = this,
chart = series.chart,
data = series.data,
closestPoints,
smallestInterval,
chartSmallestInterval = chart.smallestInterval,
interval,
i;
// sort the data points
stableSort(data, function (a, b) {
return (a.x - b.x);
});
// remove points with equal x values
// record the closest distance for calculation of column widths
/*for (i = data.length - 1; i >= 0; i--) {
if (data[i - 1]) {
if (data[i - 1].x == data[i].x) {
data[i - 1].destroy();
data.splice(i - 1, 1); // remove the duplicate
}
}
}*/
// connect nulls
if (series.options.connectNulls) {
for (i = data.length - 1; i >= 0; i--) {
if (data[i].y === null && data[i - 1] && data[i + 1]) {
data.splice(i, 1);
}
}
}
// find the closes pair of points
for (i = data.length - 1; i >= 0; i--) {
if (data[i - 1]) {
interval = data[i].x - data[i - 1].x;
if (interval > 0 && (smallestInterval === UNDEFINED || interval < smallestInterval)) {
smallestInterval = interval;
closestPoints = i;
}
}
}
if (chartSmallestInterval === UNDEFINED || smallestInterval < chartSmallestInterval) {
chart.smallestInterval = smallestInterval;
}
series.closestPoints = closestPoints;
}
|
javascript
|
function () {
var series = this,
chart = series.chart,
data = series.data,
closestPoints,
smallestInterval,
chartSmallestInterval = chart.smallestInterval,
interval,
i;
// sort the data points
stableSort(data, function (a, b) {
return (a.x - b.x);
});
// remove points with equal x values
// record the closest distance for calculation of column widths
/*for (i = data.length - 1; i >= 0; i--) {
if (data[i - 1]) {
if (data[i - 1].x == data[i].x) {
data[i - 1].destroy();
data.splice(i - 1, 1); // remove the duplicate
}
}
}*/
// connect nulls
if (series.options.connectNulls) {
for (i = data.length - 1; i >= 0; i--) {
if (data[i].y === null && data[i - 1] && data[i + 1]) {
data.splice(i, 1);
}
}
}
// find the closes pair of points
for (i = data.length - 1; i >= 0; i--) {
if (data[i - 1]) {
interval = data[i].x - data[i - 1].x;
if (interval > 0 && (smallestInterval === UNDEFINED || interval < smallestInterval)) {
smallestInterval = interval;
closestPoints = i;
}
}
}
if (chartSmallestInterval === UNDEFINED || smallestInterval < chartSmallestInterval) {
chart.smallestInterval = smallestInterval;
}
series.closestPoints = closestPoints;
}
|
[
"function",
"(",
")",
"{",
"var",
"series",
"=",
"this",
",",
"chart",
"=",
"series",
".",
"chart",
",",
"data",
"=",
"series",
".",
"data",
",",
"closestPoints",
",",
"smallestInterval",
",",
"chartSmallestInterval",
"=",
"chart",
".",
"smallestInterval",
",",
"interval",
",",
"i",
";",
"// sort the data points\r",
"stableSort",
"(",
"data",
",",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"(",
"a",
".",
"x",
"-",
"b",
".",
"x",
")",
";",
"}",
")",
";",
"// remove points with equal x values\r",
"// record the closest distance for calculation of column widths\r",
"/*for (i = data.length - 1; i >= 0; i--) {\r\n\t\t\tif (data[i - 1]) {\r\n\t\t\t\tif (data[i - 1].x == data[i].x)\t{\r\n\t\t\t\t\tdata[i - 1].destroy();\r\n\t\t\t\t\tdata.splice(i - 1, 1); // remove the duplicate\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}*/",
"// connect nulls\r",
"if",
"(",
"series",
".",
"options",
".",
"connectNulls",
")",
"{",
"for",
"(",
"i",
"=",
"data",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"data",
"[",
"i",
"]",
".",
"y",
"===",
"null",
"&&",
"data",
"[",
"i",
"-",
"1",
"]",
"&&",
"data",
"[",
"i",
"+",
"1",
"]",
")",
"{",
"data",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"}",
"}",
"}",
"// find the closes pair of points\r",
"for",
"(",
"i",
"=",
"data",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"data",
"[",
"i",
"-",
"1",
"]",
")",
"{",
"interval",
"=",
"data",
"[",
"i",
"]",
".",
"x",
"-",
"data",
"[",
"i",
"-",
"1",
"]",
".",
"x",
";",
"if",
"(",
"interval",
">",
"0",
"&&",
"(",
"smallestInterval",
"===",
"UNDEFINED",
"||",
"interval",
"<",
"smallestInterval",
")",
")",
"{",
"smallestInterval",
"=",
"interval",
";",
"closestPoints",
"=",
"i",
";",
"}",
"}",
"}",
"if",
"(",
"chartSmallestInterval",
"===",
"UNDEFINED",
"||",
"smallestInterval",
"<",
"chartSmallestInterval",
")",
"{",
"chart",
".",
"smallestInterval",
"=",
"smallestInterval",
";",
"}",
"series",
".",
"closestPoints",
"=",
"closestPoints",
";",
"}"
] |
Sort the data and remove duplicates
|
[
"Sort",
"the",
"data",
"and",
"remove",
"duplicates"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L21159-L21209
|
|
13,729
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function () {
// trigger the event only if listeners exist
var series = this,
options = series.options,
chart = series.chart,
tooltip = chart.tooltip,
hoverPoint = chart.hoverPoint;
// trigger mouse out on the point, which must be in this series
if (hoverPoint) {
hoverPoint.onMouseOut();
}
// fire the mouse out event
if (series && options.events.mouseOut) {
fireEvent(series, 'mouseOut');
}
// hide the tooltip
if (tooltip && !options.stickyTracking) {
tooltip.hide();
}
// set normal state
series.setState();
chart.hoverSeries = null;
}
|
javascript
|
function () {
// trigger the event only if listeners exist
var series = this,
options = series.options,
chart = series.chart,
tooltip = chart.tooltip,
hoverPoint = chart.hoverPoint;
// trigger mouse out on the point, which must be in this series
if (hoverPoint) {
hoverPoint.onMouseOut();
}
// fire the mouse out event
if (series && options.events.mouseOut) {
fireEvent(series, 'mouseOut');
}
// hide the tooltip
if (tooltip && !options.stickyTracking) {
tooltip.hide();
}
// set normal state
series.setState();
chart.hoverSeries = null;
}
|
[
"function",
"(",
")",
"{",
"// trigger the event only if listeners exist\r",
"var",
"series",
"=",
"this",
",",
"options",
"=",
"series",
".",
"options",
",",
"chart",
"=",
"series",
".",
"chart",
",",
"tooltip",
"=",
"chart",
".",
"tooltip",
",",
"hoverPoint",
"=",
"chart",
".",
"hoverPoint",
";",
"// trigger mouse out on the point, which must be in this series\r",
"if",
"(",
"hoverPoint",
")",
"{",
"hoverPoint",
".",
"onMouseOut",
"(",
")",
";",
"}",
"// fire the mouse out event\r",
"if",
"(",
"series",
"&&",
"options",
".",
"events",
".",
"mouseOut",
")",
"{",
"fireEvent",
"(",
"series",
",",
"'mouseOut'",
")",
";",
"}",
"// hide the tooltip\r",
"if",
"(",
"tooltip",
"&&",
"!",
"options",
".",
"stickyTracking",
")",
"{",
"tooltip",
".",
"hide",
"(",
")",
";",
"}",
"// set normal state\r",
"series",
".",
"setState",
"(",
")",
";",
"chart",
".",
"hoverSeries",
"=",
"null",
";",
"}"
] |
Series mouse out handler
|
[
"Series",
"mouse",
"out",
"handler"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L21537-L21564
|
|
13,730
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function (options, base1, base2, base3) {
var conversion = this.pointAttrToOptions,
attr,
option,
obj = {};
options = options || {};
base1 = base1 || {};
base2 = base2 || {};
base3 = base3 || {};
for (attr in conversion) {
option = conversion[attr];
obj[attr] = pick(options[option], base1[attr], base2[attr], base3[attr]);
}
return obj;
}
|
javascript
|
function (options, base1, base2, base3) {
var conversion = this.pointAttrToOptions,
attr,
option,
obj = {};
options = options || {};
base1 = base1 || {};
base2 = base2 || {};
base3 = base3 || {};
for (attr in conversion) {
option = conversion[attr];
obj[attr] = pick(options[option], base1[attr], base2[attr], base3[attr]);
}
return obj;
}
|
[
"function",
"(",
"options",
",",
"base1",
",",
"base2",
",",
"base3",
")",
"{",
"var",
"conversion",
"=",
"this",
".",
"pointAttrToOptions",
",",
"attr",
",",
"option",
",",
"obj",
"=",
"{",
"}",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"base1",
"=",
"base1",
"||",
"{",
"}",
";",
"base2",
"=",
"base2",
"||",
"{",
"}",
";",
"base3",
"=",
"base3",
"||",
"{",
"}",
";",
"for",
"(",
"attr",
"in",
"conversion",
")",
"{",
"option",
"=",
"conversion",
"[",
"attr",
"]",
";",
"obj",
"[",
"attr",
"]",
"=",
"pick",
"(",
"options",
"[",
"option",
"]",
",",
"base1",
"[",
"attr",
"]",
",",
"base2",
"[",
"attr",
"]",
",",
"base3",
"[",
"attr",
"]",
")",
";",
"}",
"return",
"obj",
";",
"}"
] |
Convert state properties from API naming conventions to SVG attributes
@param {Object} options API options object
@param {Object} base1 SVG attribute object to inherit from
@param {Object} base2 Second level SVG attribute object to inherit from
|
[
"Convert",
"state",
"properties",
"from",
"API",
"naming",
"conventions",
"to",
"SVG",
"attributes"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L21659-L21675
|
|
13,731
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function (state) {
var series = this,
options = series.options,
graph = series.graph,
stateOptions = options.states,
lineWidth = options.lineWidth;
state = state || NORMAL_STATE;
if (series.state !== state) {
series.state = state;
if (stateOptions[state] && stateOptions[state].enabled === false) {
return;
}
if (state) {
lineWidth = stateOptions[state].lineWidth || lineWidth + 1;
}
if (graph && !graph.dashstyle) { // hover is turned off for dashed lines in VML
graph.attr({ // use attr because animate will cause any other animation on the graph to stop
'stroke-width': lineWidth
}, state ? 0 : 500);
}
}
}
|
javascript
|
function (state) {
var series = this,
options = series.options,
graph = series.graph,
stateOptions = options.states,
lineWidth = options.lineWidth;
state = state || NORMAL_STATE;
if (series.state !== state) {
series.state = state;
if (stateOptions[state] && stateOptions[state].enabled === false) {
return;
}
if (state) {
lineWidth = stateOptions[state].lineWidth || lineWidth + 1;
}
if (graph && !graph.dashstyle) { // hover is turned off for dashed lines in VML
graph.attr({ // use attr because animate will cause any other animation on the graph to stop
'stroke-width': lineWidth
}, state ? 0 : 500);
}
}
}
|
[
"function",
"(",
"state",
")",
"{",
"var",
"series",
"=",
"this",
",",
"options",
"=",
"series",
".",
"options",
",",
"graph",
"=",
"series",
".",
"graph",
",",
"stateOptions",
"=",
"options",
".",
"states",
",",
"lineWidth",
"=",
"options",
".",
"lineWidth",
";",
"state",
"=",
"state",
"||",
"NORMAL_STATE",
";",
"if",
"(",
"series",
".",
"state",
"!==",
"state",
")",
"{",
"series",
".",
"state",
"=",
"state",
";",
"if",
"(",
"stateOptions",
"[",
"state",
"]",
"&&",
"stateOptions",
"[",
"state",
"]",
".",
"enabled",
"===",
"false",
")",
"{",
"return",
";",
"}",
"if",
"(",
"state",
")",
"{",
"lineWidth",
"=",
"stateOptions",
"[",
"state",
"]",
".",
"lineWidth",
"||",
"lineWidth",
"+",
"1",
";",
"}",
"if",
"(",
"graph",
"&&",
"!",
"graph",
".",
"dashstyle",
")",
"{",
"// hover is turned off for dashed lines in VML\r",
"graph",
".",
"attr",
"(",
"{",
"// use attr because animate will cause any other animation on the graph to stop\r",
"'stroke-width'",
":",
"lineWidth",
"}",
",",
"state",
"?",
"0",
":",
"500",
")",
";",
"}",
"}",
"}"
] |
Set the state of the graph
|
[
"Set",
"the",
"state",
"of",
"the",
"graph"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L22281-L22307
|
|
13,732
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function (selected) {
var series = this;
// if called without an argument, toggle
series.selected = selected = (selected === UNDEFINED) ? !series.selected : selected;
if (series.checkbox) {
series.checkbox.checked = selected;
}
fireEvent(series, selected ? 'select' : 'unselect');
}
|
javascript
|
function (selected) {
var series = this;
// if called without an argument, toggle
series.selected = selected = (selected === UNDEFINED) ? !series.selected : selected;
if (series.checkbox) {
series.checkbox.checked = selected;
}
fireEvent(series, selected ? 'select' : 'unselect');
}
|
[
"function",
"(",
"selected",
")",
"{",
"var",
"series",
"=",
"this",
";",
"// if called without an argument, toggle\r",
"series",
".",
"selected",
"=",
"selected",
"=",
"(",
"selected",
"===",
"UNDEFINED",
")",
"?",
"!",
"series",
".",
"selected",
":",
"selected",
";",
"if",
"(",
"series",
".",
"checkbox",
")",
"{",
"series",
".",
"checkbox",
".",
"checked",
"=",
"selected",
";",
"}",
"fireEvent",
"(",
"series",
",",
"selected",
"?",
"'select'",
":",
"'unselect'",
")",
";",
"}"
] |
Set the selected state of the graph
@param selected {Boolean} True to select the series, false to unselect. If
UNDEFINED, the selection state is toggled.
|
[
"Set",
"the",
"selected",
"state",
"of",
"the",
"graph"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L22403-L22413
|
|
13,733
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function () {
var series = this,
chart = series.chart,
renderer = chart.renderer,
shapeArgs,
tracker,
trackerLabel = +new Date(),
options = series.options,
cursor = options.cursor,
css = cursor && { cursor: cursor },
rel;
each(series.data, function (point) {
tracker = point.tracker;
shapeArgs = point.trackerArgs || point.shapeArgs;
delete shapeArgs.strokeWidth;
if (point.y !== null) {
if (tracker) {// update
tracker.attr(shapeArgs);
} else {
point.tracker =
renderer[point.shapeType](shapeArgs)
.attr({
isTracker: trackerLabel,
fill: TRACKER_FILL,
visibility: series.visible ? VISIBLE : HIDDEN,
zIndex: options.zIndex || 1
})
.on(hasTouch ? 'touchstart' : 'mouseover', function (event) {
rel = event.relatedTarget || event.fromElement;
if (chart.hoverSeries !== series && attr(rel, 'isTracker') !== trackerLabel) {
series.onMouseOver();
}
point.onMouseOver();
})
.on('mouseout', function (event) {
if (!options.stickyTracking) {
rel = event.relatedTarget || event.toElement;
if (attr(rel, 'isTracker') !== trackerLabel) {
series.onMouseOut();
}
}
})
.css(css)
.add(point.group || chart.trackerGroup); // pies have point group - see issue #118
}
}
});
}
|
javascript
|
function () {
var series = this,
chart = series.chart,
renderer = chart.renderer,
shapeArgs,
tracker,
trackerLabel = +new Date(),
options = series.options,
cursor = options.cursor,
css = cursor && { cursor: cursor },
rel;
each(series.data, function (point) {
tracker = point.tracker;
shapeArgs = point.trackerArgs || point.shapeArgs;
delete shapeArgs.strokeWidth;
if (point.y !== null) {
if (tracker) {// update
tracker.attr(shapeArgs);
} else {
point.tracker =
renderer[point.shapeType](shapeArgs)
.attr({
isTracker: trackerLabel,
fill: TRACKER_FILL,
visibility: series.visible ? VISIBLE : HIDDEN,
zIndex: options.zIndex || 1
})
.on(hasTouch ? 'touchstart' : 'mouseover', function (event) {
rel = event.relatedTarget || event.fromElement;
if (chart.hoverSeries !== series && attr(rel, 'isTracker') !== trackerLabel) {
series.onMouseOver();
}
point.onMouseOver();
})
.on('mouseout', function (event) {
if (!options.stickyTracking) {
rel = event.relatedTarget || event.toElement;
if (attr(rel, 'isTracker') !== trackerLabel) {
series.onMouseOut();
}
}
})
.css(css)
.add(point.group || chart.trackerGroup); // pies have point group - see issue #118
}
}
});
}
|
[
"function",
"(",
")",
"{",
"var",
"series",
"=",
"this",
",",
"chart",
"=",
"series",
".",
"chart",
",",
"renderer",
"=",
"chart",
".",
"renderer",
",",
"shapeArgs",
",",
"tracker",
",",
"trackerLabel",
"=",
"+",
"new",
"Date",
"(",
")",
",",
"options",
"=",
"series",
".",
"options",
",",
"cursor",
"=",
"options",
".",
"cursor",
",",
"css",
"=",
"cursor",
"&&",
"{",
"cursor",
":",
"cursor",
"}",
",",
"rel",
";",
"each",
"(",
"series",
".",
"data",
",",
"function",
"(",
"point",
")",
"{",
"tracker",
"=",
"point",
".",
"tracker",
";",
"shapeArgs",
"=",
"point",
".",
"trackerArgs",
"||",
"point",
".",
"shapeArgs",
";",
"delete",
"shapeArgs",
".",
"strokeWidth",
";",
"if",
"(",
"point",
".",
"y",
"!==",
"null",
")",
"{",
"if",
"(",
"tracker",
")",
"{",
"// update\r",
"tracker",
".",
"attr",
"(",
"shapeArgs",
")",
";",
"}",
"else",
"{",
"point",
".",
"tracker",
"=",
"renderer",
"[",
"point",
".",
"shapeType",
"]",
"(",
"shapeArgs",
")",
".",
"attr",
"(",
"{",
"isTracker",
":",
"trackerLabel",
",",
"fill",
":",
"TRACKER_FILL",
",",
"visibility",
":",
"series",
".",
"visible",
"?",
"VISIBLE",
":",
"HIDDEN",
",",
"zIndex",
":",
"options",
".",
"zIndex",
"||",
"1",
"}",
")",
".",
"on",
"(",
"hasTouch",
"?",
"'touchstart'",
":",
"'mouseover'",
",",
"function",
"(",
"event",
")",
"{",
"rel",
"=",
"event",
".",
"relatedTarget",
"||",
"event",
".",
"fromElement",
";",
"if",
"(",
"chart",
".",
"hoverSeries",
"!==",
"series",
"&&",
"attr",
"(",
"rel",
",",
"'isTracker'",
")",
"!==",
"trackerLabel",
")",
"{",
"series",
".",
"onMouseOver",
"(",
")",
";",
"}",
"point",
".",
"onMouseOver",
"(",
")",
";",
"}",
")",
".",
"on",
"(",
"'mouseout'",
",",
"function",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"options",
".",
"stickyTracking",
")",
"{",
"rel",
"=",
"event",
".",
"relatedTarget",
"||",
"event",
".",
"toElement",
";",
"if",
"(",
"attr",
"(",
"rel",
",",
"'isTracker'",
")",
"!==",
"trackerLabel",
")",
"{",
"series",
".",
"onMouseOut",
"(",
")",
";",
"}",
"}",
"}",
")",
".",
"css",
"(",
"css",
")",
".",
"add",
"(",
"point",
".",
"group",
"||",
"chart",
".",
"trackerGroup",
")",
";",
"// pies have point group - see issue #118\r",
"}",
"}",
"}",
")",
";",
"}"
] |
Draw the individual tracker elements.
This method is inherited by scatter and pie charts too.
|
[
"Draw",
"the",
"individual",
"tracker",
"elements",
".",
"This",
"method",
"is",
"inherited",
"by",
"scatter",
"and",
"pie",
"charts",
"too",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L22800-L22850
|
|
13,734
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function () {
var series = this;
Series.prototype.translate.apply(series);
each(series.data, function (point) {
point.shapeType = 'circle';
point.shapeArgs = {
x: point.plotX,
y: point.plotY,
r: series.chart.options.tooltip.snap
};
});
}
|
javascript
|
function () {
var series = this;
Series.prototype.translate.apply(series);
each(series.data, function (point) {
point.shapeType = 'circle';
point.shapeArgs = {
x: point.plotX,
y: point.plotY,
r: series.chart.options.tooltip.snap
};
});
}
|
[
"function",
"(",
")",
"{",
"var",
"series",
"=",
"this",
";",
"Series",
".",
"prototype",
".",
"translate",
".",
"apply",
"(",
"series",
")",
";",
"each",
"(",
"series",
".",
"data",
",",
"function",
"(",
"point",
")",
"{",
"point",
".",
"shapeType",
"=",
"'circle'",
";",
"point",
".",
"shapeArgs",
"=",
"{",
"x",
":",
"point",
".",
"plotX",
",",
"y",
":",
"point",
".",
"plotY",
",",
"r",
":",
"series",
".",
"chart",
".",
"options",
".",
"tooltip",
".",
"snap",
"}",
";",
"}",
")",
";",
"}"
] |
Extend the base Series' translate method by adding shape type and
arguments for the point trackers
|
[
"Extend",
"the",
"base",
"Series",
"translate",
"method",
"by",
"adding",
"shape",
"type",
"and",
"arguments",
"for",
"the",
"point",
"trackers"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L22936-L22949
|
|
13,735
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function () {
var series = this;
// cache attributes for shapes
//series.getAttribs();
this.drawPoints();
// draw the mouse tracking area
if (series.options.enableMouseTracking !== false) {
series.drawTracker();
}
// PATCH by Simon Fishel
//
// execute beforeLabelRender hook to allow re-formatting of data labels
//
// + if(series.options.hooks && series.options.hooks.beforeLabelRender) {
// + series.options.hooks.beforeLabelRender(series)
// + }
if(series.options.hooks && series.options.hooks.beforeLabelRender) {
series.options.hooks.beforeLabelRender(series)
}
this.drawDataLabels();
if (series.options.animation && series.animate) {
series.animate();
}
series.isDirty = false; // means data is in accordance with what you see
}
|
javascript
|
function () {
var series = this;
// cache attributes for shapes
//series.getAttribs();
this.drawPoints();
// draw the mouse tracking area
if (series.options.enableMouseTracking !== false) {
series.drawTracker();
}
// PATCH by Simon Fishel
//
// execute beforeLabelRender hook to allow re-formatting of data labels
//
// + if(series.options.hooks && series.options.hooks.beforeLabelRender) {
// + series.options.hooks.beforeLabelRender(series)
// + }
if(series.options.hooks && series.options.hooks.beforeLabelRender) {
series.options.hooks.beforeLabelRender(series)
}
this.drawDataLabels();
if (series.options.animation && series.animate) {
series.animate();
}
series.isDirty = false; // means data is in accordance with what you see
}
|
[
"function",
"(",
")",
"{",
"var",
"series",
"=",
"this",
";",
"// cache attributes for shapes\r",
"//series.getAttribs();\r",
"this",
".",
"drawPoints",
"(",
")",
";",
"// draw the mouse tracking area\r",
"if",
"(",
"series",
".",
"options",
".",
"enableMouseTracking",
"!==",
"false",
")",
"{",
"series",
".",
"drawTracker",
"(",
")",
";",
"}",
"// PATCH by Simon Fishel\r",
"//\r",
"// execute beforeLabelRender hook to allow re-formatting of data labels\r",
"//\r",
"// + if(series.options.hooks && series.options.hooks.beforeLabelRender) {\r",
"// + series.options.hooks.beforeLabelRender(series)\r",
"// + }\r",
"if",
"(",
"series",
".",
"options",
".",
"hooks",
"&&",
"series",
".",
"options",
".",
"hooks",
".",
"beforeLabelRender",
")",
"{",
"series",
".",
"options",
".",
"hooks",
".",
"beforeLabelRender",
"(",
"series",
")",
"}",
"this",
".",
"drawDataLabels",
"(",
")",
";",
"if",
"(",
"series",
".",
"options",
".",
"animation",
"&&",
"series",
".",
"animate",
")",
"{",
"series",
".",
"animate",
"(",
")",
";",
"}",
"series",
".",
"isDirty",
"=",
"false",
";",
"// means data is in accordance with what you see\r",
"}"
] |
Render the slices
|
[
"Render",
"the",
"slices"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L23274-L23306
|
|
13,736
|
splunk/splunk-sdk-javascript
|
lib/modularinputs/argument.js
|
Argument
|
function Argument(argumentConfig) {
if (!argumentConfig) {
argumentConfig = {};
}
this.name = utils.isUndefined(argumentConfig.name) ? "" : argumentConfig.name;
this.description = utils.isUndefined(argumentConfig.description) ? null : argumentConfig.description;
this.validation = utils.isUndefined(argumentConfig.validation) ? null : argumentConfig.validation;
this.dataType = utils.isUndefined(argumentConfig.dataType) ? Argument.dataTypeString : argumentConfig.dataType;
this.requiredOnEdit = utils.isUndefined(argumentConfig.requiredOnEdit) ? false : argumentConfig.requiredOnEdit;
this.requiredOnCreate = utils.isUndefined(argumentConfig.requiredOnCreate) ? false : argumentConfig.requiredOnCreate;
}
|
javascript
|
function Argument(argumentConfig) {
if (!argumentConfig) {
argumentConfig = {};
}
this.name = utils.isUndefined(argumentConfig.name) ? "" : argumentConfig.name;
this.description = utils.isUndefined(argumentConfig.description) ? null : argumentConfig.description;
this.validation = utils.isUndefined(argumentConfig.validation) ? null : argumentConfig.validation;
this.dataType = utils.isUndefined(argumentConfig.dataType) ? Argument.dataTypeString : argumentConfig.dataType;
this.requiredOnEdit = utils.isUndefined(argumentConfig.requiredOnEdit) ? false : argumentConfig.requiredOnEdit;
this.requiredOnCreate = utils.isUndefined(argumentConfig.requiredOnCreate) ? false : argumentConfig.requiredOnCreate;
}
|
[
"function",
"Argument",
"(",
"argumentConfig",
")",
"{",
"if",
"(",
"!",
"argumentConfig",
")",
"{",
"argumentConfig",
"=",
"{",
"}",
";",
"}",
"this",
".",
"name",
"=",
"utils",
".",
"isUndefined",
"(",
"argumentConfig",
".",
"name",
")",
"?",
"\"\"",
":",
"argumentConfig",
".",
"name",
";",
"this",
".",
"description",
"=",
"utils",
".",
"isUndefined",
"(",
"argumentConfig",
".",
"description",
")",
"?",
"null",
":",
"argumentConfig",
".",
"description",
";",
"this",
".",
"validation",
"=",
"utils",
".",
"isUndefined",
"(",
"argumentConfig",
".",
"validation",
")",
"?",
"null",
":",
"argumentConfig",
".",
"validation",
";",
"this",
".",
"dataType",
"=",
"utils",
".",
"isUndefined",
"(",
"argumentConfig",
".",
"dataType",
")",
"?",
"Argument",
".",
"dataTypeString",
":",
"argumentConfig",
".",
"dataType",
";",
"this",
".",
"requiredOnEdit",
"=",
"utils",
".",
"isUndefined",
"(",
"argumentConfig",
".",
"requiredOnEdit",
")",
"?",
"false",
":",
"argumentConfig",
".",
"requiredOnEdit",
";",
"this",
".",
"requiredOnCreate",
"=",
"utils",
".",
"isUndefined",
"(",
"argumentConfig",
".",
"requiredOnCreate",
")",
"?",
"false",
":",
"argumentConfig",
".",
"requiredOnCreate",
";",
"}"
] |
Class representing an argument to a modular input kind.
`Argument` is meant to be used with `Scheme` to generate an XML
definition of the modular input kind that Splunk understands.
`name` is the only required parameter for the constructor.
@example
// Example with minimal parameters
var myArg1 = new Argument({name: "arg1"});
// Example with all parameters
var myArg2 = new Argument({
name: "arg1",
description: "This an argument with lots of parameters",
validation: "is_pos_int('some_name')",
dataType: Argument.dataTypeNumber,
requiredOnEdit: true,
requiredOnCreate: true
});
@param {Object} argumentConfig An object containing at least the name property to configure this Argument
@class splunkjs.ModularInputs.Argument
|
[
"Class",
"representing",
"an",
"argument",
"to",
"a",
"modular",
"input",
"kind",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/modularinputs/argument.js#L46-L57
|
13,737
|
splunk/splunk-sdk-javascript
|
lib/modularinputs/event.js
|
Event
|
function Event(eventConfig) {
eventConfig = utils.isUndefined(eventConfig) ? {} : eventConfig;
this.data = utils.isUndefined(eventConfig.data) ? null : eventConfig.data;
this.done = utils.isUndefined(eventConfig.done) ? true : eventConfig.done;
this.host = utils.isUndefined(eventConfig.host) ? null : eventConfig.host;
this.index = utils.isUndefined(eventConfig.index) ? null : eventConfig.index;
this.source = utils.isUndefined(eventConfig.source) ? null : eventConfig.source;
this.sourcetype = utils.isUndefined(eventConfig.sourcetype) ? null : eventConfig.sourcetype;
this.stanza = utils.isUndefined(eventConfig.stanza) ? null : eventConfig.stanza;
this.unbroken = utils.isUndefined(eventConfig.unbroken) ? true : eventConfig.unbroken;
// eventConfig.time can be of type Date, Number, or String.
this.time = utils.isUndefined(eventConfig.time) ? null : eventConfig.time;
}
|
javascript
|
function Event(eventConfig) {
eventConfig = utils.isUndefined(eventConfig) ? {} : eventConfig;
this.data = utils.isUndefined(eventConfig.data) ? null : eventConfig.data;
this.done = utils.isUndefined(eventConfig.done) ? true : eventConfig.done;
this.host = utils.isUndefined(eventConfig.host) ? null : eventConfig.host;
this.index = utils.isUndefined(eventConfig.index) ? null : eventConfig.index;
this.source = utils.isUndefined(eventConfig.source) ? null : eventConfig.source;
this.sourcetype = utils.isUndefined(eventConfig.sourcetype) ? null : eventConfig.sourcetype;
this.stanza = utils.isUndefined(eventConfig.stanza) ? null : eventConfig.stanza;
this.unbroken = utils.isUndefined(eventConfig.unbroken) ? true : eventConfig.unbroken;
// eventConfig.time can be of type Date, Number, or String.
this.time = utils.isUndefined(eventConfig.time) ? null : eventConfig.time;
}
|
[
"function",
"Event",
"(",
"eventConfig",
")",
"{",
"eventConfig",
"=",
"utils",
".",
"isUndefined",
"(",
"eventConfig",
")",
"?",
"{",
"}",
":",
"eventConfig",
";",
"this",
".",
"data",
"=",
"utils",
".",
"isUndefined",
"(",
"eventConfig",
".",
"data",
")",
"?",
"null",
":",
"eventConfig",
".",
"data",
";",
"this",
".",
"done",
"=",
"utils",
".",
"isUndefined",
"(",
"eventConfig",
".",
"done",
")",
"?",
"true",
":",
"eventConfig",
".",
"done",
";",
"this",
".",
"host",
"=",
"utils",
".",
"isUndefined",
"(",
"eventConfig",
".",
"host",
")",
"?",
"null",
":",
"eventConfig",
".",
"host",
";",
"this",
".",
"index",
"=",
"utils",
".",
"isUndefined",
"(",
"eventConfig",
".",
"index",
")",
"?",
"null",
":",
"eventConfig",
".",
"index",
";",
"this",
".",
"source",
"=",
"utils",
".",
"isUndefined",
"(",
"eventConfig",
".",
"source",
")",
"?",
"null",
":",
"eventConfig",
".",
"source",
";",
"this",
".",
"sourcetype",
"=",
"utils",
".",
"isUndefined",
"(",
"eventConfig",
".",
"sourcetype",
")",
"?",
"null",
":",
"eventConfig",
".",
"sourcetype",
";",
"this",
".",
"stanza",
"=",
"utils",
".",
"isUndefined",
"(",
"eventConfig",
".",
"stanza",
")",
"?",
"null",
":",
"eventConfig",
".",
"stanza",
";",
"this",
".",
"unbroken",
"=",
"utils",
".",
"isUndefined",
"(",
"eventConfig",
".",
"unbroken",
")",
"?",
"true",
":",
"eventConfig",
".",
"unbroken",
";",
"// eventConfig.time can be of type Date, Number, or String.",
"this",
".",
"time",
"=",
"utils",
".",
"isUndefined",
"(",
"eventConfig",
".",
"time",
")",
"?",
"null",
":",
"eventConfig",
".",
"time",
";",
"}"
] |
`Event` represents an event or fragment of an event to be written by this
modular input to Splunk.
@example
// Minimal configuration
var myEvent = new Event({
data: "This is a test of my new event.",
stanza: "myStanzaName",
time: parseFloat("1372187084.000")
});
// Full configuration
var myBetterEvent = new Event({
data: "This is a test of my better event.",
stanza: "myStanzaName",
time: parseFloat("1372187084.000"),
host: "localhost",
index: "main",
source: "Splunk",
sourcetype: "misc",
done: true,
unbroken: true
});
@param {Object} eventConfig An object containing the configuration for an `Event`.
@class splunkjs.ModularInputs.Event
|
[
"Event",
"represents",
"an",
"event",
"or",
"fragment",
"of",
"an",
"event",
"to",
"be",
"written",
"by",
"this",
"modular",
"input",
"to",
"Splunk",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/modularinputs/event.js#L49-L63
|
13,738
|
splunk/splunk-sdk-javascript
|
examples/node/helloworld/search_normal.js
|
function(results, job, done) {
// Print out the statics
console.log("Job Statistics: ");
console.log(" Event Count: " + job.properties().eventCount);
console.log(" Disk Usage: " + job.properties().diskUsage + " bytes");
console.log(" Priority: " + job.properties().priority);
// Find the index of the fields we want
var rawIndex = results.fields.indexOf("_raw");
var sourcetypeIndex = results.fields.indexOf("sourcetype");
var userIndex = results.fields.indexOf("user");
// Print out each result and the key-value pairs we want
console.log("Results: ");
for(var i = 0; i < results.rows.length; i++) {
console.log(" Result " + i + ": ");
console.log(" sourcetype: " + results.rows[i][sourcetypeIndex]);
console.log(" user: " + results.rows[i][userIndex]);
console.log(" _raw: " + results.rows[i][rawIndex]);
}
// Once we're done, cancel the job.
job.cancel(done);
}
|
javascript
|
function(results, job, done) {
// Print out the statics
console.log("Job Statistics: ");
console.log(" Event Count: " + job.properties().eventCount);
console.log(" Disk Usage: " + job.properties().diskUsage + " bytes");
console.log(" Priority: " + job.properties().priority);
// Find the index of the fields we want
var rawIndex = results.fields.indexOf("_raw");
var sourcetypeIndex = results.fields.indexOf("sourcetype");
var userIndex = results.fields.indexOf("user");
// Print out each result and the key-value pairs we want
console.log("Results: ");
for(var i = 0; i < results.rows.length; i++) {
console.log(" Result " + i + ": ");
console.log(" sourcetype: " + results.rows[i][sourcetypeIndex]);
console.log(" user: " + results.rows[i][userIndex]);
console.log(" _raw: " + results.rows[i][rawIndex]);
}
// Once we're done, cancel the job.
job.cancel(done);
}
|
[
"function",
"(",
"results",
",",
"job",
",",
"done",
")",
"{",
"// Print out the statics",
"console",
".",
"log",
"(",
"\"Job Statistics: \"",
")",
";",
"console",
".",
"log",
"(",
"\" Event Count: \"",
"+",
"job",
".",
"properties",
"(",
")",
".",
"eventCount",
")",
";",
"console",
".",
"log",
"(",
"\" Disk Usage: \"",
"+",
"job",
".",
"properties",
"(",
")",
".",
"diskUsage",
"+",
"\" bytes\"",
")",
";",
"console",
".",
"log",
"(",
"\" Priority: \"",
"+",
"job",
".",
"properties",
"(",
")",
".",
"priority",
")",
";",
"// Find the index of the fields we want",
"var",
"rawIndex",
"=",
"results",
".",
"fields",
".",
"indexOf",
"(",
"\"_raw\"",
")",
";",
"var",
"sourcetypeIndex",
"=",
"results",
".",
"fields",
".",
"indexOf",
"(",
"\"sourcetype\"",
")",
";",
"var",
"userIndex",
"=",
"results",
".",
"fields",
".",
"indexOf",
"(",
"\"user\"",
")",
";",
"// Print out each result and the key-value pairs we want",
"console",
".",
"log",
"(",
"\"Results: \"",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"results",
".",
"rows",
".",
"length",
";",
"i",
"++",
")",
"{",
"console",
".",
"log",
"(",
"\" Result \"",
"+",
"i",
"+",
"\": \"",
")",
";",
"console",
".",
"log",
"(",
"\" sourcetype: \"",
"+",
"results",
".",
"rows",
"[",
"i",
"]",
"[",
"sourcetypeIndex",
"]",
")",
";",
"console",
".",
"log",
"(",
"\" user: \"",
"+",
"results",
".",
"rows",
"[",
"i",
"]",
"[",
"userIndex",
"]",
")",
";",
"console",
".",
"log",
"(",
"\" _raw: \"",
"+",
"results",
".",
"rows",
"[",
"i",
"]",
"[",
"rawIndex",
"]",
")",
";",
"}",
"// Once we're done, cancel the job.",
"job",
".",
"cancel",
"(",
"done",
")",
";",
"}"
] |
Print out the statistics and get the results
|
[
"Print",
"out",
"the",
"statistics",
"and",
"get",
"the",
"results"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/examples/node/helloworld/search_normal.js#L63-L86
|
|
13,739
|
splunk/splunk-sdk-javascript
|
contrib/nodeunit/junit_reporter.js
|
function (path, callback) {
var mkdir = child_process.spawn('mkdir', ['-p', path]);
mkdir.on('error', function (err) {
callback(err);
callback = function(){};
});
mkdir.on('exit', function (code) {
if (code === 0) callback();
else callback(new Error('mkdir exited with code: ' + code));
});
}
|
javascript
|
function (path, callback) {
var mkdir = child_process.spawn('mkdir', ['-p', path]);
mkdir.on('error', function (err) {
callback(err);
callback = function(){};
});
mkdir.on('exit', function (code) {
if (code === 0) callback();
else callback(new Error('mkdir exited with code: ' + code));
});
}
|
[
"function",
"(",
"path",
",",
"callback",
")",
"{",
"var",
"mkdir",
"=",
"child_process",
".",
"spawn",
"(",
"'mkdir'",
",",
"[",
"'-p'",
",",
"path",
"]",
")",
";",
"mkdir",
".",
"on",
"(",
"'error'",
",",
"function",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"callback",
"=",
"function",
"(",
")",
"{",
"}",
";",
"}",
")",
";",
"mkdir",
".",
"on",
"(",
"'exit'",
",",
"function",
"(",
"code",
")",
"{",
"if",
"(",
"code",
"===",
"0",
")",
"callback",
"(",
")",
";",
"else",
"callback",
"(",
"new",
"Error",
"(",
"'mkdir exited with code: '",
"+",
"code",
")",
")",
";",
"}",
")",
";",
"}"
] |
Ensures a directory exists using mkdir -p.
@param {String} path
@param {Function} callback
@api private
|
[
"Ensures",
"a",
"directory",
"exists",
"using",
"mkdir",
"-",
"p",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/contrib/nodeunit/junit_reporter.js#L41-L51
|
|
13,740
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(http, params) {
if (!(http instanceof Http) && !params) {
// Move over the params
params = http;
http = null;
}
params = params || {};
this.scheme = params.scheme || "https";
this.host = params.host || "localhost";
this.port = params.port || 8089;
this.username = params.username || null;
this.password = params.password || null;
this.owner = params.owner;
this.app = params.app;
this.sessionKey = params.sessionKey || "";
this.authorization = params.authorization || "Splunk";
this.paths = params.paths || Paths;
this.version = params.version || "default";
this.timeout = params.timeout || 0;
this.autologin = true;
// Initialize autologin
// The reason we explicitly check to see if 'autologin'
// is actually set is because we need to distinguish the
// case of it being set to 'false', and it not being set.
// Unfortunately, in JavaScript, these are both false-y
if (params.hasOwnProperty("autologin")) {
this.autologin = params.autologin;
}
if (!http) {
// If there is no HTTP implementation set, we check what platform
// we're running on. If we're running in the browser, then complain,
// else, we instantiate NodeHttp.
if (typeof(window) !== 'undefined') {
throw new Error("Http instance required when creating a Context within a browser.");
}
else {
var NodeHttp = require('./platform/node/node_http').NodeHttp;
http = new NodeHttp();
}
}
// Store the HTTP implementation
this.http = http;
this.http._setSplunkVersion(this.version);
// Store our full prefix, which is just combining together
// the scheme with the host
var versionPrefix = utils.getWithVersion(this.version, prefixMap);
this.prefix = this.scheme + "://" + this.host + ":" + this.port + versionPrefix;
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this._headers = utils.bind(this, this._headers);
this.fullpath = utils.bind(this, this.fullpath);
this.urlify = utils.bind(this, this.urlify);
this.get = utils.bind(this, this.get);
this.del = utils.bind(this, this.del);
this.post = utils.bind(this, this.post);
this.login = utils.bind(this, this.login);
this._shouldAutoLogin = utils.bind(this, this._shouldAutoLogin);
this._requestWrapper = utils.bind(this, this._requestWrapper);
}
|
javascript
|
function(http, params) {
if (!(http instanceof Http) && !params) {
// Move over the params
params = http;
http = null;
}
params = params || {};
this.scheme = params.scheme || "https";
this.host = params.host || "localhost";
this.port = params.port || 8089;
this.username = params.username || null;
this.password = params.password || null;
this.owner = params.owner;
this.app = params.app;
this.sessionKey = params.sessionKey || "";
this.authorization = params.authorization || "Splunk";
this.paths = params.paths || Paths;
this.version = params.version || "default";
this.timeout = params.timeout || 0;
this.autologin = true;
// Initialize autologin
// The reason we explicitly check to see if 'autologin'
// is actually set is because we need to distinguish the
// case of it being set to 'false', and it not being set.
// Unfortunately, in JavaScript, these are both false-y
if (params.hasOwnProperty("autologin")) {
this.autologin = params.autologin;
}
if (!http) {
// If there is no HTTP implementation set, we check what platform
// we're running on. If we're running in the browser, then complain,
// else, we instantiate NodeHttp.
if (typeof(window) !== 'undefined') {
throw new Error("Http instance required when creating a Context within a browser.");
}
else {
var NodeHttp = require('./platform/node/node_http').NodeHttp;
http = new NodeHttp();
}
}
// Store the HTTP implementation
this.http = http;
this.http._setSplunkVersion(this.version);
// Store our full prefix, which is just combining together
// the scheme with the host
var versionPrefix = utils.getWithVersion(this.version, prefixMap);
this.prefix = this.scheme + "://" + this.host + ":" + this.port + versionPrefix;
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this._headers = utils.bind(this, this._headers);
this.fullpath = utils.bind(this, this.fullpath);
this.urlify = utils.bind(this, this.urlify);
this.get = utils.bind(this, this.get);
this.del = utils.bind(this, this.del);
this.post = utils.bind(this, this.post);
this.login = utils.bind(this, this.login);
this._shouldAutoLogin = utils.bind(this, this._shouldAutoLogin);
this._requestWrapper = utils.bind(this, this._requestWrapper);
}
|
[
"function",
"(",
"http",
",",
"params",
")",
"{",
"if",
"(",
"!",
"(",
"http",
"instanceof",
"Http",
")",
"&&",
"!",
"params",
")",
"{",
"// Move over the params",
"params",
"=",
"http",
";",
"http",
"=",
"null",
";",
"}",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"this",
".",
"scheme",
"=",
"params",
".",
"scheme",
"||",
"\"https\"",
";",
"this",
".",
"host",
"=",
"params",
".",
"host",
"||",
"\"localhost\"",
";",
"this",
".",
"port",
"=",
"params",
".",
"port",
"||",
"8089",
";",
"this",
".",
"username",
"=",
"params",
".",
"username",
"||",
"null",
";",
"this",
".",
"password",
"=",
"params",
".",
"password",
"||",
"null",
";",
"this",
".",
"owner",
"=",
"params",
".",
"owner",
";",
"this",
".",
"app",
"=",
"params",
".",
"app",
";",
"this",
".",
"sessionKey",
"=",
"params",
".",
"sessionKey",
"||",
"\"\"",
";",
"this",
".",
"authorization",
"=",
"params",
".",
"authorization",
"||",
"\"Splunk\"",
";",
"this",
".",
"paths",
"=",
"params",
".",
"paths",
"||",
"Paths",
";",
"this",
".",
"version",
"=",
"params",
".",
"version",
"||",
"\"default\"",
";",
"this",
".",
"timeout",
"=",
"params",
".",
"timeout",
"||",
"0",
";",
"this",
".",
"autologin",
"=",
"true",
";",
"// Initialize autologin",
"// The reason we explicitly check to see if 'autologin'",
"// is actually set is because we need to distinguish the",
"// case of it being set to 'false', and it not being set.",
"// Unfortunately, in JavaScript, these are both false-y",
"if",
"(",
"params",
".",
"hasOwnProperty",
"(",
"\"autologin\"",
")",
")",
"{",
"this",
".",
"autologin",
"=",
"params",
".",
"autologin",
";",
"}",
"if",
"(",
"!",
"http",
")",
"{",
"// If there is no HTTP implementation set, we check what platform",
"// we're running on. If we're running in the browser, then complain,",
"// else, we instantiate NodeHttp.",
"if",
"(",
"typeof",
"(",
"window",
")",
"!==",
"'undefined'",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Http instance required when creating a Context within a browser.\"",
")",
";",
"}",
"else",
"{",
"var",
"NodeHttp",
"=",
"require",
"(",
"'./platform/node/node_http'",
")",
".",
"NodeHttp",
";",
"http",
"=",
"new",
"NodeHttp",
"(",
")",
";",
"}",
"}",
"// Store the HTTP implementation",
"this",
".",
"http",
"=",
"http",
";",
"this",
".",
"http",
".",
"_setSplunkVersion",
"(",
"this",
".",
"version",
")",
";",
"// Store our full prefix, which is just combining together",
"// the scheme with the host",
"var",
"versionPrefix",
"=",
"utils",
".",
"getWithVersion",
"(",
"this",
".",
"version",
",",
"prefixMap",
")",
";",
"this",
".",
"prefix",
"=",
"this",
".",
"scheme",
"+",
"\"://\"",
"+",
"this",
".",
"host",
"+",
"\":\"",
"+",
"this",
".",
"port",
"+",
"versionPrefix",
";",
"// We perform the bindings so that every function works",
"// properly when it is passed as a callback.",
"this",
".",
"_headers",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"_headers",
")",
";",
"this",
".",
"fullpath",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"fullpath",
")",
";",
"this",
".",
"urlify",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"urlify",
")",
";",
"this",
".",
"get",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"get",
")",
";",
"this",
".",
"del",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"del",
")",
";",
"this",
".",
"post",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"post",
")",
";",
"this",
".",
"login",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"login",
")",
";",
"this",
".",
"_shouldAutoLogin",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"_shouldAutoLogin",
")",
";",
"this",
".",
"_requestWrapper",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"_requestWrapper",
")",
";",
"}"
] |
Constructor for `splunkjs.Context`.
@constructor
@param {splunkjs.Http} http An instance of a `splunkjs.Http` class.
@param {Object} params A dictionary of optional parameters:
- `scheme` (_string_): The scheme ("http" or "https") for accessing Splunk.
- `host` (_string_): The host name (the default is "localhost").
- `port` (_integer_): The port number (the default is 8089).
- `username` (_string_): The Splunk account username, which is used to authenticate the Splunk instance.
- `password` (_string_): The password, which is used to authenticate the Splunk instance.
- `owner` (_string_): The owner (username) component of the namespace.
- `app` (_string_): The app component of the namespace.
- `sessionKey` (_string_): The current session token.
- `autologin` (_boolean_): `true` to automatically try to log in again if the session terminates, `false` if not (`true` by default).
- 'timeout' (_integer): The connection timeout in milliseconds. ('0' by default).
- `version` (_string_): The version string for Splunk, for example "4.3.2" (the default is "5.0").
@return {splunkjs.Context} A new `splunkjs.Context` instance.
@method splunkjs.Context
|
[
"Constructor",
"for",
"splunkjs",
".",
"Context",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L1134-L1199
|
|
13,741
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(path, namespace) {
namespace = namespace || {};
if (utils.startsWith(path, "/")) {
return path;
}
// If we don't have an app name (explicitly or implicitly), we default to /services/
if (!namespace.app && !this.app && namespace.sharing !== root.Sharing.SYSTEM) {
return "/services/" + path;
}
// Get the app and owner, first from the passed in namespace, then the service,
// finally defaulting to wild cards
var owner = namespace.owner || this.owner || "-";
var app = namespace.app || this.app || "-";
namespace.sharing = (namespace.sharing || "").toLowerCase();
// Modify the owner and app appropriately based on the sharing parameter
if (namespace.sharing === root.Sharing.APP || namespace.sharing === root.Sharing.GLOBAL) {
owner = "nobody";
}
else if (namespace.sharing === root.Sharing.SYSTEM) {
owner = "nobody";
app = "system";
}
return utils.trim("/servicesNS/" + encodeURIComponent(owner) + "/" + encodeURIComponent(app) + "/" + path);
}
|
javascript
|
function(path, namespace) {
namespace = namespace || {};
if (utils.startsWith(path, "/")) {
return path;
}
// If we don't have an app name (explicitly or implicitly), we default to /services/
if (!namespace.app && !this.app && namespace.sharing !== root.Sharing.SYSTEM) {
return "/services/" + path;
}
// Get the app and owner, first from the passed in namespace, then the service,
// finally defaulting to wild cards
var owner = namespace.owner || this.owner || "-";
var app = namespace.app || this.app || "-";
namespace.sharing = (namespace.sharing || "").toLowerCase();
// Modify the owner and app appropriately based on the sharing parameter
if (namespace.sharing === root.Sharing.APP || namespace.sharing === root.Sharing.GLOBAL) {
owner = "nobody";
}
else if (namespace.sharing === root.Sharing.SYSTEM) {
owner = "nobody";
app = "system";
}
return utils.trim("/servicesNS/" + encodeURIComponent(owner) + "/" + encodeURIComponent(app) + "/" + path);
}
|
[
"function",
"(",
"path",
",",
"namespace",
")",
"{",
"namespace",
"=",
"namespace",
"||",
"{",
"}",
";",
"if",
"(",
"utils",
".",
"startsWith",
"(",
"path",
",",
"\"/\"",
")",
")",
"{",
"return",
"path",
";",
"}",
"// If we don't have an app name (explicitly or implicitly), we default to /services/",
"if",
"(",
"!",
"namespace",
".",
"app",
"&&",
"!",
"this",
".",
"app",
"&&",
"namespace",
".",
"sharing",
"!==",
"root",
".",
"Sharing",
".",
"SYSTEM",
")",
"{",
"return",
"\"/services/\"",
"+",
"path",
";",
"}",
"// Get the app and owner, first from the passed in namespace, then the service,",
"// finally defaulting to wild cards",
"var",
"owner",
"=",
"namespace",
".",
"owner",
"||",
"this",
".",
"owner",
"||",
"\"-\"",
";",
"var",
"app",
"=",
"namespace",
".",
"app",
"||",
"this",
".",
"app",
"||",
"\"-\"",
";",
"namespace",
".",
"sharing",
"=",
"(",
"namespace",
".",
"sharing",
"||",
"\"\"",
")",
".",
"toLowerCase",
"(",
")",
";",
"// Modify the owner and app appropriately based on the sharing parameter",
"if",
"(",
"namespace",
".",
"sharing",
"===",
"root",
".",
"Sharing",
".",
"APP",
"||",
"namespace",
".",
"sharing",
"===",
"root",
".",
"Sharing",
".",
"GLOBAL",
")",
"{",
"owner",
"=",
"\"nobody\"",
";",
"}",
"else",
"if",
"(",
"namespace",
".",
"sharing",
"===",
"root",
".",
"Sharing",
".",
"SYSTEM",
")",
"{",
"owner",
"=",
"\"nobody\"",
";",
"app",
"=",
"\"system\"",
";",
"}",
"return",
"utils",
".",
"trim",
"(",
"\"/servicesNS/\"",
"+",
"encodeURIComponent",
"(",
"owner",
")",
"+",
"\"/\"",
"+",
"encodeURIComponent",
"(",
"app",
")",
"+",
"\"/\"",
"+",
"path",
")",
";",
"}"
] |
Converts a partial path to a fully-qualified path to a REST endpoint,
and if necessary includes the namespace owner and app.
@param {String} path The partial path.
@param {String} namespace The namespace, in the format "_owner_/_app_".
@return {String} The fully-qualified path.
@method splunkjs.Context
|
[
"Converts",
"a",
"partial",
"path",
"to",
"a",
"fully",
"-",
"qualified",
"path",
"to",
"a",
"REST",
"endpoint",
"and",
"if",
"necessary",
"includes",
"the",
"namespace",
"owner",
"and",
"app",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L1317-L1346
|
|
13,742
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(callback) {
var that = this;
var url = this.paths.login;
var params = {
username: this.username,
password: this.password,
cookie : '1'
};
callback = callback || function() {};
var wrappedCallback = function(err, response) {
// Let's make sure that not only did the request succeed, but
// we actually got a non-empty session key back.
var hasSessionKey = !!(!err && response.data && response.data.sessionKey);
if (err || !hasSessionKey) {
callback(err || "No session key available", false);
}
else {
that.sessionKey = response.data.sessionKey;
callback(null, true);
}
};
return this.http.post(
this.urlify(url),
this._headers(),
params,
this.timeout,
wrappedCallback
);
}
|
javascript
|
function(callback) {
var that = this;
var url = this.paths.login;
var params = {
username: this.username,
password: this.password,
cookie : '1'
};
callback = callback || function() {};
var wrappedCallback = function(err, response) {
// Let's make sure that not only did the request succeed, but
// we actually got a non-empty session key back.
var hasSessionKey = !!(!err && response.data && response.data.sessionKey);
if (err || !hasSessionKey) {
callback(err || "No session key available", false);
}
else {
that.sessionKey = response.data.sessionKey;
callback(null, true);
}
};
return this.http.post(
this.urlify(url),
this._headers(),
params,
this.timeout,
wrappedCallback
);
}
|
[
"function",
"(",
"callback",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"url",
"=",
"this",
".",
"paths",
".",
"login",
";",
"var",
"params",
"=",
"{",
"username",
":",
"this",
".",
"username",
",",
"password",
":",
"this",
".",
"password",
",",
"cookie",
":",
"'1'",
"}",
";",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"wrappedCallback",
"=",
"function",
"(",
"err",
",",
"response",
")",
"{",
"// Let's make sure that not only did the request succeed, but",
"// we actually got a non-empty session key back.",
"var",
"hasSessionKey",
"=",
"!",
"!",
"(",
"!",
"err",
"&&",
"response",
".",
"data",
"&&",
"response",
".",
"data",
".",
"sessionKey",
")",
";",
"if",
"(",
"err",
"||",
"!",
"hasSessionKey",
")",
"{",
"callback",
"(",
"err",
"||",
"\"No session key available\"",
",",
"false",
")",
";",
"}",
"else",
"{",
"that",
".",
"sessionKey",
"=",
"response",
".",
"data",
".",
"sessionKey",
";",
"callback",
"(",
"null",
",",
"true",
")",
";",
"}",
"}",
";",
"return",
"this",
".",
"http",
".",
"post",
"(",
"this",
".",
"urlify",
"(",
"url",
")",
",",
"this",
".",
"_headers",
"(",
")",
",",
"params",
",",
"this",
".",
"timeout",
",",
"wrappedCallback",
")",
";",
"}"
] |
Authenticates and logs in to a Splunk instance, then stores the
resulting session key.
@param {Function} callback The function to call when login has finished: `(err, wasSuccessful)`.
@method splunkjs.Context
@private
|
[
"Authenticates",
"and",
"logs",
"in",
"to",
"a",
"Splunk",
"instance",
"then",
"stores",
"the",
"resulting",
"session",
"key",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L1370-L1401
|
|
13,743
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(path, params, callback) {
var that = this;
var request = function(callback) {
return that.http.del(
that.urlify(path),
that._headers(),
params,
that.timeout,
callback
);
};
return this._requestWrapper(request, callback);
}
|
javascript
|
function(path, params, callback) {
var that = this;
var request = function(callback) {
return that.http.del(
that.urlify(path),
that._headers(),
params,
that.timeout,
callback
);
};
return this._requestWrapper(request, callback);
}
|
[
"function",
"(",
"path",
",",
"params",
",",
"callback",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"request",
"=",
"function",
"(",
"callback",
")",
"{",
"return",
"that",
".",
"http",
".",
"del",
"(",
"that",
".",
"urlify",
"(",
"path",
")",
",",
"that",
".",
"_headers",
"(",
")",
",",
"params",
",",
"that",
".",
"timeout",
",",
"callback",
")",
";",
"}",
";",
"return",
"this",
".",
"_requestWrapper",
"(",
"request",
",",
"callback",
")",
";",
"}"
] |
Performs a DELETE request.
@param {String} path The REST endpoint path of the DELETE request.
@param {Object} params The entity-specific parameters for this request.
@param {Function} callback The function to call when the request is complete: `(err, response)`.
@method splunkjs.Context
|
[
"Performs",
"a",
"DELETE",
"request",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L1454-L1467
|
|
13,744
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(path, method, query, post, body, headers, callback) {
var that = this;
var request = function(callback) {
return that.http.request(
that.urlify(path),
{
method: method,
headers: that._headers(headers),
query: query,
post: post,
body: body,
timeout: that.timeout
},
callback
);
};
return this._requestWrapper(request, callback);
}
|
javascript
|
function(path, method, query, post, body, headers, callback) {
var that = this;
var request = function(callback) {
return that.http.request(
that.urlify(path),
{
method: method,
headers: that._headers(headers),
query: query,
post: post,
body: body,
timeout: that.timeout
},
callback
);
};
return this._requestWrapper(request, callback);
}
|
[
"function",
"(",
"path",
",",
"method",
",",
"query",
",",
"post",
",",
"body",
",",
"headers",
",",
"callback",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"request",
"=",
"function",
"(",
"callback",
")",
"{",
"return",
"that",
".",
"http",
".",
"request",
"(",
"that",
".",
"urlify",
"(",
"path",
")",
",",
"{",
"method",
":",
"method",
",",
"headers",
":",
"that",
".",
"_headers",
"(",
"headers",
")",
",",
"query",
":",
"query",
",",
"post",
":",
"post",
",",
"body",
":",
"body",
",",
"timeout",
":",
"that",
".",
"timeout",
"}",
",",
"callback",
")",
";",
"}",
";",
"return",
"this",
".",
"_requestWrapper",
"(",
"request",
",",
"callback",
")",
";",
"}"
] |
Issues an arbitrary HTTP request to the REST endpoint path segment.
@param {String} path The REST endpoint path segment (with any query parameters already appended and encoded).
@param {String} method The HTTP method (can be `GET`, `POST`, or `DELETE`).
@param {Object} query The entity-specific parameters for this request.
@param {Object} post A dictionary of POST argument that will get form encoded.
@param {Object} body The body of the request, mutually exclusive with `post`.
@param {Object} headers Headers for this request.
@param {Function} callback The function to call when the request is complete: `(err, response)`.
@method splunkjs.Context
|
[
"Issues",
"an",
"arbitrary",
"HTTP",
"request",
"to",
"the",
"REST",
"endpoint",
"path",
"segment",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L1506-L1524
|
|
13,745
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function() {
this._super.apply(this, arguments);
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this.specialize = utils.bind(this, this.specialize);
this.apps = utils.bind(this, this.apps);
this.configurations = utils.bind(this, this.configurations);
this.indexes = utils.bind(this, this.indexes);
this.savedSearches = utils.bind(this, this.savedSearches);
this.jobs = utils.bind(this, this.jobs);
this.users = utils.bind(this, this.users);
this.currentUser = utils.bind(this, this.currentUser);
this.views = utils.bind(this, this.views);
this.firedAlertGroups = utils.bind(this, this.firedAlertGroups);
this.dataModels = utils.bind(this, this.dataModels);
}
|
javascript
|
function() {
this._super.apply(this, arguments);
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this.specialize = utils.bind(this, this.specialize);
this.apps = utils.bind(this, this.apps);
this.configurations = utils.bind(this, this.configurations);
this.indexes = utils.bind(this, this.indexes);
this.savedSearches = utils.bind(this, this.savedSearches);
this.jobs = utils.bind(this, this.jobs);
this.users = utils.bind(this, this.users);
this.currentUser = utils.bind(this, this.currentUser);
this.views = utils.bind(this, this.views);
this.firedAlertGroups = utils.bind(this, this.firedAlertGroups);
this.dataModels = utils.bind(this, this.dataModels);
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"_super",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"// We perform the bindings so that every function works ",
"// properly when it is passed as a callback.",
"this",
".",
"specialize",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"specialize",
")",
";",
"this",
".",
"apps",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"apps",
")",
";",
"this",
".",
"configurations",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"configurations",
")",
";",
"this",
".",
"indexes",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"indexes",
")",
";",
"this",
".",
"savedSearches",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"savedSearches",
")",
";",
"this",
".",
"jobs",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"jobs",
")",
";",
"this",
".",
"users",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"users",
")",
";",
"this",
".",
"currentUser",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"currentUser",
")",
";",
"this",
".",
"views",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"views",
")",
";",
"this",
".",
"firedAlertGroups",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"firedAlertGroups",
")",
";",
"this",
".",
"dataModels",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"dataModels",
")",
";",
"}"
] |
Constructor for `splunkjs.Service`.
@constructor
@param {splunkjs.Http} http An instance of a `splunkjs.Http` class.
@param {Object} params A dictionary of optional parameters:
- `scheme` (_string_): The scheme ("http" or "https") for accessing Splunk.
- `host` (_string_): The host name (the default is "localhost").
- `port` (_integer_): The port number (the default is 8089).
- `username` (_string_): The Splunk account username, which is used to authenticate the Splunk instance.
- `password` (_string_): The password, which is used to authenticate the Splunk instance.
- `owner` (_string_): The owner (username) component of the namespace.
- `app` (_string_): The app component of the namespace.
- `sessionKey` (_string_): The current session token.
- `autologin` (_boolean_): `true` to automatically try to log in again if the session terminates, `false` if not (`true` by default).
- `version` (_string_): The version string for Splunk, for example "4.3.2" (the default is "5.0").
@return {splunkjs.Service} A new `splunkjs.Service` instance.
@method splunkjs.Service
|
[
"Constructor",
"for",
"splunkjs",
".",
"Service",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L2303-L2319
|
|
13,746
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(owner, app) {
return new Service(this.http, {
scheme: this.scheme,
host: this.host,
port: this.port,
username: this.username,
password: this.password,
owner: owner,
app: app,
sessionKey: this.sessionKey,
version: this.version
});
}
|
javascript
|
function(owner, app) {
return new Service(this.http, {
scheme: this.scheme,
host: this.host,
port: this.port,
username: this.username,
password: this.password,
owner: owner,
app: app,
sessionKey: this.sessionKey,
version: this.version
});
}
|
[
"function",
"(",
"owner",
",",
"app",
")",
"{",
"return",
"new",
"Service",
"(",
"this",
".",
"http",
",",
"{",
"scheme",
":",
"this",
".",
"scheme",
",",
"host",
":",
"this",
".",
"host",
",",
"port",
":",
"this",
".",
"port",
",",
"username",
":",
"this",
".",
"username",
",",
"password",
":",
"this",
".",
"password",
",",
"owner",
":",
"owner",
",",
"app",
":",
"app",
",",
"sessionKey",
":",
"this",
".",
"sessionKey",
",",
"version",
":",
"this",
".",
"version",
"}",
")",
";",
"}"
] |
Creates a specialized version of the current `Service` instance for
a specific namespace context.
@example
var svc = ...;
var newService = svc.specialize("myuser", "unix");
@param {String} owner The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
@param {String} app The app context for this resource (such as "search"). The "-" wildcard means all apps.
@return {splunkjs.Service} The specialized `Service` instance.
@method splunkjs.Service
|
[
"Creates",
"a",
"specialized",
"version",
"of",
"the",
"current",
"Service",
"instance",
"for",
"a",
"specific",
"namespace",
"context",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L2336-L2348
|
|
13,747
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(sid, namespace, callback) {
if (!callback && utils.isFunction(namespace)) {
callback = namespace;
namespace = null;
}
var job = new root.Job(this, sid, namespace);
return job.fetch({}, callback);
}
|
javascript
|
function(sid, namespace, callback) {
if (!callback && utils.isFunction(namespace)) {
callback = namespace;
namespace = null;
}
var job = new root.Job(this, sid, namespace);
return job.fetch({}, callback);
}
|
[
"function",
"(",
"sid",
",",
"namespace",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"callback",
"&&",
"utils",
".",
"isFunction",
"(",
"namespace",
")",
")",
"{",
"callback",
"=",
"namespace",
";",
"namespace",
"=",
"null",
";",
"}",
"var",
"job",
"=",
"new",
"root",
".",
"Job",
"(",
"this",
",",
"sid",
",",
"namespace",
")",
";",
"return",
"job",
".",
"fetch",
"(",
"{",
"}",
",",
"callback",
")",
";",
"}"
] |
A convenience method to get a `Job` by its sid.
@param {String} sid The search ID for a search job.
@param {Object} namespace Namespace information:
- `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
- `app` (_string_): The app context for this resource (such as "search"). The "-" wildcard means all apps.
- `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".
@param {Function} callback A function to call with the created job: `(err, job)`.
@endpoint search/jobs
@method splunkjs.Service
|
[
"A",
"convenience",
"method",
"to",
"get",
"a",
"Job",
"by",
"its",
"sid",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L2650-L2657
|
|
13,748
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(callback) {
callback = callback || function() {};
var that = this;
var req = this.get(Paths.currentUser, {}, function(err, response) {
if (err) {
callback(err);
}
else {
var username = response.data.entry[0].content.username;
var user = new root.User(that, username);
user.fetch(function() {
if (req.wasAborted) {
return; // aborted, so ignore
}
else {
callback.apply(null, arguments);
}
});
}
});
return req;
}
|
javascript
|
function(callback) {
callback = callback || function() {};
var that = this;
var req = this.get(Paths.currentUser, {}, function(err, response) {
if (err) {
callback(err);
}
else {
var username = response.data.entry[0].content.username;
var user = new root.User(that, username);
user.fetch(function() {
if (req.wasAborted) {
return; // aborted, so ignore
}
else {
callback.apply(null, arguments);
}
});
}
});
return req;
}
|
[
"function",
"(",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"that",
"=",
"this",
";",
"var",
"req",
"=",
"this",
".",
"get",
"(",
"Paths",
".",
"currentUser",
",",
"{",
"}",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"var",
"username",
"=",
"response",
".",
"data",
".",
"entry",
"[",
"0",
"]",
".",
"content",
".",
"username",
";",
"var",
"user",
"=",
"new",
"root",
".",
"User",
"(",
"that",
",",
"username",
")",
";",
"user",
".",
"fetch",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"req",
".",
"wasAborted",
")",
"{",
"return",
";",
"// aborted, so ignore",
"}",
"else",
"{",
"callback",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
")",
";",
"return",
"req",
";",
"}"
] |
Gets the user that is currently logged in.
@example
service.currentUser(function(err, user) {
console.log("Real name: ", user.properties().realname);
});
@param {Function} callback A function to call with the user instance: `(err, user)`.
@return {splunkjs.Service.currentUser} The `User`.
@endpoint authorization/current-context
@method splunkjs.Service
|
[
"Gets",
"the",
"user",
"that",
"is",
"currently",
"logged",
"in",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L2708-L2731
|
|
13,749
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(query, params, callback) {
if (!callback && utils.isFunction(params)) {
callback = params;
params = {};
}
callback = callback || function() {};
params = params || {};
params.q = query;
return this.get(Paths.parser, params, function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, response.data);
}
});
}
|
javascript
|
function(query, params, callback) {
if (!callback && utils.isFunction(params)) {
callback = params;
params = {};
}
callback = callback || function() {};
params = params || {};
params.q = query;
return this.get(Paths.parser, params, function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, response.data);
}
});
}
|
[
"function",
"(",
"query",
",",
"params",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"callback",
"&&",
"utils",
".",
"isFunction",
"(",
"params",
")",
")",
"{",
"callback",
"=",
"params",
";",
"params",
"=",
"{",
"}",
";",
"}",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"params",
".",
"q",
"=",
"query",
";",
"return",
"this",
".",
"get",
"(",
"Paths",
".",
"parser",
",",
"params",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"response",
".",
"data",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Parses a search query.
@example
service.parse("search index=_internal | head 1", function(err, parse) {
console.log("Commands: ", parse.commands);
});
@param {String} query The search query to parse.
@param {Object} params An object of options for the parser:
- `enable_lookups` (_boolean_): If `true`, performs reverse lookups to expand the search expression.
- `output_mode` (_string_): The output format (XML or JSON).
- `parse_only` (_boolean_): If `true`, disables the expansion of search due to evaluation of subsearches, time term expansion, lookups, tags, eventtypes, and sourcetype alias.
- `reload_macros` (_boolean_): If `true`, reloads macro definitions from macros.conf.
@param {Function} callback A function to call with the parse info: `(err, parse)`.
@endpoint search/parser
@method splunkjs.Service
|
[
"Parses",
"a",
"search",
"query",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L2774-L2793
|
|
13,750
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(prefix, count, callback) {
if (!callback && utils.isFunction(count)) {
callback = count;
count = 10;
}
callback = callback || function() {};
var params = {
count: count || 10,
prefix: prefix
};
return this.get(Paths.typeahead, params, function(err, response) {
if (err) {
callback(err);
}
else {
var results = (response.data || {}).results;
callback(null, results || []);
}
});
}
|
javascript
|
function(prefix, count, callback) {
if (!callback && utils.isFunction(count)) {
callback = count;
count = 10;
}
callback = callback || function() {};
var params = {
count: count || 10,
prefix: prefix
};
return this.get(Paths.typeahead, params, function(err, response) {
if (err) {
callback(err);
}
else {
var results = (response.data || {}).results;
callback(null, results || []);
}
});
}
|
[
"function",
"(",
"prefix",
",",
"count",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"callback",
"&&",
"utils",
".",
"isFunction",
"(",
"count",
")",
")",
"{",
"callback",
"=",
"count",
";",
"count",
"=",
"10",
";",
"}",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"params",
"=",
"{",
"count",
":",
"count",
"||",
"10",
",",
"prefix",
":",
"prefix",
"}",
";",
"return",
"this",
".",
"get",
"(",
"Paths",
".",
"typeahead",
",",
"params",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"var",
"results",
"=",
"(",
"response",
".",
"data",
"||",
"{",
"}",
")",
".",
"results",
";",
"callback",
"(",
"null",
",",
"results",
"||",
"[",
"]",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Provides auto-complete suggestions for search queries.
@example
service.typeahead("index=", 10, function(err, options) {
console.log("Autocompletion options: ", options);
});
@param {String} prefix The query fragment to autocomplete.
@param {Number} count The number of options to return (optional).
@param {Function} callback A function to call with the autocompletion info: `(err, options)`.
@endpoint search/typeahead
@method splunkjs.Service
|
[
"Provides",
"auto",
"-",
"complete",
"suggestions",
"for",
"search",
"queries",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L2811-L2832
|
|
13,751
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(event, params, callback) {
if (!callback && utils.isFunction(params)) {
callback = params;
params = {};
}
callback = callback || function() {};
params = params || {};
// If the event is a JSON object, convert it to a string.
if (utils.isObject(event)) {
event = JSON.stringify(event);
}
var path = this.paths.submitEvent;
var method = "POST";
var headers = {"Content-Type": "text/plain"};
var body = event;
var get = params;
var post = {};
var req = this.request(
path,
method,
get,
post,
body,
headers,
function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, response.data);
}
}
);
return req;
}
|
javascript
|
function(event, params, callback) {
if (!callback && utils.isFunction(params)) {
callback = params;
params = {};
}
callback = callback || function() {};
params = params || {};
// If the event is a JSON object, convert it to a string.
if (utils.isObject(event)) {
event = JSON.stringify(event);
}
var path = this.paths.submitEvent;
var method = "POST";
var headers = {"Content-Type": "text/plain"};
var body = event;
var get = params;
var post = {};
var req = this.request(
path,
method,
get,
post,
body,
headers,
function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, response.data);
}
}
);
return req;
}
|
[
"function",
"(",
"event",
",",
"params",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"callback",
"&&",
"utils",
".",
"isFunction",
"(",
"params",
")",
")",
"{",
"callback",
"=",
"params",
";",
"params",
"=",
"{",
"}",
";",
"}",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"// If the event is a JSON object, convert it to a string.",
"if",
"(",
"utils",
".",
"isObject",
"(",
"event",
")",
")",
"{",
"event",
"=",
"JSON",
".",
"stringify",
"(",
"event",
")",
";",
"}",
"var",
"path",
"=",
"this",
".",
"paths",
".",
"submitEvent",
";",
"var",
"method",
"=",
"\"POST\"",
";",
"var",
"headers",
"=",
"{",
"\"Content-Type\"",
":",
"\"text/plain\"",
"}",
";",
"var",
"body",
"=",
"event",
";",
"var",
"get",
"=",
"params",
";",
"var",
"post",
"=",
"{",
"}",
";",
"var",
"req",
"=",
"this",
".",
"request",
"(",
"path",
",",
"method",
",",
"get",
",",
"post",
",",
"body",
",",
"headers",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"response",
".",
"data",
")",
";",
"}",
"}",
")",
";",
"return",
"req",
";",
"}"
] |
Logs an event to Splunk.
@example
service.log("A new event", {index: "_internal", sourcetype: "mysourcetype"}, function(err, result) {
console.log("Submitted event: ", result);
});
@param {String|Object} event The text for this event, or a JSON object.
@param {Object} params A dictionary of parameters for indexing:
- `index` (_string_): The index to send events from this input to.
- `host` (_string_): The value to populate in the Host field for events from this data input.
- `host_regex` (_string_): A regular expression used to extract the host value from each event.
- `source` (_string_): The value to populate in the Source field for events from this data input.
- `sourcetype` (_string_): The value to populate in the Sourcetype field for events from this data input.
@param {Function} callback A function to call when the event is submitted: `(err, result)`.
@endpoint receivers/simple
@method splunkjs.Service
|
[
"Logs",
"an",
"event",
"to",
"Splunk",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L2855-L2894
|
|
13,752
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(service, qualifiedPath) {
if (!service) {
throw new Error("Passed in a null Service.");
}
if (!qualifiedPath) {
throw new Error("Passed in an empty path.");
}
this.service = service;
this.qualifiedPath = qualifiedPath;
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this.get = utils.bind(this, this.get);
this.post = utils.bind(this, this.post);
this.del = utils.bind(this, this.del);
}
|
javascript
|
function(service, qualifiedPath) {
if (!service) {
throw new Error("Passed in a null Service.");
}
if (!qualifiedPath) {
throw new Error("Passed in an empty path.");
}
this.service = service;
this.qualifiedPath = qualifiedPath;
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this.get = utils.bind(this, this.get);
this.post = utils.bind(this, this.post);
this.del = utils.bind(this, this.del);
}
|
[
"function",
"(",
"service",
",",
"qualifiedPath",
")",
"{",
"if",
"(",
"!",
"service",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Passed in a null Service.\"",
")",
";",
"}",
"if",
"(",
"!",
"qualifiedPath",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Passed in an empty path.\"",
")",
";",
"}",
"this",
".",
"service",
"=",
"service",
";",
"this",
".",
"qualifiedPath",
"=",
"qualifiedPath",
";",
"// We perform the bindings so that every function works ",
"// properly when it is passed as a callback.",
"this",
".",
"get",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"get",
")",
";",
"this",
".",
"post",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"post",
")",
";",
"this",
".",
"del",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"del",
")",
";",
"}"
] |
Constructor for `splunkjs.Service.Endpoint`.
@constructor
@param {splunkjs.Service} service A `Service` instance.
@param {String} qualifiedPath A fully-qualified relative endpoint path (for example, "/services/search/jobs").
@return {splunkjs.Service.Endpoint} A new `splunkjs.Service.Endpoint` instance.
@method splunkjs.Service.Endpoint
|
[
"Constructor",
"for",
"splunkjs",
".",
"Service",
".",
"Endpoint",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L2916-L2933
|
|
13,753
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(relpath, params, callback) {
var url = this.qualifiedPath;
// If we have a relative path, we will append it with a preceding
// slash.
if (relpath) {
url = url + "/" + relpath;
}
return this.service.get(
url,
params,
callback
);
}
|
javascript
|
function(relpath, params, callback) {
var url = this.qualifiedPath;
// If we have a relative path, we will append it with a preceding
// slash.
if (relpath) {
url = url + "/" + relpath;
}
return this.service.get(
url,
params,
callback
);
}
|
[
"function",
"(",
"relpath",
",",
"params",
",",
"callback",
")",
"{",
"var",
"url",
"=",
"this",
".",
"qualifiedPath",
";",
"// If we have a relative path, we will append it with a preceding",
"// slash.",
"if",
"(",
"relpath",
")",
"{",
"url",
"=",
"url",
"+",
"\"/\"",
"+",
"relpath",
";",
"}",
"return",
"this",
".",
"service",
".",
"get",
"(",
"url",
",",
"params",
",",
"callback",
")",
";",
"}"
] |
Performs a relative GET request on an endpoint's path,
combined with the parameters and a relative path if specified.
@example
// Will make a request to {service.prefix}/search/jobs/123456/results?offset=1
var endpoint = new splunkjs.Service.Endpoint(service, "search/jobs/12345");
endpoint.get("results", {offset: 1}, function() { console.log("DONE"))});
@param {String} relpath A relative path to append to the endpoint path.
@param {Object} params A dictionary of entity-specific parameters to add to the query string.
@param {Function} callback A function to call when the request is complete: `(err, response)`.
@method splunkjs.Service.Endpoint
|
[
"Performs",
"a",
"relative",
"GET",
"request",
"on",
"an",
"endpoint",
"s",
"path",
"combined",
"with",
"the",
"parameters",
"and",
"a",
"relative",
"path",
"if",
"specified",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L2951-L2965
|
|
13,754
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(relpath, params, callback) {
var url = this.qualifiedPath;
// If we have a relative path, we will append it with a preceding
// slash.
if (relpath) {
url = url + "/" + relpath;
}
return this.service.post(
url,
params,
callback
);
}
|
javascript
|
function(relpath, params, callback) {
var url = this.qualifiedPath;
// If we have a relative path, we will append it with a preceding
// slash.
if (relpath) {
url = url + "/" + relpath;
}
return this.service.post(
url,
params,
callback
);
}
|
[
"function",
"(",
"relpath",
",",
"params",
",",
"callback",
")",
"{",
"var",
"url",
"=",
"this",
".",
"qualifiedPath",
";",
"// If we have a relative path, we will append it with a preceding",
"// slash.",
"if",
"(",
"relpath",
")",
"{",
"url",
"=",
"url",
"+",
"\"/\"",
"+",
"relpath",
";",
"}",
"return",
"this",
".",
"service",
".",
"post",
"(",
"url",
",",
"params",
",",
"callback",
")",
";",
"}"
] |
Performs a relative POST request on an endpoint's path,
combined with the parameters and a relative path if specified.
@example
// Will make a request to {service.prefix}/search/jobs/123456/control
var endpoint = new splunkjs.Service.Endpoint(service, "search/jobs/12345");
endpoint.post("control", {action: "cancel"}, function() { console.log("CANCELLED"))});
@param {String} relpath A relative path to append to the endpoint path.
@param {Object} params A dictionary of entity-specific parameters to add to the body.
@param {Function} callback A function to call when the request is complete: `(err, response)`.
@method splunkjs.Service.Endpoint
|
[
"Performs",
"a",
"relative",
"POST",
"request",
"on",
"an",
"endpoint",
"s",
"path",
"combined",
"with",
"the",
"parameters",
"and",
"a",
"relative",
"path",
"if",
"specified",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L2983-L2997
|
|
13,755
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(relpath, params, callback) {
var url = this.qualifiedPath;
// If we have a relative path, we will append it with a preceding
// slash.
if (relpath) {
url = url + "/" + relpath;
}
return this.service.del(
url,
params,
callback
);
}
|
javascript
|
function(relpath, params, callback) {
var url = this.qualifiedPath;
// If we have a relative path, we will append it with a preceding
// slash.
if (relpath) {
url = url + "/" + relpath;
}
return this.service.del(
url,
params,
callback
);
}
|
[
"function",
"(",
"relpath",
",",
"params",
",",
"callback",
")",
"{",
"var",
"url",
"=",
"this",
".",
"qualifiedPath",
";",
"// If we have a relative path, we will append it with a preceding",
"// slash.",
"if",
"(",
"relpath",
")",
"{",
"url",
"=",
"url",
"+",
"\"/\"",
"+",
"relpath",
";",
"}",
"return",
"this",
".",
"service",
".",
"del",
"(",
"url",
",",
"params",
",",
"callback",
")",
";",
"}"
] |
Performs a relative DELETE request on an endpoint's path,
combined with the parameters and a relative path if specified.
@example
// Will make a request to {service.prefix}/search/jobs/123456
var endpoint = new splunkjs.Service.Endpoint(service, "search/jobs/12345");
endpoint.delete("", {}, function() { console.log("DELETED"))});
@param {String} relpath A relative path to append to the endpoint path.
@param {Object} params A dictionary of entity-specific parameters to add to the query string.
@param {Function} callback A function to call when the request is complete: `(err, response)`.
@method splunkjs.Service.Endpoint
|
[
"Performs",
"a",
"relative",
"DELETE",
"request",
"on",
"an",
"endpoint",
"s",
"path",
"combined",
"with",
"the",
"parameters",
"and",
"a",
"relative",
"path",
"if",
"specified",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L3015-L3029
|
|
13,756
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(service, path, namespace) {
var fullpath = service.fullpath(path, namespace);
this._super(service, fullpath);
this.namespace = namespace;
this._properties = {};
this._state = {};
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this._load = utils.bind(this, this._load);
this.fetch = utils.bind(this, this.fetch);
this.properties = utils.bind(this, this.properties);
this.state = utils.bind(this, this.state);
this.path = utils.bind(this, this.path);
}
|
javascript
|
function(service, path, namespace) {
var fullpath = service.fullpath(path, namespace);
this._super(service, fullpath);
this.namespace = namespace;
this._properties = {};
this._state = {};
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this._load = utils.bind(this, this._load);
this.fetch = utils.bind(this, this.fetch);
this.properties = utils.bind(this, this.properties);
this.state = utils.bind(this, this.state);
this.path = utils.bind(this, this.path);
}
|
[
"function",
"(",
"service",
",",
"path",
",",
"namespace",
")",
"{",
"var",
"fullpath",
"=",
"service",
".",
"fullpath",
"(",
"path",
",",
"namespace",
")",
";",
"this",
".",
"_super",
"(",
"service",
",",
"fullpath",
")",
";",
"this",
".",
"namespace",
"=",
"namespace",
";",
"this",
".",
"_properties",
"=",
"{",
"}",
";",
"this",
".",
"_state",
"=",
"{",
"}",
";",
"// We perform the bindings so that every function works ",
"// properly when it is passed as a callback.",
"this",
".",
"_load",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"_load",
")",
";",
"this",
".",
"fetch",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"fetch",
")",
";",
"this",
".",
"properties",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"properties",
")",
";",
"this",
".",
"state",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"state",
")",
";",
"this",
".",
"path",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"path",
")",
";",
"}"
] |
Constructor for `splunkjs.Service.Resource`.
@constructor
@param {splunkjs.Service} service A `Service` instance.
@param {String} path A relative endpoint path (for example, "search/jobs").
@param {Object} namespace Namespace information:
- `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
- `app` (_string_): The app context for this resource (such as "search"). The "-" wildcard means all apps.
- `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".
@return {splunkjs.Service.Resource} A new `splunkjs.Service.Resource` instance.
@method splunkjs.Service.Resource
|
[
"Constructor",
"for",
"splunkjs",
".",
"Service",
".",
"Resource",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L3058-L3073
|
|
13,757
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(service, path, namespace) {
this._super(service, path, namespace);
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this._load = utils.bind(this, this._load);
this.fetch = utils.bind(this, this.fetch);
this.remove = utils.bind(this, this.remove);
this.update = utils.bind(this, this.update);
this.fields = utils.bind(this, this.fields);
this.links = utils.bind(this, this.links);
this.acl = utils.bind(this, this.acl);
this.author = utils.bind(this, this.author);
this.updated = utils.bind(this, this.updated);
this.published = utils.bind(this, this.published);
this.enable = utils.bind(this, this.enable);
this.disable = utils.bind(this, this.disable);
this.reload = utils.bind(this, this.reload);
// Initial values
this._properties = {};
this._fields = {};
this._acl = {};
this._links = {};
}
|
javascript
|
function(service, path, namespace) {
this._super(service, path, namespace);
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this._load = utils.bind(this, this._load);
this.fetch = utils.bind(this, this.fetch);
this.remove = utils.bind(this, this.remove);
this.update = utils.bind(this, this.update);
this.fields = utils.bind(this, this.fields);
this.links = utils.bind(this, this.links);
this.acl = utils.bind(this, this.acl);
this.author = utils.bind(this, this.author);
this.updated = utils.bind(this, this.updated);
this.published = utils.bind(this, this.published);
this.enable = utils.bind(this, this.enable);
this.disable = utils.bind(this, this.disable);
this.reload = utils.bind(this, this.reload);
// Initial values
this._properties = {};
this._fields = {};
this._acl = {};
this._links = {};
}
|
[
"function",
"(",
"service",
",",
"path",
",",
"namespace",
")",
"{",
"this",
".",
"_super",
"(",
"service",
",",
"path",
",",
"namespace",
")",
";",
"// We perform the bindings so that every function works ",
"// properly when it is passed as a callback.",
"this",
".",
"_load",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"_load",
")",
";",
"this",
".",
"fetch",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"fetch",
")",
";",
"this",
".",
"remove",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"remove",
")",
";",
"this",
".",
"update",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"update",
")",
";",
"this",
".",
"fields",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"fields",
")",
";",
"this",
".",
"links",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"links",
")",
";",
"this",
".",
"acl",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"acl",
")",
";",
"this",
".",
"author",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"author",
")",
";",
"this",
".",
"updated",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"updated",
")",
";",
"this",
".",
"published",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"published",
")",
";",
"this",
".",
"enable",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"enable",
")",
";",
"this",
".",
"disable",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"disable",
")",
";",
"this",
".",
"reload",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"reload",
")",
";",
"// Initial values",
"this",
".",
"_properties",
"=",
"{",
"}",
";",
"this",
".",
"_fields",
"=",
"{",
"}",
";",
"this",
".",
"_acl",
"=",
"{",
"}",
";",
"this",
".",
"_links",
"=",
"{",
"}",
";",
"}"
] |
Constructor for `splunkjs.Service.Entity`.
@constructor
@param {splunkjs.Service} service A `Service` instance.
@param {String} path A relative endpoint path (for example, "search/jobs").
@param {Object} namespace Namespace information:
- `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
- `app` (_string_): The app context for this resource (such as "search"). The "-" wildcard means all apps.
- `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".
@return {splunkjs.Service.Entity} A new `splunkjs.Service.Entity` instance.
@method splunkjs.Service.Entity
|
[
"Constructor",
"for",
"splunkjs",
".",
"Service",
".",
"Entity",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L3168-L3192
|
|
13,758
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(properties) {
properties = utils.isArray(properties) ? properties[0] : properties;
// Initialize the properties to
// empty values
properties = properties || {
content: {},
fields: {},
acl: {},
links: {}
};
this._super(properties);
// Take out the entity-specific content
this._properties = properties.content || {};
this._fields = properties.fields || this._fields || {};
this._acl = properties.acl || {};
this._links = properties.links || {};
this._author = properties.author || null;
this._updated = properties.updated || null;
this._published = properties.published || null;
}
|
javascript
|
function(properties) {
properties = utils.isArray(properties) ? properties[0] : properties;
// Initialize the properties to
// empty values
properties = properties || {
content: {},
fields: {},
acl: {},
links: {}
};
this._super(properties);
// Take out the entity-specific content
this._properties = properties.content || {};
this._fields = properties.fields || this._fields || {};
this._acl = properties.acl || {};
this._links = properties.links || {};
this._author = properties.author || null;
this._updated = properties.updated || null;
this._published = properties.published || null;
}
|
[
"function",
"(",
"properties",
")",
"{",
"properties",
"=",
"utils",
".",
"isArray",
"(",
"properties",
")",
"?",
"properties",
"[",
"0",
"]",
":",
"properties",
";",
"// Initialize the properties to",
"// empty values",
"properties",
"=",
"properties",
"||",
"{",
"content",
":",
"{",
"}",
",",
"fields",
":",
"{",
"}",
",",
"acl",
":",
"{",
"}",
",",
"links",
":",
"{",
"}",
"}",
";",
"this",
".",
"_super",
"(",
"properties",
")",
";",
"// Take out the entity-specific content",
"this",
".",
"_properties",
"=",
"properties",
".",
"content",
"||",
"{",
"}",
";",
"this",
".",
"_fields",
"=",
"properties",
".",
"fields",
"||",
"this",
".",
"_fields",
"||",
"{",
"}",
";",
"this",
".",
"_acl",
"=",
"properties",
".",
"acl",
"||",
"{",
"}",
";",
"this",
".",
"_links",
"=",
"properties",
".",
"links",
"||",
"{",
"}",
";",
"this",
".",
"_author",
"=",
"properties",
".",
"author",
"||",
"null",
";",
"this",
".",
"_updated",
"=",
"properties",
".",
"updated",
"||",
"null",
";",
"this",
".",
"_published",
"=",
"properties",
".",
"published",
"||",
"null",
";",
"}"
] |
Loads the entity and stores the properties.
@param {Object} properties The properties for this entity.
@method splunkjs.Service.Entity
@protected
|
[
"Loads",
"the",
"entity",
"and",
"stores",
"the",
"properties",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L3202-L3224
|
|
13,759
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(options, callback) {
if (!callback && utils.isFunction(options)) {
callback = options;
options = {};
}
callback = callback || function() {};
options = options || {};
var that = this;
return this.get("", options, function(err, response) {
if (err) {
callback(err);
}
else {
that._load(response.data ? response.data.entry : null);
callback(null, that);
}
});
}
|
javascript
|
function(options, callback) {
if (!callback && utils.isFunction(options)) {
callback = options;
options = {};
}
callback = callback || function() {};
options = options || {};
var that = this;
return this.get("", options, function(err, response) {
if (err) {
callback(err);
}
else {
that._load(response.data ? response.data.entry : null);
callback(null, that);
}
});
}
|
[
"function",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"callback",
"&&",
"utils",
".",
"isFunction",
"(",
"options",
")",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"that",
"=",
"this",
";",
"return",
"this",
".",
"get",
"(",
"\"\"",
",",
"options",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"that",
".",
"_load",
"(",
"response",
".",
"data",
"?",
"response",
".",
"data",
".",
"entry",
":",
"null",
")",
";",
"callback",
"(",
"null",
",",
"that",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Refreshes the entity by fetching the object from the server and
loading it.
@param {Object} options An optional dictionary of collection filtering and pagination options:
- `count` (_integer_): The maximum number of items to return.
- `offset` (_integer_): The offset of the first item to return.
- `search` (_string_): The search query to filter responses.
- `sort_dir` (_string_): The direction to sort returned items: “asc” or “desc”.
- `sort_key` (_string_): The field to use for sorting (optional).
- `sort_mode` (_string_): The collating sequence for sorting returned items: “auto”, “alpha”, “alpha_case”, or “num”.
@param {Function} callback A function to call when the object is retrieved: `(err, resource)`.
@method splunkjs.Service.Entity
|
[
"Refreshes",
"the",
"entity",
"by",
"fetching",
"the",
"object",
"from",
"the",
"server",
"and",
"loading",
"it",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L3310-L3329
|
|
13,760
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(props, callback) {
callback = callback || function() {};
if (props.hasOwnProperty("name")) {
throw new Error("Cannot set 'name' field in 'update'");
}
var that = this;
var req = this.post("", props, function(err, response) {
if (!err && !that.fetchOnUpdate) {
that._load(response.data.entry);
callback(err, that);
}
else if (!err && that.fetchOnUpdate) {
that.fetch(function() {
if (req.wasAborted) {
return; // aborted, so ignore
}
else {
callback.apply(null, arguments);
}
});
}
else {
callback(err, that);
}
});
return req;
}
|
javascript
|
function(props, callback) {
callback = callback || function() {};
if (props.hasOwnProperty("name")) {
throw new Error("Cannot set 'name' field in 'update'");
}
var that = this;
var req = this.post("", props, function(err, response) {
if (!err && !that.fetchOnUpdate) {
that._load(response.data.entry);
callback(err, that);
}
else if (!err && that.fetchOnUpdate) {
that.fetch(function() {
if (req.wasAborted) {
return; // aborted, so ignore
}
else {
callback.apply(null, arguments);
}
});
}
else {
callback(err, that);
}
});
return req;
}
|
[
"function",
"(",
"props",
",",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"if",
"(",
"props",
".",
"hasOwnProperty",
"(",
"\"name\"",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Cannot set 'name' field in 'update'\"",
")",
";",
"}",
"var",
"that",
"=",
"this",
";",
"var",
"req",
"=",
"this",
".",
"post",
"(",
"\"\"",
",",
"props",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"!",
"err",
"&&",
"!",
"that",
".",
"fetchOnUpdate",
")",
"{",
"that",
".",
"_load",
"(",
"response",
".",
"data",
".",
"entry",
")",
";",
"callback",
"(",
"err",
",",
"that",
")",
";",
"}",
"else",
"if",
"(",
"!",
"err",
"&&",
"that",
".",
"fetchOnUpdate",
")",
"{",
"that",
".",
"fetch",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"req",
".",
"wasAborted",
")",
"{",
"return",
";",
"// aborted, so ignore",
"}",
"else",
"{",
"callback",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"err",
",",
"that",
")",
";",
"}",
"}",
")",
";",
"return",
"req",
";",
"}"
] |
Updates the entity on the server.
@param {Object} props The properties to update the object with.
@param {Function} callback A function to call when the object is updated: `(err, entity)`.
@method splunkjs.Service.Entity
@protected
|
[
"Updates",
"the",
"entity",
"on",
"the",
"server",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L3357-L3386
|
|
13,761
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(callback) {
callback = callback || function() {};
var that = this;
this.post("disable", {}, function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, that);
}
});
}
|
javascript
|
function(callback) {
callback = callback || function() {};
var that = this;
this.post("disable", {}, function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, that);
}
});
}
|
[
"function",
"(",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"that",
"=",
"this",
";",
"this",
".",
"post",
"(",
"\"disable\"",
",",
"{",
"}",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"that",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Disables the entity on the server.
@param {Function} callback A function to call when the object is disabled: `(err, entity)`.
@method splunkjs.Service.Entity
@protected
|
[
"Disables",
"the",
"entity",
"on",
"the",
"server",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L3396-L3408
|
|
13,762
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(service, path, namespace) {
this._super(service, path, namespace);
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this._load = utils.bind(this, this._load);
this.fetch = utils.bind(this, this.fetch);
this.create = utils.bind(this, this.create);
this.list = utils.bind(this, this.list);
this.item = utils.bind(this, this.item);
this.instantiateEntity = utils.bind(this, this.instantiateEntity);
// Initial values
this._entities = [];
this._entitiesByName = {};
this._properties = {};
this._paging = {};
this._links = {};
}
|
javascript
|
function(service, path, namespace) {
this._super(service, path, namespace);
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this._load = utils.bind(this, this._load);
this.fetch = utils.bind(this, this.fetch);
this.create = utils.bind(this, this.create);
this.list = utils.bind(this, this.list);
this.item = utils.bind(this, this.item);
this.instantiateEntity = utils.bind(this, this.instantiateEntity);
// Initial values
this._entities = [];
this._entitiesByName = {};
this._properties = {};
this._paging = {};
this._links = {};
}
|
[
"function",
"(",
"service",
",",
"path",
",",
"namespace",
")",
"{",
"this",
".",
"_super",
"(",
"service",
",",
"path",
",",
"namespace",
")",
";",
"// We perform the bindings so that every function works ",
"// properly when it is passed as a callback.",
"this",
".",
"_load",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"_load",
")",
";",
"this",
".",
"fetch",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"fetch",
")",
";",
"this",
".",
"create",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"create",
")",
";",
"this",
".",
"list",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"list",
")",
";",
"this",
".",
"item",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"item",
")",
";",
"this",
".",
"instantiateEntity",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"instantiateEntity",
")",
";",
"// Initial values",
"this",
".",
"_entities",
"=",
"[",
"]",
";",
"this",
".",
"_entitiesByName",
"=",
"{",
"}",
";",
"this",
".",
"_properties",
"=",
"{",
"}",
";",
"this",
".",
"_paging",
"=",
"{",
"}",
";",
"this",
".",
"_links",
"=",
"{",
"}",
";",
"}"
] |
Constructor for `splunkjs.Service.Collection`.
@constructor
@param {splunkjs.Service} service A `Service` instance.
@param {String} path A relative endpoint path (for example, "search/jobs").
@param {Object} namespace Namespace information:
- `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
- `app` (_string_): The app context for this resource (such as "search"). The "-" wildcard means all apps.
- `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".
@return {splunkjs.Service.Collection} A new `splunkjs.Service.Collection` instance.
@method splunkjs.Service.Collection
|
[
"Constructor",
"for",
"splunkjs",
".",
"Service",
".",
"Collection",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L3487-L3505
|
|
13,763
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(options, callback) {
if (!callback && utils.isFunction(options)) {
callback = options;
options = {};
}
callback = callback || function() {};
options = options || {};
if (!options.count) {
options.count = 0;
}
var that = this;
var req = that.get("", options, function(err, response) {
if (err) {
callback(err);
}
else {
that._load(response.data);
callback(null, that);
}
});
return req;
}
|
javascript
|
function(options, callback) {
if (!callback && utils.isFunction(options)) {
callback = options;
options = {};
}
callback = callback || function() {};
options = options || {};
if (!options.count) {
options.count = 0;
}
var that = this;
var req = that.get("", options, function(err, response) {
if (err) {
callback(err);
}
else {
that._load(response.data);
callback(null, that);
}
});
return req;
}
|
[
"function",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"callback",
"&&",
"utils",
".",
"isFunction",
"(",
"options",
")",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"options",
".",
"count",
")",
"{",
"options",
".",
"count",
"=",
"0",
";",
"}",
"var",
"that",
"=",
"this",
";",
"var",
"req",
"=",
"that",
".",
"get",
"(",
"\"\"",
",",
"options",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"that",
".",
"_load",
"(",
"response",
".",
"data",
")",
";",
"callback",
"(",
"null",
",",
"that",
")",
";",
"}",
"}",
")",
";",
"return",
"req",
";",
"}"
] |
Refreshes the resource by fetching the object from the server and
loading it.
@param {Object} options A dictionary of collection filtering and pagination options:
- `count` (_integer_): The maximum number of items to return.
- `offset` (_integer_): The offset of the first item to return.
- `search` (_string_): The search query to filter responses.
- `sort_dir` (_string_): The direction to sort returned items: “asc” or “desc”.
- `sort_key` (_string_): The field to use for sorting (optional).
- `sort_mode` (_string_): The collating sequence for sorting returned items: “auto”, “alpha”, “alpha_case”, or “num”.
@param {Function} callback A function to call when the object is retrieved: `(err, resource)`.
@method splunkjs.Service.Collection
|
[
"Refreshes",
"the",
"resource",
"by",
"fetching",
"the",
"object",
"from",
"the",
"server",
"and",
"loading",
"it",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L3603-L3627
|
|
13,764
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(id, namespace) {
if (utils.isEmpty(namespace)) {
namespace = null;
}
if (!id) {
throw new Error("Must suply a non-empty name.");
}
if (namespace && (namespace.app === '-' || namespace.owner === '-')) {
throw new Error("When searching for an entity, wildcards are not allowed in the namespace. Please refine your search.");
}
var fullPath = null;
if (this._entitiesByName.hasOwnProperty(id)) {
var entities = this._entitiesByName[id];
if (entities.length === 1 && !namespace) {
// If there is only one entity with the
// specified name and the user did not
// specify a namespace, then we just
// return it
return entities[0];
}
else if (entities.length === 1 && namespace) {
// If we specified a namespace, then we
// only return the entity if it matches
// the full path
fullPath = this.service.fullpath(entities[0].path(), namespace);
if (entities[0].qualifiedPath === fullPath) {
return entities[0];
}
else {
return null;
}
}
else if (entities.length > 1 && !namespace) {
// If there is more than one entity and we didn't
// specify a namespace, then we return an error
// saying the match is ambiguous
throw new Error("Ambiguous match for name '" + id + "'");
}
else {
// There is more than one entity, and we do have
// a namespace, so we try and find it
for(var i = 0; i < entities.length; i++) {
var entity = entities[i];
fullPath = this.service.fullpath(entities[i].path(), namespace);
if (entity.qualifiedPath === fullPath) {
return entity;
}
}
}
}
else {
return null;
}
}
|
javascript
|
function(id, namespace) {
if (utils.isEmpty(namespace)) {
namespace = null;
}
if (!id) {
throw new Error("Must suply a non-empty name.");
}
if (namespace && (namespace.app === '-' || namespace.owner === '-')) {
throw new Error("When searching for an entity, wildcards are not allowed in the namespace. Please refine your search.");
}
var fullPath = null;
if (this._entitiesByName.hasOwnProperty(id)) {
var entities = this._entitiesByName[id];
if (entities.length === 1 && !namespace) {
// If there is only one entity with the
// specified name and the user did not
// specify a namespace, then we just
// return it
return entities[0];
}
else if (entities.length === 1 && namespace) {
// If we specified a namespace, then we
// only return the entity if it matches
// the full path
fullPath = this.service.fullpath(entities[0].path(), namespace);
if (entities[0].qualifiedPath === fullPath) {
return entities[0];
}
else {
return null;
}
}
else if (entities.length > 1 && !namespace) {
// If there is more than one entity and we didn't
// specify a namespace, then we return an error
// saying the match is ambiguous
throw new Error("Ambiguous match for name '" + id + "'");
}
else {
// There is more than one entity, and we do have
// a namespace, so we try and find it
for(var i = 0; i < entities.length; i++) {
var entity = entities[i];
fullPath = this.service.fullpath(entities[i].path(), namespace);
if (entity.qualifiedPath === fullPath) {
return entity;
}
}
}
}
else {
return null;
}
}
|
[
"function",
"(",
"id",
",",
"namespace",
")",
"{",
"if",
"(",
"utils",
".",
"isEmpty",
"(",
"namespace",
")",
")",
"{",
"namespace",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"id",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Must suply a non-empty name.\"",
")",
";",
"}",
"if",
"(",
"namespace",
"&&",
"(",
"namespace",
".",
"app",
"===",
"'-'",
"||",
"namespace",
".",
"owner",
"===",
"'-'",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"When searching for an entity, wildcards are not allowed in the namespace. Please refine your search.\"",
")",
";",
"}",
"var",
"fullPath",
"=",
"null",
";",
"if",
"(",
"this",
".",
"_entitiesByName",
".",
"hasOwnProperty",
"(",
"id",
")",
")",
"{",
"var",
"entities",
"=",
"this",
".",
"_entitiesByName",
"[",
"id",
"]",
";",
"if",
"(",
"entities",
".",
"length",
"===",
"1",
"&&",
"!",
"namespace",
")",
"{",
"// If there is only one entity with the",
"// specified name and the user did not",
"// specify a namespace, then we just",
"// return it",
"return",
"entities",
"[",
"0",
"]",
";",
"}",
"else",
"if",
"(",
"entities",
".",
"length",
"===",
"1",
"&&",
"namespace",
")",
"{",
"// If we specified a namespace, then we ",
"// only return the entity if it matches",
"// the full path",
"fullPath",
"=",
"this",
".",
"service",
".",
"fullpath",
"(",
"entities",
"[",
"0",
"]",
".",
"path",
"(",
")",
",",
"namespace",
")",
";",
"if",
"(",
"entities",
"[",
"0",
"]",
".",
"qualifiedPath",
"===",
"fullPath",
")",
"{",
"return",
"entities",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"else",
"if",
"(",
"entities",
".",
"length",
">",
"1",
"&&",
"!",
"namespace",
")",
"{",
"// If there is more than one entity and we didn't",
"// specify a namespace, then we return an error",
"// saying the match is ambiguous",
"throw",
"new",
"Error",
"(",
"\"Ambiguous match for name '\"",
"+",
"id",
"+",
"\"'\"",
")",
";",
"}",
"else",
"{",
"// There is more than one entity, and we do have",
"// a namespace, so we try and find it",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"entities",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"entity",
"=",
"entities",
"[",
"i",
"]",
";",
"fullPath",
"=",
"this",
".",
"service",
".",
"fullpath",
"(",
"entities",
"[",
"i",
"]",
".",
"path",
"(",
")",
",",
"namespace",
")",
";",
"if",
"(",
"entity",
".",
"qualifiedPath",
"===",
"fullPath",
")",
"{",
"return",
"entity",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Returns a specific entity from the collection.
@example
var apps = service.apps();
apps.fetch(function(err, apps) {
var app = apps.item("search");
console.log("Search App Found: " + !!app);
// `app` is an Application object.
});
@param {String} id The name of the entity to retrieve.
@param {Object} namespace Namespace information:
- `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user. The wildcard value "-", is not acceptable when searching for an entity.
- `app` (_string_): The app context for this resource (such as "search"). The wildcard value "-" is unacceptable when searching for an entity.
- `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".
@returns {splunkjs.Service.Entity} The entity, or `null` if one is not found.
@method splunkjs.Service.Collection
|
[
"Returns",
"a",
"specific",
"entity",
"from",
"the",
"collection",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L3650-L3707
|
|
13,765
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(params, callback) {
callback = callback || function() {};
var that = this;
var req = this.post("", params, function(err, response) {
if (err) {
callback(err);
}
else {
var props = response.data.entry;
if (utils.isArray(props)) {
props = props[0];
}
var entity = that.instantiateEntity(props);
entity._load(props);
if (that.fetchOnEntityCreation) {
entity.fetch(function() {
if (req.wasAborted) {
return; // aborted, so ignore
}
else {
callback.apply(null, arguments);
}
});
}
else {
callback(null, entity);
}
}
});
return req;
}
|
javascript
|
function(params, callback) {
callback = callback || function() {};
var that = this;
var req = this.post("", params, function(err, response) {
if (err) {
callback(err);
}
else {
var props = response.data.entry;
if (utils.isArray(props)) {
props = props[0];
}
var entity = that.instantiateEntity(props);
entity._load(props);
if (that.fetchOnEntityCreation) {
entity.fetch(function() {
if (req.wasAborted) {
return; // aborted, so ignore
}
else {
callback.apply(null, arguments);
}
});
}
else {
callback(null, entity);
}
}
});
return req;
}
|
[
"function",
"(",
"params",
",",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"that",
"=",
"this",
";",
"var",
"req",
"=",
"this",
".",
"post",
"(",
"\"\"",
",",
"params",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"var",
"props",
"=",
"response",
".",
"data",
".",
"entry",
";",
"if",
"(",
"utils",
".",
"isArray",
"(",
"props",
")",
")",
"{",
"props",
"=",
"props",
"[",
"0",
"]",
";",
"}",
"var",
"entity",
"=",
"that",
".",
"instantiateEntity",
"(",
"props",
")",
";",
"entity",
".",
"_load",
"(",
"props",
")",
";",
"if",
"(",
"that",
".",
"fetchOnEntityCreation",
")",
"{",
"entity",
".",
"fetch",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"req",
".",
"wasAborted",
")",
"{",
"return",
";",
"// aborted, so ignore",
"}",
"else",
"{",
"callback",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"entity",
")",
";",
"}",
"}",
"}",
")",
";",
"return",
"req",
";",
"}"
] |
Creates an entity on the server for this collection with the specified
parameters.
@example
var apps = service.apps();
apps.create({name: "NewSearchApp"}, function(err, newApp) {
console.log("CREATED");
});
@param {Object} params A dictionary of entity-specific properties.
@param {Function} callback The function to call when the request is complete: `(err, response)`.
@returns {Array} An array of `splunkjs.Service.Entity` objects.
@method splunkjs.Service.Collection
|
[
"Creates",
"an",
"entity",
"on",
"the",
"server",
"for",
"this",
"collection",
"with",
"the",
"specified",
"parameters",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L3726-L3759
|
|
13,766
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(service, name, namespace) {
this.name = name;
this._super(service, this.path(), namespace);
this.acknowledge = utils.bind(this, this.acknowledge);
this.dispatch = utils.bind(this, this.dispatch);
this.history = utils.bind(this, this.history);
this.suppressInfo = utils.bind(this, this.suppressInfo);
}
|
javascript
|
function(service, name, namespace) {
this.name = name;
this._super(service, this.path(), namespace);
this.acknowledge = utils.bind(this, this.acknowledge);
this.dispatch = utils.bind(this, this.dispatch);
this.history = utils.bind(this, this.history);
this.suppressInfo = utils.bind(this, this.suppressInfo);
}
|
[
"function",
"(",
"service",
",",
"name",
",",
"namespace",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"_super",
"(",
"service",
",",
"this",
".",
"path",
"(",
")",
",",
"namespace",
")",
";",
"this",
".",
"acknowledge",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"acknowledge",
")",
";",
"this",
".",
"dispatch",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"dispatch",
")",
";",
"this",
".",
"history",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"history",
")",
";",
"this",
".",
"suppressInfo",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"suppressInfo",
")",
";",
"}"
] |
Constructor for `splunkjs.Service.SavedSearch`.
@constructor
@param {splunkjs.Service} service A `Service` instance.
@param {String} name The name for the new saved search.
@param {Object} namespace Namespace information:
- `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
- `app` (_string_): The app context for this resource (such as "search"). The "-" wildcard means all apps.
- `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".
@return {splunkjs.Service.SavedSearch} A new `splunkjs.Service.SavedSearch` instance.
@method splunkjs.Service.SavedSearch
|
[
"Constructor",
"for",
"splunkjs",
".",
"Service",
".",
"SavedSearch",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L3815-L3823
|
|
13,767
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(options, callback) {
if (!callback && utils.isFunction(options)) {
callback = options;
options = {};
}
callback = callback || function() {};
options = options || {};
var that = this;
var req = this.post("dispatch", options, function(err, response) {
if (err) {
callback(err);
return;
}
var sid = response.data.sid;
var job = new root.Job(that.service, sid, that.namespace);
callback(null, job, that);
});
return req;
}
|
javascript
|
function(options, callback) {
if (!callback && utils.isFunction(options)) {
callback = options;
options = {};
}
callback = callback || function() {};
options = options || {};
var that = this;
var req = this.post("dispatch", options, function(err, response) {
if (err) {
callback(err);
return;
}
var sid = response.data.sid;
var job = new root.Job(that.service, sid, that.namespace);
callback(null, job, that);
});
return req;
}
|
[
"function",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"callback",
"&&",
"utils",
".",
"isFunction",
"(",
"options",
")",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"that",
"=",
"this",
";",
"var",
"req",
"=",
"this",
".",
"post",
"(",
"\"dispatch\"",
",",
"options",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"return",
";",
"}",
"var",
"sid",
"=",
"response",
".",
"data",
".",
"sid",
";",
"var",
"job",
"=",
"new",
"root",
".",
"Job",
"(",
"that",
".",
"service",
",",
"sid",
",",
"that",
".",
"namespace",
")",
";",
"callback",
"(",
"null",
",",
"job",
",",
"that",
")",
";",
"}",
")",
";",
"return",
"req",
";",
"}"
] |
Dispatches a saved search, which creates a search job and returns a
`splunkjs.Service.Job` instance in the callback function.
@example
var savedSearch = service.savedSearches().item("MySavedSearch");
savedSearch.dispatch({force_dispatch: false}, function(err, job, savedSearch) {
console.log("Job SID: ", job.sid);
});
@param {Object} options The options for dispatching this saved search:
- `dispatch.now` (_string_): The time that is used to dispatch the search as though the specified time were the current time.
- `dispatch.*` (_string_): Overwrites the value of the search field specified in *.
- `trigger_actions` (_boolean_): Indicates whether to trigger alert actions.
- `force_dispatch` (_boolean_): Indicates whether to start a new search if another instance of this search is already running.
@param {Function} callback A function to call when the saved search is dispatched: `(err, job, savedSearch)`.
@endpoint saved/searches/{name}/dispatch
@method splunkjs.Service.SavedSearch
|
[
"Dispatches",
"a",
"saved",
"search",
"which",
"creates",
"a",
"search",
"job",
"and",
"returns",
"a",
"splunkjs",
".",
"Service",
".",
"Job",
"instance",
"in",
"the",
"callback",
"function",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L3890-L3913
|
|
13,768
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(params, callback) {
params = params || {};
if (!params.search) {
var update = this._super;
var req = this.fetch(function(err, search) {
if (err) {
callback(err);
}
else {
params.search = search.properties().search;
update.call(search, params, function() {
if (req.wasAborted) {
return; // aborted, so ignore
}
else {
callback.apply(null, arguments);
}
});
}
});
return req;
}
else {
return this._super(params, callback);
}
}
|
javascript
|
function(params, callback) {
params = params || {};
if (!params.search) {
var update = this._super;
var req = this.fetch(function(err, search) {
if (err) {
callback(err);
}
else {
params.search = search.properties().search;
update.call(search, params, function() {
if (req.wasAborted) {
return; // aborted, so ignore
}
else {
callback.apply(null, arguments);
}
});
}
});
return req;
}
else {
return this._super(params, callback);
}
}
|
[
"function",
"(",
"params",
",",
"callback",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"params",
".",
"search",
")",
"{",
"var",
"update",
"=",
"this",
".",
"_super",
";",
"var",
"req",
"=",
"this",
".",
"fetch",
"(",
"function",
"(",
"err",
",",
"search",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"params",
".",
"search",
"=",
"search",
".",
"properties",
"(",
")",
".",
"search",
";",
"update",
".",
"call",
"(",
"search",
",",
"params",
",",
"function",
"(",
")",
"{",
"if",
"(",
"req",
".",
"wasAborted",
")",
"{",
"return",
";",
"// aborted, so ignore",
"}",
"else",
"{",
"callback",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
")",
";",
"return",
"req",
";",
"}",
"else",
"{",
"return",
"this",
".",
"_super",
"(",
"params",
",",
"callback",
")",
";",
"}",
"}"
] |
Updates the saved search on the server.
**Note:** The search query is required, even when it isn't being modified.
If you don't provide it, this method will fetch the search string from
the server or from the local cache.
@param {Object} props The properties to update the saved search with. For a list of available parameters, see <a href="http://dev.splunk.com/view/SP-CAAAEFA#savedsearchparams" target="_blank">Saved search parameters</a> on Splunk Developer Portal.
@param {Function} callback A function to call when the object is updated: `(err, entity)`.
@method splunkjs.Service.SavedSearch
|
[
"Updates",
"the",
"saved",
"search",
"on",
"the",
"server",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L4010-L4037
|
|
13,769
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(props) {
var entityNamespace = utils.namespaceFromProperties(props);
return new root.SavedSearch(this.service, props.name, entityNamespace);
}
|
javascript
|
function(props) {
var entityNamespace = utils.namespaceFromProperties(props);
return new root.SavedSearch(this.service, props.name, entityNamespace);
}
|
[
"function",
"(",
"props",
")",
"{",
"var",
"entityNamespace",
"=",
"utils",
".",
"namespaceFromProperties",
"(",
"props",
")",
";",
"return",
"new",
"root",
".",
"SavedSearch",
"(",
"this",
".",
"service",
",",
"props",
".",
"name",
",",
"entityNamespace",
")",
";",
"}"
] |
Creates a local instance of a saved search.
@param {Object} props The properties for the new saved search. For a list of available parameters, see <a href="http://dev.splunk.com/view/SP-CAAAEFA#savedsearchparams" target="_blank">Saved search parameters</a> on Splunk Developer Portal.
@return {splunkjs.Service.SavedSearch} A new `splunkjs.Service.SavedSearch` instance.
@method splunkjs.Service.SavedSearches
|
[
"Creates",
"a",
"local",
"instance",
"of",
"a",
"saved",
"search",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L4067-L4070
|
|
13,770
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(props) {
var entityNamespace = utils.namespaceFromProperties(props);
return new root.StoragePassword(this.service, props.name, entityNamespace);
}
|
javascript
|
function(props) {
var entityNamespace = utils.namespaceFromProperties(props);
return new root.StoragePassword(this.service, props.name, entityNamespace);
}
|
[
"function",
"(",
"props",
")",
"{",
"var",
"entityNamespace",
"=",
"utils",
".",
"namespaceFromProperties",
"(",
"props",
")",
";",
"return",
"new",
"root",
".",
"StoragePassword",
"(",
"this",
".",
"service",
",",
"props",
".",
"name",
",",
"entityNamespace",
")",
";",
"}"
] |
Creates a local instance of a storage password.
@param {Object} props The properties for the new storage password. For a list of available parameters,
see <a href="http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTaccess#POST_storage.2Fpasswords" target="_blank">
POST storage/passwords</a> on Splunk Developer Portal.
@return {splunkjs.Service.SavedSearch} A new `splunkjs.Service.StoragePassword` instance.
@method splunkjs.Service.StoragePasswords
|
[
"Creates",
"a",
"local",
"instance",
"of",
"a",
"storage",
"password",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L4156-L4159
|
|
13,771
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(service, name, namespace) {
this.name = name;
this._super(service, this.path(), namespace);
this.list = utils.bind(this, this.list);
}
|
javascript
|
function(service, name, namespace) {
this.name = name;
this._super(service, this.path(), namespace);
this.list = utils.bind(this, this.list);
}
|
[
"function",
"(",
"service",
",",
"name",
",",
"namespace",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"_super",
"(",
"service",
",",
"this",
".",
"path",
"(",
")",
",",
"namespace",
")",
";",
"this",
".",
"list",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"list",
")",
";",
"}"
] |
Constructor for `splunkjs.Service.FiredAlertGroup`.
@constructor
@param {splunkjs.Service} service A `Service` instance.
@param {String} name The name for the new alert group.
@param {Object} namespace Namespace information:
- `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
- `app` (_string_): The app context for this resource (such as "search"). The "-" wildcard means all apps.
- `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".
@return {splunkjs.Service.FiredAlertGroup} A new `splunkjs.Service.FiredAlertGroup` instance.
@method splunkjs.Service.FiredAlertGroup
|
[
"Constructor",
"for",
"splunkjs",
".",
"Service",
".",
"FiredAlertGroup",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L4423-L4428
|
|
13,772
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(props) {
var entityNamespace = utils.namespaceFromProperties(props);
return new root.FiredAlertGroup(this.service, props.name, entityNamespace);
}
|
javascript
|
function(props) {
var entityNamespace = utils.namespaceFromProperties(props);
return new root.FiredAlertGroup(this.service, props.name, entityNamespace);
}
|
[
"function",
"(",
"props",
")",
"{",
"var",
"entityNamespace",
"=",
"utils",
".",
"namespaceFromProperties",
"(",
"props",
")",
";",
"return",
"new",
"root",
".",
"FiredAlertGroup",
"(",
"this",
".",
"service",
",",
"props",
".",
"name",
",",
"entityNamespace",
")",
";",
"}"
] |
Creates a local instance of an alert group.
@param {Object} props The properties for the alert group.
@return {splunkjs.Service.FiredAlertGroup} A new `splunkjs.Service.FiredAlertGroup` instance.
@method splunkjs.Service.FiredAlertGroupCollection
|
[
"Creates",
"a",
"local",
"instance",
"of",
"an",
"alert",
"group",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L4459-L4462
|
|
13,773
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(service, namespace) {
this._super(service, this.path(), namespace);
this.instantiateEntity = utils.bind(this, this.instantiateEntity);
this.remove = utils.bind(this, this.remove);
}
|
javascript
|
function(service, namespace) {
this._super(service, this.path(), namespace);
this.instantiateEntity = utils.bind(this, this.instantiateEntity);
this.remove = utils.bind(this, this.remove);
}
|
[
"function",
"(",
"service",
",",
"namespace",
")",
"{",
"this",
".",
"_super",
"(",
"service",
",",
"this",
".",
"path",
"(",
")",
",",
"namespace",
")",
";",
"this",
".",
"instantiateEntity",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"instantiateEntity",
")",
";",
"this",
".",
"remove",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"remove",
")",
";",
"}"
] |
Constructor for `splunkjs.Service.FiredAlertGroupCollection`.
@constructor
@param {splunkjs.Service} service A `Service` instance.
@param {Object} namespace Namespace information:
- `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
- `app` (_string_): The app context for this resource (such as "search"). The "-" wildcard means all apps.
- `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".
@return {splunkjs.Service.FiredAlertGroupCollection} A new `splunkjs.Service.FiredAlertGroupCollection` instance.
@method splunkjs.Service.FiredAlertGroupCollection
|
[
"Constructor",
"for",
"splunkjs",
".",
"Service",
".",
"FiredAlertGroupCollection",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L4486-L4491
|
|
13,774
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(service, name) {
this.name = name;
this._super(service, this.path(), {});
this.setupInfo = utils.bind(this, this.setupInfo);
this.updateInfo = utils.bind(this, this.updateInfo);
}
|
javascript
|
function(service, name) {
this.name = name;
this._super(service, this.path(), {});
this.setupInfo = utils.bind(this, this.setupInfo);
this.updateInfo = utils.bind(this, this.updateInfo);
}
|
[
"function",
"(",
"service",
",",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"_super",
"(",
"service",
",",
"this",
".",
"path",
"(",
")",
",",
"{",
"}",
")",
";",
"this",
".",
"setupInfo",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"setupInfo",
")",
";",
"this",
".",
"updateInfo",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"updateInfo",
")",
";",
"}"
] |
Constructor for `splunkjs.Service.Application`.
@constructor
@param {splunkjs.Service} service A `Service` instance.
@param {String} name The name of the Splunk app.
@return {splunkjs.Service.Application} A new `splunkjs.Service.Application` instance.
@method splunkjs.Service.Application
|
[
"Constructor",
"for",
"splunkjs",
".",
"Service",
".",
"Application",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L4530-L4536
|
|
13,775
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(callback) {
callback = callback || function() {};
var that = this;
return this.get("setup", {}, function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, response.data.entry.content, that);
}
});
}
|
javascript
|
function(callback) {
callback = callback || function() {};
var that = this;
return this.get("setup", {}, function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, response.data.entry.content, that);
}
});
}
|
[
"function",
"(",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"that",
"=",
"this",
";",
"return",
"this",
".",
"get",
"(",
"\"setup\"",
",",
"{",
"}",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"response",
".",
"data",
".",
"entry",
".",
"content",
",",
"that",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Retrieves the setup information for a Splunk app.
@example
var app = service.apps().item("app");
app.setup(function(err, info, search) {
console.log("SETUP INFO: ", info);
});
@param {Function} callback A function to call when setup information is retrieved: `(err, info, app)`.
@endpoint apps/local/{name}/setup
@method splunkjs.Service.Application
|
[
"Retrieves",
"the",
"setup",
"information",
"for",
"a",
"Splunk",
"app",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L4553-L4565
|
|
13,776
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(props) {
var entityNamespace = utils.namespaceFromProperties(props);
return new root.View(this.service, props.name, entityNamespace);
}
|
javascript
|
function(props) {
var entityNamespace = utils.namespaceFromProperties(props);
return new root.View(this.service, props.name, entityNamespace);
}
|
[
"function",
"(",
"props",
")",
"{",
"var",
"entityNamespace",
"=",
"utils",
".",
"namespaceFromProperties",
"(",
"props",
")",
";",
"return",
"new",
"root",
".",
"View",
"(",
"this",
".",
"service",
",",
"props",
".",
"name",
",",
"entityNamespace",
")",
";",
"}"
] |
Creates a local instance of a view.
@param {Object} props The properties for the new view. For a list of available parameters, see the <a href="http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#POST_scheduled.2Fviews.2F.7Bname.7D" target="_blank">POST scheduled/views/{name}</a> endpoint in the REST API documentation.
@return {splunkjs.Service.View} A new `splunkjs.Service.View` instance.
@method splunkjs.Service.Views
|
[
"Creates",
"a",
"local",
"instance",
"of",
"a",
"view",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L4870-L4873
|
|
13,777
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(service, name, namespace) {
this.name = name;
this._super(service, this.path(), namespace);
this.submitEvent = utils.bind(this, this.submitEvent);
}
|
javascript
|
function(service, name, namespace) {
this.name = name;
this._super(service, this.path(), namespace);
this.submitEvent = utils.bind(this, this.submitEvent);
}
|
[
"function",
"(",
"service",
",",
"name",
",",
"namespace",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"_super",
"(",
"service",
",",
"this",
".",
"path",
"(",
")",
",",
"namespace",
")",
";",
"this",
".",
"submitEvent",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"submitEvent",
")",
";",
"}"
] |
Constructor for `splunkjs.Service.Index`.
@constructor
@param {splunkjs.Service} service A `Service` instance.
@param {String} name The name of the index.
@param {Object} namespace Namespace information:
- `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
- `app` (_string_): The app context for this resource (such as "search"). The "-" wildcard means all apps.
- `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".
@return {splunkjs.Service.Index} A new `splunkjs.Service.Index` instance.
@method splunkjs.Service.Index
|
[
"Constructor",
"for",
"splunkjs",
".",
"Service",
".",
"Index",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L4924-L4929
|
|
13,778
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(event, params, callback) {
if (!callback && utils.isFunction(params)) {
callback = params;
params = {};
}
callback = callback || function() {};
params = params || {};
// Add the index name
params["index"] = this.name;
var that = this;
return this.service.log(event, params, function(err, result) {
callback(err, result, that);
});
}
|
javascript
|
function(event, params, callback) {
if (!callback && utils.isFunction(params)) {
callback = params;
params = {};
}
callback = callback || function() {};
params = params || {};
// Add the index name
params["index"] = this.name;
var that = this;
return this.service.log(event, params, function(err, result) {
callback(err, result, that);
});
}
|
[
"function",
"(",
"event",
",",
"params",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"callback",
"&&",
"utils",
".",
"isFunction",
"(",
"params",
")",
")",
"{",
"callback",
"=",
"params",
";",
"params",
"=",
"{",
"}",
";",
"}",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"// Add the index name",
"params",
"[",
"\"index\"",
"]",
"=",
"this",
".",
"name",
";",
"var",
"that",
"=",
"this",
";",
"return",
"this",
".",
"service",
".",
"log",
"(",
"event",
",",
"params",
",",
"function",
"(",
"err",
",",
"result",
")",
"{",
"callback",
"(",
"err",
",",
"result",
",",
"that",
")",
";",
"}",
")",
";",
"}"
] |
Submits an event to this index.
@example
var index = service.indexes().item("_internal");
index.submitEvent("A new event", {sourcetype: "mysourcetype"}, function(err, result, index) {
console.log("Submitted event: ", result);
});
@param {String} event The text for this event.
@param {Object} params A dictionary of parameters for indexing:
- `host` (_string_): The value to populate in the host field for events from this data input.
- `host_regex` (_string_): A regular expression used to extract the host value from each event.
- `source` (_string_): The source value to fill in the metadata for this input's events.
- `sourcetype` (_string_): The sourcetype to apply to events from this input.
@param {Function} callback A function to call when the event is submitted: `(err, result, index)`.
@endpoint receivers/simple?index={name}
@method splunkjs.Service.Index
|
[
"Submits",
"an",
"event",
"to",
"this",
"index",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L4952-L4968
|
|
13,779
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(props) {
var entityNamespace = utils.namespaceFromProperties(props);
return new root.Index(this.service, props.name, entityNamespace);
}
|
javascript
|
function(props) {
var entityNamespace = utils.namespaceFromProperties(props);
return new root.Index(this.service, props.name, entityNamespace);
}
|
[
"function",
"(",
"props",
")",
"{",
"var",
"entityNamespace",
"=",
"utils",
".",
"namespaceFromProperties",
"(",
"props",
")",
";",
"return",
"new",
"root",
".",
"Index",
"(",
"this",
".",
"service",
",",
"props",
".",
"name",
",",
"entityNamespace",
")",
";",
"}"
] |
Creates a local instance of an index.
@param {Object} props The properties for the new index. For a list of available parameters, see <a href="http://dev.splunk.com/view/SP-CAAAEJ3#indexparams" target="_blank">Index parameters</a> on Splunk Developer Portal.
@return {splunkjs.Service.Index} A new `splunkjs.Service.Index` instance.
@method splunkjs.Service.Indexes
|
[
"Creates",
"a",
"local",
"instance",
"of",
"an",
"index",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L5006-L5009
|
|
13,780
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(name, params, callback) {
// If someone called us with the default style of (params, callback),
// lets make it work
if (utils.isObject(name) && utils.isFunction(params) && !callback) {
callback = params;
params = name;
name = params.name;
}
params = params || {};
params["name"] = name;
return this._super(params, callback);
}
|
javascript
|
function(name, params, callback) {
// If someone called us with the default style of (params, callback),
// lets make it work
if (utils.isObject(name) && utils.isFunction(params) && !callback) {
callback = params;
params = name;
name = params.name;
}
params = params || {};
params["name"] = name;
return this._super(params, callback);
}
|
[
"function",
"(",
"name",
",",
"params",
",",
"callback",
")",
"{",
"// If someone called us with the default style of (params, callback),",
"// lets make it work",
"if",
"(",
"utils",
".",
"isObject",
"(",
"name",
")",
"&&",
"utils",
".",
"isFunction",
"(",
"params",
")",
"&&",
"!",
"callback",
")",
"{",
"callback",
"=",
"params",
";",
"params",
"=",
"name",
";",
"name",
"=",
"params",
".",
"name",
";",
"}",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"params",
"[",
"\"name\"",
"]",
"=",
"name",
";",
"return",
"this",
".",
"_super",
"(",
"params",
",",
"callback",
")",
";",
"}"
] |
Creates an index with the given name and parameters.
@example
var indexes = service.indexes();
indexes.create("NewIndex", {assureUTF8: true}, function(err, newIndex) {
console.log("CREATED");
});
@param {String} name A name for this index.
@param {Object} params A dictionary of properties. For a list of available parameters, see <a href="http://dev.splunk.com/view/SP-CAAAEJ3#indexparams" target="_blank">Index parameters</a> on Splunk Developer Portal.
@param {Function} callback A function to call with the new index: `(err, createdIndex)`.
@endpoint data/indexes
@method splunkjs.Service.Indexes
|
[
"Creates",
"an",
"index",
"with",
"the",
"given",
"name",
"and",
"parameters",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L5045-L5058
|
|
13,781
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(service, file, name, namespace) {
this.name = name;
this.file = file;
this._super(service, this.path(), namespace);
}
|
javascript
|
function(service, file, name, namespace) {
this.name = name;
this.file = file;
this._super(service, this.path(), namespace);
}
|
[
"function",
"(",
"service",
",",
"file",
",",
"name",
",",
"namespace",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"file",
"=",
"file",
";",
"this",
".",
"_super",
"(",
"service",
",",
"this",
".",
"path",
"(",
")",
",",
"namespace",
")",
";",
"}"
] |
Constructor for `splunkjs.Service.ConfigurationStanza`.
@constructor
@param {splunkjs.Service} service A `Service` instance.
@param {String} file The name of the configuration file.
@param {String} name The name of the new stanza.
@param {Object} namespace Namespace information:
- `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
- `app` (_string_): The app context for this resource (such as "search"). The "-" wildcard means all apps.
- `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".
@return {splunkjs.Service.ConfigurationStanza} A new `splunkjs.Service.ConfigurationStanza` instance.
@method splunkjs.Service.ConfigurationStanza
|
[
"Constructor",
"for",
"splunkjs",
".",
"Service",
".",
"ConfigurationStanza",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L5095-L5099
|
|
13,782
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(props) {
var entityNamespace = utils.namespaceFromProperties(props);
return new root.ConfigurationStanza(this.service, this.name, props.name, entityNamespace);
}
|
javascript
|
function(props) {
var entityNamespace = utils.namespaceFromProperties(props);
return new root.ConfigurationStanza(this.service, this.name, props.name, entityNamespace);
}
|
[
"function",
"(",
"props",
")",
"{",
"var",
"entityNamespace",
"=",
"utils",
".",
"namespaceFromProperties",
"(",
"props",
")",
";",
"return",
"new",
"root",
".",
"ConfigurationStanza",
"(",
"this",
".",
"service",
",",
"this",
".",
"name",
",",
"props",
".",
"name",
",",
"entityNamespace",
")",
";",
"}"
] |
Creates a local instance of a stanza in a configuration file.
@param {Object} props The key-value properties for the new stanza.
@return {splunkjs.Service.ConfigurationStanza} A new `splunkjs.Service.ConfigurationStanza` instance.
@method splunkjs.Service.ConfigurationFile
|
[
"Creates",
"a",
"local",
"instance",
"of",
"a",
"stanza",
"in",
"a",
"configuration",
"file",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L5143-L5146
|
|
13,783
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(stanzaName, values, callback) {
// If someone called us with the default style of (params, callback),
// lets make it work
if (utils.isObject(stanzaName) && utils.isFunction(values) && !callback) {
callback = values;
values = stanzaName;
stanzaName = values.name;
}
if (utils.isFunction(values) && !callback) {
callback = values;
values = {};
}
values = values || {};
values["name"] = stanzaName;
return this._super(values, callback);
}
|
javascript
|
function(stanzaName, values, callback) {
// If someone called us with the default style of (params, callback),
// lets make it work
if (utils.isObject(stanzaName) && utils.isFunction(values) && !callback) {
callback = values;
values = stanzaName;
stanzaName = values.name;
}
if (utils.isFunction(values) && !callback) {
callback = values;
values = {};
}
values = values || {};
values["name"] = stanzaName;
return this._super(values, callback);
}
|
[
"function",
"(",
"stanzaName",
",",
"values",
",",
"callback",
")",
"{",
"// If someone called us with the default style of (params, callback),",
"// lets make it work",
"if",
"(",
"utils",
".",
"isObject",
"(",
"stanzaName",
")",
"&&",
"utils",
".",
"isFunction",
"(",
"values",
")",
"&&",
"!",
"callback",
")",
"{",
"callback",
"=",
"values",
";",
"values",
"=",
"stanzaName",
";",
"stanzaName",
"=",
"values",
".",
"name",
";",
"}",
"if",
"(",
"utils",
".",
"isFunction",
"(",
"values",
")",
"&&",
"!",
"callback",
")",
"{",
"callback",
"=",
"values",
";",
"values",
"=",
"{",
"}",
";",
"}",
"values",
"=",
"values",
"||",
"{",
"}",
";",
"values",
"[",
"\"name\"",
"]",
"=",
"stanzaName",
";",
"return",
"this",
".",
"_super",
"(",
"values",
",",
"callback",
")",
";",
"}"
] |
Creates a stanza in this configuration file.
@example
var file = service.configurations().item("props");
file.create("my_stanza", function(err, newStanza) {
console.log("CREATED");
});
@param {String} stanzaName A name for this stanza.
@param {Object} values A dictionary of key-value pairs to put in this stanza.
@param {Function} callback A function to call with the created stanza: `(err, createdStanza)`.
@endpoint configs/conf-{file}
@method splunkjs.Service.ConfigurationFile
|
[
"Creates",
"a",
"stanza",
"in",
"this",
"configuration",
"file",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L5184-L5202
|
|
13,784
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(service, namespace) {
if (!namespace || namespace.owner === "-" || namespace.app === "-") {
throw new Error("Configurations requires a non-wildcard owner/app");
}
this._super(service, this.path(), namespace);
}
|
javascript
|
function(service, namespace) {
if (!namespace || namespace.owner === "-" || namespace.app === "-") {
throw new Error("Configurations requires a non-wildcard owner/app");
}
this._super(service, this.path(), namespace);
}
|
[
"function",
"(",
"service",
",",
"namespace",
")",
"{",
"if",
"(",
"!",
"namespace",
"||",
"namespace",
".",
"owner",
"===",
"\"-\"",
"||",
"namespace",
".",
"app",
"===",
"\"-\"",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Configurations requires a non-wildcard owner/app\"",
")",
";",
"}",
"this",
".",
"_super",
"(",
"service",
",",
"this",
".",
"path",
"(",
")",
",",
"namespace",
")",
";",
"}"
] |
Constructor for `splunkjs.Service.Configurations`.
@constructor
@param {splunkjs.Service} service A `Service` instance.
@param {Object} namespace Namespace information:
- `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
- `app` (_string_): The app context for this resource (such as "search"). The "-" wildcard means all apps.
- `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".
@return {splunkjs.Service.Configurations} A new `splunkjs.Service.Configurations` instance.
@method splunkjs.Service.Configurations
|
[
"Constructor",
"for",
"splunkjs",
".",
"Service",
".",
"Configurations",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L5257-L5263
|
|
13,785
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(filename, callback) {
// If someone called us with the default style of (params, callback),
// lets make it work
if (utils.isObject(filename)) {
filename = filename["__conf"];
}
callback = callback || function() {};
var that = this;
var req = this.post("", {__conf: filename}, function(err, response) {
if (err) {
callback(err);
}
else {
var entity = new root.ConfigurationFile(that.service, filename);
entity.fetch(function() {
if (req.wasAborted) {
return; // aborted, so ignore
}
else {
callback.apply(null, arguments);
}
});
}
});
return req;
}
|
javascript
|
function(filename, callback) {
// If someone called us with the default style of (params, callback),
// lets make it work
if (utils.isObject(filename)) {
filename = filename["__conf"];
}
callback = callback || function() {};
var that = this;
var req = this.post("", {__conf: filename}, function(err, response) {
if (err) {
callback(err);
}
else {
var entity = new root.ConfigurationFile(that.service, filename);
entity.fetch(function() {
if (req.wasAborted) {
return; // aborted, so ignore
}
else {
callback.apply(null, arguments);
}
});
}
});
return req;
}
|
[
"function",
"(",
"filename",
",",
"callback",
")",
"{",
"// If someone called us with the default style of (params, callback),",
"// lets make it work",
"if",
"(",
"utils",
".",
"isObject",
"(",
"filename",
")",
")",
"{",
"filename",
"=",
"filename",
"[",
"\"__conf\"",
"]",
";",
"}",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"that",
"=",
"this",
";",
"var",
"req",
"=",
"this",
".",
"post",
"(",
"\"\"",
",",
"{",
"__conf",
":",
"filename",
"}",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"var",
"entity",
"=",
"new",
"root",
".",
"ConfigurationFile",
"(",
"that",
".",
"service",
",",
"filename",
")",
";",
"entity",
".",
"fetch",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"req",
".",
"wasAborted",
")",
"{",
"return",
";",
"// aborted, so ignore",
"}",
"else",
"{",
"callback",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
")",
";",
"return",
"req",
";",
"}"
] |
Creates a configuration file.
@example
var configurations = service.configurations();
configurations.create("myprops", function(err, newFile) {
console.log("CREATED");
});
@param {String} filename A name for this configuration file.
@param {Function} callback A function to call with the new configuration file: `(err, createdFile)`.
@endpoint properties
@method splunkjs.Service.Configurations
|
[
"Creates",
"a",
"configuration",
"file",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L5281-L5309
|
|
13,786
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(service, sid, namespace) {
this.name = sid;
this._super(service, this.path(), namespace);
this.sid = sid;
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this.cancel = utils.bind(this, this.cancel);
this.disablePreview = utils.bind(this, this.disablePreview);
this.enablePreview = utils.bind(this, this.enablePreview);
this.events = utils.bind(this, this.events);
this.finalize = utils.bind(this, this.finalize);
this.pause = utils.bind(this, this.pause);
this.preview = utils.bind(this, this.preview);
this.results = utils.bind(this, this.results);
this.searchlog = utils.bind(this, this.searchlog);
this.setPriority = utils.bind(this, this.setPriority);
this.setTTL = utils.bind(this, this.setTTL);
this.summary = utils.bind(this, this.summary);
this.timeline = utils.bind(this, this.timeline);
this.touch = utils.bind(this, this.touch);
this.unpause = utils.bind(this, this.unpause);
}
|
javascript
|
function(service, sid, namespace) {
this.name = sid;
this._super(service, this.path(), namespace);
this.sid = sid;
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this.cancel = utils.bind(this, this.cancel);
this.disablePreview = utils.bind(this, this.disablePreview);
this.enablePreview = utils.bind(this, this.enablePreview);
this.events = utils.bind(this, this.events);
this.finalize = utils.bind(this, this.finalize);
this.pause = utils.bind(this, this.pause);
this.preview = utils.bind(this, this.preview);
this.results = utils.bind(this, this.results);
this.searchlog = utils.bind(this, this.searchlog);
this.setPriority = utils.bind(this, this.setPriority);
this.setTTL = utils.bind(this, this.setTTL);
this.summary = utils.bind(this, this.summary);
this.timeline = utils.bind(this, this.timeline);
this.touch = utils.bind(this, this.touch);
this.unpause = utils.bind(this, this.unpause);
}
|
[
"function",
"(",
"service",
",",
"sid",
",",
"namespace",
")",
"{",
"this",
".",
"name",
"=",
"sid",
";",
"this",
".",
"_super",
"(",
"service",
",",
"this",
".",
"path",
"(",
")",
",",
"namespace",
")",
";",
"this",
".",
"sid",
"=",
"sid",
";",
"// We perform the bindings so that every function works ",
"// properly when it is passed as a callback.",
"this",
".",
"cancel",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"cancel",
")",
";",
"this",
".",
"disablePreview",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"disablePreview",
")",
";",
"this",
".",
"enablePreview",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"enablePreview",
")",
";",
"this",
".",
"events",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"events",
")",
";",
"this",
".",
"finalize",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"finalize",
")",
";",
"this",
".",
"pause",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"pause",
")",
";",
"this",
".",
"preview",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"preview",
")",
";",
"this",
".",
"results",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"results",
")",
";",
"this",
".",
"searchlog",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"searchlog",
")",
";",
"this",
".",
"setPriority",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"setPriority",
")",
";",
"this",
".",
"setTTL",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"setTTL",
")",
";",
"this",
".",
"summary",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"summary",
")",
";",
"this",
".",
"timeline",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"timeline",
")",
";",
"this",
".",
"touch",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"touch",
")",
";",
"this",
".",
"unpause",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"unpause",
")",
";",
"}"
] |
Constructor for `splunkjs.Service.Job`.
@constructor
@param {splunkjs.Service} service A `Service` instance.
@param {String} sid The search ID for this search job.
@param {Object} namespace Namespace information:
- `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
- `app` (_string_): The app context for this resource (such as "search"). The "-" wildcard means all apps.
- `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".
@return {splunkjs.Service.Job} A new `splunkjs.Service.Job` instance.
@method splunkjs.Service.Job
|
[
"Constructor",
"for",
"splunkjs",
".",
"Service",
".",
"Job",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L5344-L5366
|
|
13,787
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(callback) {
callback = callback || function() {};
var that = this;
var req = this.post("control", {action: "enablepreview"}, function(err) {
callback(err, that);
});
return req;
}
|
javascript
|
function(callback) {
callback = callback || function() {};
var that = this;
var req = this.post("control", {action: "enablepreview"}, function(err) {
callback(err, that);
});
return req;
}
|
[
"function",
"(",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"that",
"=",
"this",
";",
"var",
"req",
"=",
"this",
".",
"post",
"(",
"\"control\"",
",",
"{",
"action",
":",
"\"enablepreview\"",
"}",
",",
"function",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
",",
"that",
")",
";",
"}",
")",
";",
"return",
"req",
";",
"}"
] |
Enables preview generation for a search job.
@example
var job = service.jobs().item("mysid");
job.disablePreview(function(err, job) {
console.log("PREVIEW ENABLED");
});
@param {Function} callback A function to call with this search job: `(err, job)`.
@endpoint search/jobs/{search_id}/control
@method splunkjs.Service.Job
|
[
"Enables",
"preview",
"generation",
"for",
"a",
"search",
"job",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L5430-L5439
|
|
13,788
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(params, callback) {
callback = callback || function() {};
params = params || {};
params.output_mode = params.output_mode || "json_rows";
var that = this;
return this.get("events", params, function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, response.data, that);
}
});
}
|
javascript
|
function(params, callback) {
callback = callback || function() {};
params = params || {};
params.output_mode = params.output_mode || "json_rows";
var that = this;
return this.get("events", params, function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, response.data, that);
}
});
}
|
[
"function",
"(",
"params",
",",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"params",
".",
"output_mode",
"=",
"params",
".",
"output_mode",
"||",
"\"json_rows\"",
";",
"var",
"that",
"=",
"this",
";",
"return",
"this",
".",
"get",
"(",
"\"events\"",
",",
"params",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"response",
".",
"data",
",",
"that",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Returns the events of a search job with given parameters.
@example
var job = service.jobs().item("mysid");
job.events({count: 10}, function(err, events, job) {
console.log("Fields: ", events.fields);
});
@param {Object} params The parameters for retrieving events. For a list of available parameters, see the <a href="http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#GET_search.2Fjobs.2F.7Bsearch_id.7D.2Fevents" target="_blank">GET search/jobs/{search_id}/events</a> endpoint in the REST API documentation.
@param {Function} callback A function to call when the events are retrieved: `(err, events, job)`.
@endpoint search/jobs/{search_id}/events
@method splunkjs.Service.Job
|
[
"Returns",
"the",
"events",
"of",
"a",
"search",
"job",
"with",
"given",
"parameters",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L5457-L5471
|
|
13,789
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(value, callback) {
callback = callback || function() {};
var that = this;
var req = this.post("control", {action: "setpriority", priority: value}, function(err) {
callback(err, that);
});
return req;
}
|
javascript
|
function(value, callback) {
callback = callback || function() {};
var that = this;
var req = this.post("control", {action: "setpriority", priority: value}, function(err) {
callback(err, that);
});
return req;
}
|
[
"function",
"(",
"value",
",",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"that",
"=",
"this",
";",
"var",
"req",
"=",
"this",
".",
"post",
"(",
"\"control\"",
",",
"{",
"action",
":",
"\"setpriority\"",
",",
"priority",
":",
"value",
"}",
",",
"function",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
",",
"that",
")",
";",
"}",
")",
";",
"return",
"req",
";",
"}"
] |
Sets the priority for this search job.
@example
var job = service.jobs().item("mysid");
job.setPriority(6, function(err, job) {
console.log("JOB PRIORITY SET");
});
@param {Number} value The priority (an integer between 1-10). A higher value means a higher priority.
@param {Function} callback A function to call with the search job: `(err, job)`.
@endpoint search/jobs/{search_id}/control
@method splunkjs.Service.Job
|
[
"Sets",
"the",
"priority",
"for",
"this",
"search",
"job",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L5654-L5663
|
|
13,790
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(options, callbacks) {
var period = options.period || 500; // ms
if (utils.isFunction(callbacks)) {
callbacks = {
done: callbacks
};
}
var noCallbacksAfterReady = (
!callbacks.progress &&
!callbacks.done &&
!callbacks.failed &&
!callbacks.error
);
callbacks.ready = callbacks.ready || function() {};
callbacks.progress = callbacks.progress || function() {};
callbacks.done = callbacks.done || function() {};
callbacks.failed = callbacks.failed || function() {};
callbacks.error = callbacks.error || function() {};
// For use by tests only
callbacks._preready = callbacks._preready || function() {};
callbacks._stoppedAfterReady = callbacks._stoppedAfterReady || function() {};
var that = this;
var emittedReady = false;
var doneLooping = false;
Async.whilst(
function() { return !doneLooping; },
function(nextIteration) {
that.fetch(function(err, job) {
if (err) {
nextIteration(err);
return;
}
var dispatchState = job.properties().dispatchState;
var notReady = dispatchState === "QUEUED" || dispatchState === "PARSING";
if (notReady) {
callbacks._preready(job);
}
else {
if (!emittedReady) {
callbacks.ready(job);
emittedReady = true;
// Optimization: Don't keep polling the job if the
// caller only cares about the `ready` event.
if (noCallbacksAfterReady) {
callbacks._stoppedAfterReady(job);
doneLooping = true;
nextIteration();
return;
}
}
callbacks.progress(job);
var props = job.properties();
if (dispatchState === "DONE" && props.isDone) {
callbacks.done(job);
doneLooping = true;
nextIteration();
return;
}
else if (dispatchState === "FAILED" && props.isFailed) {
callbacks.failed(job);
doneLooping = true;
nextIteration();
return;
}
}
Async.sleep(period, nextIteration);
});
},
function(err) {
if (err) {
callbacks.error(err);
}
}
);
}
|
javascript
|
function(options, callbacks) {
var period = options.period || 500; // ms
if (utils.isFunction(callbacks)) {
callbacks = {
done: callbacks
};
}
var noCallbacksAfterReady = (
!callbacks.progress &&
!callbacks.done &&
!callbacks.failed &&
!callbacks.error
);
callbacks.ready = callbacks.ready || function() {};
callbacks.progress = callbacks.progress || function() {};
callbacks.done = callbacks.done || function() {};
callbacks.failed = callbacks.failed || function() {};
callbacks.error = callbacks.error || function() {};
// For use by tests only
callbacks._preready = callbacks._preready || function() {};
callbacks._stoppedAfterReady = callbacks._stoppedAfterReady || function() {};
var that = this;
var emittedReady = false;
var doneLooping = false;
Async.whilst(
function() { return !doneLooping; },
function(nextIteration) {
that.fetch(function(err, job) {
if (err) {
nextIteration(err);
return;
}
var dispatchState = job.properties().dispatchState;
var notReady = dispatchState === "QUEUED" || dispatchState === "PARSING";
if (notReady) {
callbacks._preready(job);
}
else {
if (!emittedReady) {
callbacks.ready(job);
emittedReady = true;
// Optimization: Don't keep polling the job if the
// caller only cares about the `ready` event.
if (noCallbacksAfterReady) {
callbacks._stoppedAfterReady(job);
doneLooping = true;
nextIteration();
return;
}
}
callbacks.progress(job);
var props = job.properties();
if (dispatchState === "DONE" && props.isDone) {
callbacks.done(job);
doneLooping = true;
nextIteration();
return;
}
else if (dispatchState === "FAILED" && props.isFailed) {
callbacks.failed(job);
doneLooping = true;
nextIteration();
return;
}
}
Async.sleep(period, nextIteration);
});
},
function(err) {
if (err) {
callbacks.error(err);
}
}
);
}
|
[
"function",
"(",
"options",
",",
"callbacks",
")",
"{",
"var",
"period",
"=",
"options",
".",
"period",
"||",
"500",
";",
"// ms",
"if",
"(",
"utils",
".",
"isFunction",
"(",
"callbacks",
")",
")",
"{",
"callbacks",
"=",
"{",
"done",
":",
"callbacks",
"}",
";",
"}",
"var",
"noCallbacksAfterReady",
"=",
"(",
"!",
"callbacks",
".",
"progress",
"&&",
"!",
"callbacks",
".",
"done",
"&&",
"!",
"callbacks",
".",
"failed",
"&&",
"!",
"callbacks",
".",
"error",
")",
";",
"callbacks",
".",
"ready",
"=",
"callbacks",
".",
"ready",
"||",
"function",
"(",
")",
"{",
"}",
";",
"callbacks",
".",
"progress",
"=",
"callbacks",
".",
"progress",
"||",
"function",
"(",
")",
"{",
"}",
";",
"callbacks",
".",
"done",
"=",
"callbacks",
".",
"done",
"||",
"function",
"(",
")",
"{",
"}",
";",
"callbacks",
".",
"failed",
"=",
"callbacks",
".",
"failed",
"||",
"function",
"(",
")",
"{",
"}",
";",
"callbacks",
".",
"error",
"=",
"callbacks",
".",
"error",
"||",
"function",
"(",
")",
"{",
"}",
";",
"// For use by tests only",
"callbacks",
".",
"_preready",
"=",
"callbacks",
".",
"_preready",
"||",
"function",
"(",
")",
"{",
"}",
";",
"callbacks",
".",
"_stoppedAfterReady",
"=",
"callbacks",
".",
"_stoppedAfterReady",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"that",
"=",
"this",
";",
"var",
"emittedReady",
"=",
"false",
";",
"var",
"doneLooping",
"=",
"false",
";",
"Async",
".",
"whilst",
"(",
"function",
"(",
")",
"{",
"return",
"!",
"doneLooping",
";",
"}",
",",
"function",
"(",
"nextIteration",
")",
"{",
"that",
".",
"fetch",
"(",
"function",
"(",
"err",
",",
"job",
")",
"{",
"if",
"(",
"err",
")",
"{",
"nextIteration",
"(",
"err",
")",
";",
"return",
";",
"}",
"var",
"dispatchState",
"=",
"job",
".",
"properties",
"(",
")",
".",
"dispatchState",
";",
"var",
"notReady",
"=",
"dispatchState",
"===",
"\"QUEUED\"",
"||",
"dispatchState",
"===",
"\"PARSING\"",
";",
"if",
"(",
"notReady",
")",
"{",
"callbacks",
".",
"_preready",
"(",
"job",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"emittedReady",
")",
"{",
"callbacks",
".",
"ready",
"(",
"job",
")",
";",
"emittedReady",
"=",
"true",
";",
"// Optimization: Don't keep polling the job if the",
"// caller only cares about the `ready` event.",
"if",
"(",
"noCallbacksAfterReady",
")",
"{",
"callbacks",
".",
"_stoppedAfterReady",
"(",
"job",
")",
";",
"doneLooping",
"=",
"true",
";",
"nextIteration",
"(",
")",
";",
"return",
";",
"}",
"}",
"callbacks",
".",
"progress",
"(",
"job",
")",
";",
"var",
"props",
"=",
"job",
".",
"properties",
"(",
")",
";",
"if",
"(",
"dispatchState",
"===",
"\"DONE\"",
"&&",
"props",
".",
"isDone",
")",
"{",
"callbacks",
".",
"done",
"(",
"job",
")",
";",
"doneLooping",
"=",
"true",
";",
"nextIteration",
"(",
")",
";",
"return",
";",
"}",
"else",
"if",
"(",
"dispatchState",
"===",
"\"FAILED\"",
"&&",
"props",
".",
"isFailed",
")",
"{",
"callbacks",
".",
"failed",
"(",
"job",
")",
";",
"doneLooping",
"=",
"true",
";",
"nextIteration",
"(",
")",
";",
"return",
";",
"}",
"}",
"Async",
".",
"sleep",
"(",
"period",
",",
"nextIteration",
")",
";",
"}",
")",
";",
"}",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callbacks",
".",
"error",
"(",
"err",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Starts polling the status of this search job, and fires callbacks
upon each status change.
@param {Object} options A dictionary of optional parameters:
- `period` (_integer_): The number of milliseconds to wait between each poll. Defaults to 500.
@param {Object|Function} callbacks A dictionary of optional callbacks:
- `ready`: A function `(job)` invoked when the job's properties first become available.
- `progress`: A function `(job)` invoked whenever new job properties are available.
- `done`: A function `(job)` invoked if the job completes successfully. No further polling is done.
- `failed`: A function `(job)` invoked if the job fails executing on the server. No further polling is done.
- `error`: A function `(err)` invoked if an error occurs while polling. No further polling is done.
Or, if a function `(job)`, equivalent to passing it as a `done` callback.
@method splunkjs.Service.Job
|
[
"Starts",
"polling",
"the",
"status",
"of",
"this",
"search",
"job",
"and",
"fires",
"callbacks",
"upon",
"each",
"status",
"change",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L5796-L5884
|
|
13,791
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(props) {
var sid = props.content.sid;
var entityNamespace = utils.namespaceFromProperties(props);
return new root.Job(this.service, sid, entityNamespace);
}
|
javascript
|
function(props) {
var sid = props.content.sid;
var entityNamespace = utils.namespaceFromProperties(props);
return new root.Job(this.service, sid, entityNamespace);
}
|
[
"function",
"(",
"props",
")",
"{",
"var",
"sid",
"=",
"props",
".",
"content",
".",
"sid",
";",
"var",
"entityNamespace",
"=",
"utils",
".",
"namespaceFromProperties",
"(",
"props",
")",
";",
"return",
"new",
"root",
".",
"Job",
"(",
"this",
".",
"service",
",",
"sid",
",",
"entityNamespace",
")",
";",
"}"
] |
Creates a local instance of a job.
@param {Object} props The properties for this new job. For a list of available parameters, see <a href="http://dev.splunk.com/view/SP-CAAAEFA#searchjobparams" target="_blank">Search job parameters</a> on Splunk Developer Portal.
@return {splunkjs.Service.Job} A new `splunkjs.Service.Job` instance.
@method splunkjs.Service.Jobs
|
[
"Creates",
"a",
"local",
"instance",
"of",
"a",
"job",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L5939-L5943
|
|
13,792
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(query, params, callback) {
// If someone called us with the default style of (params, callback),
// lets make it work
if (utils.isObject(query) && utils.isFunction(params) && !callback) {
callback = params;
params = query;
query = params.search;
}
callback = callback || function() {};
params = params || {};
params.search = query;
params.exec_mode = "oneshot";
if (!params.search) {
callback("Must provide a query to create a search job");
}
var outputMode = params.output_mode || "json_rows";
var path = this.qualifiedPath;
var method = "POST";
var headers = {};
var post = params;
var get = {output_mode: outputMode};
var body = null;
var req = this.service.request(
path,
method,
get,
post,
body,
headers,
function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, response.data);
}
}
);
return req;
}
|
javascript
|
function(query, params, callback) {
// If someone called us with the default style of (params, callback),
// lets make it work
if (utils.isObject(query) && utils.isFunction(params) && !callback) {
callback = params;
params = query;
query = params.search;
}
callback = callback || function() {};
params = params || {};
params.search = query;
params.exec_mode = "oneshot";
if (!params.search) {
callback("Must provide a query to create a search job");
}
var outputMode = params.output_mode || "json_rows";
var path = this.qualifiedPath;
var method = "POST";
var headers = {};
var post = params;
var get = {output_mode: outputMode};
var body = null;
var req = this.service.request(
path,
method,
get,
post,
body,
headers,
function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, response.data);
}
}
);
return req;
}
|
[
"function",
"(",
"query",
",",
"params",
",",
"callback",
")",
"{",
"// If someone called us with the default style of (params, callback),",
"// lets make it work",
"if",
"(",
"utils",
".",
"isObject",
"(",
"query",
")",
"&&",
"utils",
".",
"isFunction",
"(",
"params",
")",
"&&",
"!",
"callback",
")",
"{",
"callback",
"=",
"params",
";",
"params",
"=",
"query",
";",
"query",
"=",
"params",
".",
"search",
";",
"}",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"params",
".",
"search",
"=",
"query",
";",
"params",
".",
"exec_mode",
"=",
"\"oneshot\"",
";",
"if",
"(",
"!",
"params",
".",
"search",
")",
"{",
"callback",
"(",
"\"Must provide a query to create a search job\"",
")",
";",
"}",
"var",
"outputMode",
"=",
"params",
".",
"output_mode",
"||",
"\"json_rows\"",
";",
"var",
"path",
"=",
"this",
".",
"qualifiedPath",
";",
"var",
"method",
"=",
"\"POST\"",
";",
"var",
"headers",
"=",
"{",
"}",
";",
"var",
"post",
"=",
"params",
";",
"var",
"get",
"=",
"{",
"output_mode",
":",
"outputMode",
"}",
";",
"var",
"body",
"=",
"null",
";",
"var",
"req",
"=",
"this",
".",
"service",
".",
"request",
"(",
"path",
",",
"method",
",",
"get",
",",
"post",
",",
"body",
",",
"headers",
",",
"function",
"(",
"err",
",",
"response",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"response",
".",
"data",
")",
";",
"}",
"}",
")",
";",
"return",
"req",
";",
"}"
] |
Creates a oneshot search from a given search query and parameters.
@example
var jobs = service.jobs();
jobs.oneshotSearch("search ERROR", {id: "myjob_123"}, function(err, results) {
console.log("RESULT FIELDS": results.fields);
});
@param {String} query The search query.
@param {Object} params A dictionary of properties for the search:
- `output_mode` (_string_): Specifies the output format of the results (XML, JSON, or CSV).
- `earliest_time` (_string_): Specifies the earliest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
- `latest_time` (_string_): Specifies the latest time in the time range to search. The time string can be a UTC time (with fractional seconds), a relative time specifier (to now), or a formatted time string.
- `rf` (_string_): Specifies one or more fields to add to the search.
@param {Function} callback A function to call with the results of the search: `(err, results)`.
@endpoint search/jobs
@method splunkjs.Service.Jobs
|
[
"Creates",
"a",
"oneshot",
"search",
"from",
"a",
"given",
"search",
"query",
"and",
"parameters",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L6066-L6111
|
|
13,793
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(props) {
props = props || {};
props.owner = props.owner || "";
this.name = props.fieldName;
this.displayName = props.displayName;
this.type = props.type;
this.multivalued = props.multivalue;
this.required = props.required;
this.hidden = props.hidden;
this.editable = props.editable;
this.comment = props.comment || null;
this.fieldSearch = props.fieldSearch;
this.lineage = props.owner.split(".");
this.owner = this.lineage[this.lineage.length - 1];
}
|
javascript
|
function(props) {
props = props || {};
props.owner = props.owner || "";
this.name = props.fieldName;
this.displayName = props.displayName;
this.type = props.type;
this.multivalued = props.multivalue;
this.required = props.required;
this.hidden = props.hidden;
this.editable = props.editable;
this.comment = props.comment || null;
this.fieldSearch = props.fieldSearch;
this.lineage = props.owner.split(".");
this.owner = this.lineage[this.lineage.length - 1];
}
|
[
"function",
"(",
"props",
")",
"{",
"props",
"=",
"props",
"||",
"{",
"}",
";",
"props",
".",
"owner",
"=",
"props",
".",
"owner",
"||",
"\"\"",
";",
"this",
".",
"name",
"=",
"props",
".",
"fieldName",
";",
"this",
".",
"displayName",
"=",
"props",
".",
"displayName",
";",
"this",
".",
"type",
"=",
"props",
".",
"type",
";",
"this",
".",
"multivalued",
"=",
"props",
".",
"multivalue",
";",
"this",
".",
"required",
"=",
"props",
".",
"required",
";",
"this",
".",
"hidden",
"=",
"props",
".",
"hidden",
";",
"this",
".",
"editable",
"=",
"props",
".",
"editable",
";",
"this",
".",
"comment",
"=",
"props",
".",
"comment",
"||",
"null",
";",
"this",
".",
"fieldSearch",
"=",
"props",
".",
"fieldSearch",
";",
"this",
".",
"lineage",
"=",
"props",
".",
"owner",
".",
"split",
"(",
"\".\"",
")",
";",
"this",
".",
"owner",
"=",
"this",
".",
"lineage",
"[",
"this",
".",
"lineage",
".",
"length",
"-",
"1",
"]",
";",
"}"
] |
Constructor for a data model field.
SDK users are not expected to invoke this constructor directly.
@constructor
@param {Object} props A dictionary of properties to set:
- `fieldName` (_string_): The name of this field.
- `displayName` (_string_): A human readable name for this field.
- `type` (_string_): The type of this field, see valid types in class docs.
- `multivalue` (_boolean_): Whether this field is multivalued.
- `required` (_boolean_): Whether this field is required on events in the object
- `hidden` (_boolean_): Whether this field should be displayed in a data model UI.
- `editable` (_boolean_): Whether this field can be edited.
- `comment` (_string_): A comment for this field, or `null` if there isn't one.
- `fieldSearch` (_string_): A search query fragment for this field.
- `lineage` (_string_): The lineage of the data model object on which this field
is defined, items are delimited by a dot. This is converted into an array of
strings upon construction.
@method splunkjs.Service.DataModelField
|
[
"Constructor",
"for",
"a",
"data",
"model",
"field",
".",
"SDK",
"users",
"are",
"not",
"expected",
"to",
"invoke",
"this",
"constructor",
"directly",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L6168-L6183
|
|
13,794
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(props) {
props = props || {};
props.owner = props.owner || "";
this.query = props.search;
this.lineage = props.owner.split(".");
this.owner = this.lineage[this.lineage.length - 1];
}
|
javascript
|
function(props) {
props = props || {};
props.owner = props.owner || "";
this.query = props.search;
this.lineage = props.owner.split(".");
this.owner = this.lineage[this.lineage.length - 1];
}
|
[
"function",
"(",
"props",
")",
"{",
"props",
"=",
"props",
"||",
"{",
"}",
";",
"props",
".",
"owner",
"=",
"props",
".",
"owner",
"||",
"\"\"",
";",
"this",
".",
"query",
"=",
"props",
".",
"search",
";",
"this",
".",
"lineage",
"=",
"props",
".",
"owner",
".",
"split",
"(",
"\".\"",
")",
";",
"this",
".",
"owner",
"=",
"this",
".",
"lineage",
"[",
"this",
".",
"lineage",
".",
"length",
"-",
"1",
"]",
";",
"}"
] |
Constructor for a data model constraint.
SDK users are not expected to invoke this constructor directly.
@constructor
@param {Object} props A dictionary of properties to set:
- `search` (_string_): The Splunk search query this constraint specifies.
- `owner` (_string_): The lineage of the data model object that owns this
constraint, items are delimited by a dot. This is converted into
an array of strings upon construction.
@method splunkjs.Service.DataModelConstraint
|
[
"Constructor",
"for",
"a",
"data",
"model",
"constraint",
".",
"SDK",
"users",
"are",
"not",
"expected",
"to",
"invoke",
"this",
"constructor",
"directly",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L6288-L6295
|
|
13,795
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(props) {
props = props || {};
props.owner = props.owner || "";
this.id = props.calculationID;
this.type = props.calculationType;
this.comment = props.comment || null;
this.editable = props.editable;
this.lineage = props.owner.split(".");
this.owner = this.lineage[this.lineage.length - 1];
this.outputFields = [];
for (var i = 0; i < props.outputFields.length; i++) {
this.outputFields[props.outputFields[i].fieldName] = new root.DataModelField(props.outputFields[i]);
}
if ("Eval" === this.type || "Rex" === this.type) {
this.expression = props.expression;
}
if ("GeoIP" === this.type || "Rex" === this.type) {
this.inputField = props.inputField;
}
if ("Lookup" === this.type) {
this.lookupName = props.lookupName;
this.inputFieldMappings = props.lookupInputs[0];
}
}
|
javascript
|
function(props) {
props = props || {};
props.owner = props.owner || "";
this.id = props.calculationID;
this.type = props.calculationType;
this.comment = props.comment || null;
this.editable = props.editable;
this.lineage = props.owner.split(".");
this.owner = this.lineage[this.lineage.length - 1];
this.outputFields = [];
for (var i = 0; i < props.outputFields.length; i++) {
this.outputFields[props.outputFields[i].fieldName] = new root.DataModelField(props.outputFields[i]);
}
if ("Eval" === this.type || "Rex" === this.type) {
this.expression = props.expression;
}
if ("GeoIP" === this.type || "Rex" === this.type) {
this.inputField = props.inputField;
}
if ("Lookup" === this.type) {
this.lookupName = props.lookupName;
this.inputFieldMappings = props.lookupInputs[0];
}
}
|
[
"function",
"(",
"props",
")",
"{",
"props",
"=",
"props",
"||",
"{",
"}",
";",
"props",
".",
"owner",
"=",
"props",
".",
"owner",
"||",
"\"\"",
";",
"this",
".",
"id",
"=",
"props",
".",
"calculationID",
";",
"this",
".",
"type",
"=",
"props",
".",
"calculationType",
";",
"this",
".",
"comment",
"=",
"props",
".",
"comment",
"||",
"null",
";",
"this",
".",
"editable",
"=",
"props",
".",
"editable",
";",
"this",
".",
"lineage",
"=",
"props",
".",
"owner",
".",
"split",
"(",
"\".\"",
")",
";",
"this",
".",
"owner",
"=",
"this",
".",
"lineage",
"[",
"this",
".",
"lineage",
".",
"length",
"-",
"1",
"]",
";",
"this",
".",
"outputFields",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"props",
".",
"outputFields",
".",
"length",
";",
"i",
"++",
")",
"{",
"this",
".",
"outputFields",
"[",
"props",
".",
"outputFields",
"[",
"i",
"]",
".",
"fieldName",
"]",
"=",
"new",
"root",
".",
"DataModelField",
"(",
"props",
".",
"outputFields",
"[",
"i",
"]",
")",
";",
"}",
"if",
"(",
"\"Eval\"",
"===",
"this",
".",
"type",
"||",
"\"Rex\"",
"===",
"this",
".",
"type",
")",
"{",
"this",
".",
"expression",
"=",
"props",
".",
"expression",
";",
"}",
"if",
"(",
"\"GeoIP\"",
"===",
"this",
".",
"type",
"||",
"\"Rex\"",
"===",
"this",
".",
"type",
")",
"{",
"this",
".",
"inputField",
"=",
"props",
".",
"inputField",
";",
"}",
"if",
"(",
"\"Lookup\"",
"===",
"this",
".",
"type",
")",
"{",
"this",
".",
"lookupName",
"=",
"props",
".",
"lookupName",
";",
"this",
".",
"inputFieldMappings",
"=",
"props",
".",
"lookupInputs",
"[",
"0",
"]",
";",
"}",
"}"
] |
Constructor for a data model calculation.
SDK users are not expected to invoke this constructor directly.
@constructor
@param {Object} props A dictionary of properties to set:
- `calculationID` (_string_): The ID of this calculation.
- `calculationType` (_string_): The type of this calculation, see class docs for valid types.
- `editable` (_boolean_): Whether this calculation can be edited.
- `comment` (_string_): A comment for this calculation, or `null` if there isn't one.
- `owner` (_string_): The lineage of the data model object on which this calculation
is defined, items are delimited by a dot. This is converted into an array of
strings upon construction.
- `outputFields` (_array_): An array of the fields this calculation generates.
- `expression` (_string_): The expression to use for this calculation; exclusive to `Eval` and `Rex` calculations (optional)
- `inputField` (_string_): The field to use for calculation; exclusive to `GeoIP` and `Rex` calculations (optional)
- `lookupName` (_string_): The name of the lookup to perform; exclusive to `Lookup` calculations (optional)
- `inputFieldMappings` (_array_): One element array containing an object with the mappings from fields in the events to fields
in the lookup; exclusive to `Lookup` calculations (optional)
@method splunkjs.Service.DataModelCalculation
|
[
"Constructor",
"for",
"a",
"data",
"model",
"calculation",
".",
"SDK",
"users",
"are",
"not",
"expected",
"to",
"invoke",
"this",
"constructor",
"directly",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L6354-L6380
|
|
13,796
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(service, props) {
this.service = service;
this.search = props.search;
this.drilldownSearch = props.drilldown_search;
this.prettyQuery = this.openInSearch = props.open_in_search;
this.pivotSearch = props.pivot_search;
this.tstatsSearch = props.tstats_search || null;
this.run = utils.bind(this, this.run);
}
|
javascript
|
function(service, props) {
this.service = service;
this.search = props.search;
this.drilldownSearch = props.drilldown_search;
this.prettyQuery = this.openInSearch = props.open_in_search;
this.pivotSearch = props.pivot_search;
this.tstatsSearch = props.tstats_search || null;
this.run = utils.bind(this, this.run);
}
|
[
"function",
"(",
"service",
",",
"props",
")",
"{",
"this",
".",
"service",
"=",
"service",
";",
"this",
".",
"search",
"=",
"props",
".",
"search",
";",
"this",
".",
"drilldownSearch",
"=",
"props",
".",
"drilldown_search",
";",
"this",
".",
"prettyQuery",
"=",
"this",
".",
"openInSearch",
"=",
"props",
".",
"open_in_search",
";",
"this",
".",
"pivotSearch",
"=",
"props",
".",
"pivot_search",
";",
"this",
".",
"tstatsSearch",
"=",
"props",
".",
"tstats_search",
"||",
"null",
";",
"this",
".",
"run",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"run",
")",
";",
"}"
] |
Constructor for a pivot.
SDK users are not expected to invoke this constructor directly.
@constructor
@param {splunkjs.Service} service A `Service` instance.
@param {Object} props A dictionary of properties to set:
- `search` (_string_): The search string for running the pivot report.
- `drilldown_search` (_string_): The search for running this pivot report using drilldown.
- `open_in_search` (_string_): Equivalent to search parameter, but listed more simply.
- `pivot_search` (_string_): A pivot search command based on the named data model.
- `tstats_search` (_string_|_null_): The search for running this pivot report using tstats, null if acceleration is disabled.
@method splunkjs.Service.Pivot
|
[
"Constructor",
"for",
"a",
"pivot",
".",
"SDK",
"users",
"are",
"not",
"expected",
"to",
"invoke",
"this",
"constructor",
"directly",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L6479-L6488
|
|
13,797
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(args, callback) {
if (utils.isUndefined(callback)) {
callback = args;
args = {};
}
if (!args || Object.keys(args).length === 0) {
args = {};
}
// If tstats is undefined, use pivotSearch (try to run an accelerated search if possible)
this.service.search(this.tstatsSearch || this.pivotSearch, args, callback);
}
|
javascript
|
function(args, callback) {
if (utils.isUndefined(callback)) {
callback = args;
args = {};
}
if (!args || Object.keys(args).length === 0) {
args = {};
}
// If tstats is undefined, use pivotSearch (try to run an accelerated search if possible)
this.service.search(this.tstatsSearch || this.pivotSearch, args, callback);
}
|
[
"function",
"(",
"args",
",",
"callback",
")",
"{",
"if",
"(",
"utils",
".",
"isUndefined",
"(",
"callback",
")",
")",
"{",
"callback",
"=",
"args",
";",
"args",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"!",
"args",
"||",
"Object",
".",
"keys",
"(",
"args",
")",
".",
"length",
"===",
"0",
")",
"{",
"args",
"=",
"{",
"}",
";",
"}",
"// If tstats is undefined, use pivotSearch (try to run an accelerated search if possible)",
"this",
".",
"service",
".",
"search",
"(",
"this",
".",
"tstatsSearch",
"||",
"this",
".",
"pivotSearch",
",",
"args",
",",
"callback",
")",
";",
"}"
] |
Starts a search job running this pivot, accelerated if possible.
@param {Object} args A dictionary of properties for the search job (optional). For a list of available parameters, see <a href="http://dev.splunk.com/view/SP-CAAAEFA#searchjobparams" target="_blank">Search job parameters</a> on Splunk Developer Portal.
**Note:** This method throws an error if the `exec_mode=oneshot` parameter is passed in with the properties dictionary.
@param {Function} callback A function to call when done creating the search job: `(err, job)`.
@method splunkjs.Service.Pivot
|
[
"Starts",
"a",
"search",
"job",
"running",
"this",
"pivot",
"accelerated",
"if",
"possible",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L6498-L6509
|
|
13,798
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(dataModelObject) {
this.dataModelObject = dataModelObject;
this.columns = [];
this.rows = [];
this.filters = [];
this.cells = [];
this.accelerationNamespace = dataModelObject.dataModel.isAccelerated() ?
dataModelObject.dataModel.name : null;
this.run = utils.bind(this, this.run);
this.pivot = utils.bind(this, this.pivot);
}
|
javascript
|
function(dataModelObject) {
this.dataModelObject = dataModelObject;
this.columns = [];
this.rows = [];
this.filters = [];
this.cells = [];
this.accelerationNamespace = dataModelObject.dataModel.isAccelerated() ?
dataModelObject.dataModel.name : null;
this.run = utils.bind(this, this.run);
this.pivot = utils.bind(this, this.pivot);
}
|
[
"function",
"(",
"dataModelObject",
")",
"{",
"this",
".",
"dataModelObject",
"=",
"dataModelObject",
";",
"this",
".",
"columns",
"=",
"[",
"]",
";",
"this",
".",
"rows",
"=",
"[",
"]",
";",
"this",
".",
"filters",
"=",
"[",
"]",
";",
"this",
".",
"cells",
"=",
"[",
"]",
";",
"this",
".",
"accelerationNamespace",
"=",
"dataModelObject",
".",
"dataModel",
".",
"isAccelerated",
"(",
")",
"?",
"dataModelObject",
".",
"dataModel",
".",
"name",
":",
"null",
";",
"this",
".",
"run",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"run",
")",
";",
"this",
".",
"pivot",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"pivot",
")",
";",
"}"
] |
Constructor for a pivot specification.
@constructor
@param {splunkjs.Service.DataModel} parentDataModel The `DataModel` that owns this data model object.
@method splunkjs.Service.PivotSpecification
|
[
"Constructor",
"for",
"a",
"pivot",
"specification",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L6640-L6652
|
|
13,799
|
splunk/splunk-sdk-javascript
|
client/splunk.js
|
function(sid) {
// If a search object is passed in, get its sid
if (sid && sid instanceof Service.Job) {
sid = sid.sid;
}
if (!sid) {
throw new Error("Sid to use for acceleration must not be null.");
}
this.accelerationNamespace = "sid=" + sid;
return this;
}
|
javascript
|
function(sid) {
// If a search object is passed in, get its sid
if (sid && sid instanceof Service.Job) {
sid = sid.sid;
}
if (!sid) {
throw new Error("Sid to use for acceleration must not be null.");
}
this.accelerationNamespace = "sid=" + sid;
return this;
}
|
[
"function",
"(",
"sid",
")",
"{",
"// If a search object is passed in, get its sid",
"if",
"(",
"sid",
"&&",
"sid",
"instanceof",
"Service",
".",
"Job",
")",
"{",
"sid",
"=",
"sid",
".",
"sid",
";",
"}",
"if",
"(",
"!",
"sid",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Sid to use for acceleration must not be null.\"",
")",
";",
"}",
"this",
".",
"accelerationNamespace",
"=",
"\"sid=\"",
"+",
"sid",
";",
"return",
"this",
";",
"}"
] |
Set the acceleration cache for this pivot specification to a job,
usually generated by createLocalAccelerationJob on a DataModelObject
instance, as the acceleration cache for this pivot specification.
@param {String|splunkjs.Service.Job} sid The sid of an acceleration job,
or, a `splunkjs.Service.Job` instance.
@return {splunkjs.Service.PivotSpecification} The updated pivot specification.
@method splunkjs.Service.PivotSpecification
|
[
"Set",
"the",
"acceleration",
"cache",
"for",
"this",
"pivot",
"specification",
"to",
"a",
"job",
"usually",
"generated",
"by",
"createLocalAccelerationJob",
"on",
"a",
"DataModelObject",
"instance",
"as",
"the",
"acceleration",
"cache",
"for",
"this",
"pivot",
"specification",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.js#L6665-L6677
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.