splunk-sdk
Version:
SDK for usage with the Splunk REST API
1 lines • 864 kB
JavaScript
var a;a="splunkjs",function i(n,o,s){function a(t,e){if(!o[t]){if(!n[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(c)return c(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}r=o[t]={exports:{}},n[t][0].call(r.exports,function(e){return a(n[t][1][e]||e)},r,r.exports,i,n,o,s)}return o[t].exports}for(var c="function"==typeof require&&require,e=0;e<s.length;e++)a(s[e]);return a}({1:[function(e,t,r){!function(e){void 0!==t&&t.exports?t.exports=e():"function"==typeof define&&define.amd?define(e):this.$script=e()}(function(){function f(e,t){for(var r=0,i=e.length;r<i;++r)if(!t(e[r]))return a;return 1}function h(e,t){f(e,function(e){return t(e),1})}function u(e,t,r){function i(e){return e.call?e():m[e]}function n(){if(!--c)for(var e in m[a]=1,s&&s(),g)f(e.split("|"),i)&&!h(g[e],i)&&(g[e]=[])}e=e[p]?e:[e];var o=t&&t.call,s=o?t:r,a=o?e.join(""):t,c=e.length;return setTimeout(function(){h(e,function e(t,r){return null===t?n():(r||/^https?:\/\//.test(t)||!l||(t=-1===t.indexOf(".js")?l+t+".js":l+t),v[t]?(a&&(y[a]=1),2==v[t]?n():setTimeout(function(){e(t,!0)},0)):(v[t]=1,a&&(y[a]=1),void d(t,n)))})},0),u}function d(e,t){var r,i=o.createElement("script");i.onload=i.onerror=i[b]=function(){i[c]&&!/^c|loade/.test(i[c])||r||(i.onload=i[b]=null,r=1,v[e]=2,t())},i.async=1,i.src=n?e+(-1===e.indexOf("?")?"?":"&")+n:e,s.insertBefore(i,s.lastChild)}var l,n,o=document,s=o.getElementsByTagName("head")[0],a=!1,p="push",c="readyState",b="onreadystatechange",m={},y={},g={},v={};return u.get=d,u.order=function(r,i,n){!function e(t){t=r.shift(),r.length?u(t,e):u(t,i,n)}()},u.path=function(e){l=e},u.urlArgs=function(e){n=e},u.ready=function(e,t,r){e=e[p]?e:[e];var i=[];return h(e,function(e){m[e]||i[p](e)}),f(e,function(e){return m[e]})?t():(e=e.join("|"),g[e]=g[e]||[],g[e][p](t),r&&r(i)),u},u.done=function(e){u([null],e)},u})},{}],2:[function(n,o,s){!function(i){!function(){!function(){var e,t,r=s||this;n("dotenv").config();try{i.env=i.env||{}}catch(e){}o.exports=r={Logger:n("./lib/log").Logger,Context:n("./lib/context"),Service:n("./lib/service"),Http:n("./lib/http"),Utils:n("./lib/utils"),Paths:n("./lib/paths").Paths,Class:n("./lib/jquery.class").Class},"undefined"==typeof window?r.NodeHttp=n("./lib/platform/node/node_http").NodeHttp:(e=n("./lib/platform/client/jquery_http").JQueryHttp,t=n("./lib/platform/client/proxy_http"),r.ProxyHttp=t.ProxyHttp,r.JQueryHttp=e,r.SplunkWebHttp=t.SplunkWebHttp)}()}.call(this)}.call(this,n("_process"))},{"./lib/context":3,"./lib/http":6,"./lib/jquery.class":7,"./lib/log":8,"./lib/paths":9,"./lib/platform/client/jquery_http":10,"./lib/platform/client/proxy_http":11,"./lib/platform/node/node_http":12,"./lib/service":13,"./lib/utils":14,_process:205,dotenv:94}],3:[function(a,t,c){!function(){"use strict";var r=a("./paths").Paths,e=a("./jquery.class").Class,i=a("./http"),n=a("./utils"),o=c||this,s={5:"",4.3:"/services/json/v2",default:""};t.exports=o=e.extend({init:function(t,e){if(t instanceof i||e||(e=t,t=null),this.scheme=(e=e||{}).scheme||"https",this.host=e.host||"localhost",this.port=e.port||8089,this.username=e.username||null,this.password=e.password||null,this.owner=e.owner,this.app=e.app,this.sessionKey=e.sessionKey||"",this.authorization=e.authorization||"Splunk",this.paths=e.paths||r,this.version=e.version||"default",this.timeout=e.timeout||0,this.autologin=!0,this.instanceType="",e.hasOwnProperty("autologin")&&(this.autologin=e.autologin),!t){if("undefined"!=typeof window)throw new Error("Http instance required when creating a Context within a browser.");{let e=a("./platform/node/node_http").NodeHttp;t=new e}}this.http=t,this.http._setSplunkVersion(this.version);e=n.getWithVersion(this.version,s);this.prefix=this.scheme+"://"+this.host+":"+this.port+e,this._headers=n.bind(this,this._headers),this.fullpath=n.bind(this,this.fullpath),this.urlify=n.bind(this,this.urlify),this.get=n.bind(this,this.get),this.del=n.bind(this,this.del),this.post=n.bind(this,this.post),this.login=n.bind(this,this.login),this._shouldAutoLogin=n.bind(this,this._shouldAutoLogin),this._requestWrapper=n.bind(this,this._requestWrapper),this.getInfo=n.bind(this,this.getInfo),this.disableV2SearchApi=n.bind(this,this.disableV2SearchApi)},_headers:function(e){return e=e||{},this.sessionKey&&(e.Authorization=this.authorization+" "+this.sessionKey),e},_shouldAutoLogin:function(){return this.username&&this.password&&this.autologin},_requestWrapper:function(t){var r=this;return!this._shouldAutoLogin()||this.sessionKey?t().then(e=>e).catch(e=>{if(e&&401===e.status&&r._shouldAutoLogin())return r.sessionKey=null,r.login().then(e=>t()).catch(e=>{throw e});throw e}):this.login().then(e=>t()).catch(e=>{throw e})},fullpath:function(e,t){if(t=t||{},n.startsWith(e,"/"))return e;if(!t.app&&!this.app&&t.sharing!==o.Sharing.SYSTEM)return"/services/"+e;let r=t.owner||this.owner||"-",i=t.app||this.app||"-";return t.sharing=(t.sharing||"").toLowerCase(),t.sharing===o.Sharing.APP||t.sharing===o.Sharing.GLOBAL?r="nobody":t.sharing===o.Sharing.SYSTEM&&(r="nobody",i="system"),n.trim("/servicesNS/"+encodeURIComponent(r)+"/"+encodeURIComponent(i)+"/"+e)},urlify:function(e){return this.prefix+this.fullpath(e)},getInfo:function(e){var i=this,t=this.paths.info;return this.http.get(this.urlify(t),this._headers(),"",this.timeout,e).then(e=>{var t=!(!e.data||!e.data.generator.version),r=!(!e.data||!e.data.generator.instance_type);return t?(i.instanceType=r?e.data.generator.instance_type:"",i.version=e.data.generator.version,i.http.version=i.version,Promise.resolve(!0)):Promise.reject("No version found")})},login:function(e){var t=this,r=this.paths.login,i={username:this.username,password:this.password,cookie:"1"};return this.http.post(this.urlify(r),this._headers(),i,this.timeout,e).then(e=>{return!(!e.data||!e.data.sessionKey)?(t.sessionKey=e.data.sessionKey,t.getInfo()):Promise.reject("No session key available")})},logout:function(){this.sessionKey=null,this.http._cookieStore={}},get:function(e,t,r,i){var n=this;return i?n.http.get(n.urlify(e),n._headers(),t,n.timeout,r,!0):this._requestWrapper(function(){return n.http.get(n.urlify(e),n._headers(),t,n.timeout,r)})},del:function(e,t,r){var i=this;return this._requestWrapper(function(){return i.http.del(i.urlify(e),i._headers(),t,i.timeout,r)})},post:function(e,t,r){var i=this;return this._requestWrapper(function(){return i.http.post(i.urlify(e),i._headers(),t,i.timeout,r)})},request:function(e,t,r,i,n,o,s){var a=this;return this._requestWrapper(function(){return a.http.request(a.urlify(e),{method:t,headers:a._headers(o),query:r,post:i,body:n,timeout:a.timeout},s)})},versionCompare:function(e){let t=this.version;var r=(t="default"===t?"5.0":t).split("."),i=e.split("."),n=Math.max(r.length,i.length);for(let e=0;e<n;e++){var o=e<r.length?parseInt(r[e],10):0,s=e<i.length?parseInt(i[e],10):0;if(o<s)return-1;if(s<o)return 1}return 0},disableV2SearchApi:function(){let e;return(e="cloud"==this.instanceType.toLowerCase()?this.versionCompare("9.0.2209"):this.versionCompare("9.0.2"))<0}}),o.Sharing={USER:"user",APP:"app",GLOBAL:"global",SYSTEM:"system"}}()},{"./http":6,"./jquery.class":7,"./paths":9,"./platform/node/node_http":12,"./utils":14}],4:[function(e,t,r){var i,n,o,s,c,f;i=a,n=window[i],o=e("../../index"),s=e("../../lib/platform/client/jquery_http").JQueryHttp,c=e("../../lib/platform/client/proxy_http"),f=c.ProxyHttp,c=c.SplunkWebHttp,window[i]=o,window[i].ProxyHttp=f,window[i].JQueryHttp=s,window[i].SplunkWebHttp=c,window[i].noConflict=function(e){return window[i]=n,o},e("../../lib/entries/browser.ui.entry")},{"../../index":2,"../../lib/entries/browser.ui.entry":5,"../../lib/platform/client/jquery_http":10,"../../lib/platform/client/proxy_http":11}],5:[function(e,t,r){function i(e,t,r){if(!e)throw new Error("Must specify a path to load from.");o(e,t,r=r||function(){})}var n,o,s;n=a,o=e("../../contrib/script"),window[n]||(window[n]={}),window[n].UI||(window[n].UI={}),n=window[n].UI,s=0,n.loadTimeline=function(e,t){var r="timeline"+s++;return i(e,r,t),r},n.loadCharting=function(e,t){var r="charting"+s++;return i(e,r,t),r},n.load=function(e,t){if(!e)throw new Error("Must specify paths to load components from");t=t||function(){};var r;return o(e,"allNaN",function(){t()}),"allNaN"},n.ready=function(e,t){o.ready(e,t=t||function(){})}},{"../../contrib/script":1}],6:[function(r,i,e){!function(){"use strict";var e=r("./jquery.class").Class,o=r("./log").Logger,s=r("./utils"),t=r("cookie"),a=null,c={5:function(e){var t=e.query||{},e=e.post||{},e=t.output_mode||e.output_mode||"json";return t.output_mode=e,t},4:function(e){return e.query||{}},default:function(e){return c[5](e)},none:function(e){return e.query||{}}};i.exports=a=e.extend({init:function(){this.get=s.bind(this,this.get),this.del=s.bind(this,this.del),this.post=s.bind(this,this.post),this.request=s.bind(this,this.request),this._buildResponse=s.bind(this,this._buildResponse),this._setSplunkVersion("none"),this._cookieStore={}},_setSplunkVersion:function(e){this.version=e},_getCookieString:function(){let r="";return s.forEach(this._cookieStore,function(e,t){r=(r=r+t+"=")+e+"; "}),r},_parseCookieHeader:function(e){e=t.parse(e);let r={};return s.forEach(e,function(e,t){r.key||(r.key=t,r.value=e)}),r},get:function(e,t,r,i,n,o){return this.request(e,{method:"GET",headers:t,timeout:i,response_timeout:n,query:r},o)},post:function(e,t,r,i,n){return t["Content-Type"]="application/x-www-form-urlencoded",this.request(e,{method:"POST",headers:t,timeout:i,response_timeout:n,post:r})},del:function(e,t,r,i,n){return this.request(e,{method:"DELETE",headers:t,timeout:i,response_timeout:n,query:r})},request:function(t,e,r){var i=this,n=s.getWithVersion(this.version,c)(e),o=e.post||{},t=t+"?"+a.encode(n),n=e.body||a.encode(o),o=i._getCookieString(),o=(0!==o.length&&(e.headers.Cookie=o,delete e.headers.Authorization),{method:e.method,headers:e.headers,timeout:e.timeout,response_timeout:e.response_timeout,query:e.query,body:n});if(r)return this.makeRequestAsync(t,o);{let e=this.makeRequest(t,o);return e.then(e=>{if(e){var t=e.response.headers["set-cookie"];if(t&&s.forEach(t,function(e){e=i._parseCookieHeader(e);i._cookieStore[e.key]=e.value}),e.status<400&&"abort"!==e.status)return e;throw e}}).catch(e=>{throw e})}},makeRequest:function(e,t){throw new Error("UNDEFINED FUNCTION - OVERRIDE REQUIRED")},parseJson:function(e){throw new Error("UNDEFINED FUNCTION - OVERRIDE REQUIRED")},_buildResponse:function(e,t,r){let i={},n=null;if(t&&t.headers&&(n=s.trim(t.headers["content-type"]||t.headers["Content-Type"]||t.headers["Content-type"]||t.headers.contentType)),s.startsWith(n,"application/json")&&r)try{i=this.parseJson(r)||{}}catch(e){o.error("Error in parsing JSON:",r,e),i=r}else i=r;return i&&o.printMessages(i.messages),{response:t,status:t?t.statusCode:0,data:i,error:e}}}),a.encode=function(e){let r="";for(var i in e)if(e.hasOwnProperty(i)){r&&"&"!==r[r.length-1]&&(r+="&");let t=e[i];if(t instanceof Array)for(let e=0;e<t.length;e++)r=r+i+"="+encodeURIComponent(t[e])+"&";else if("object"==typeof t)for(var n in t)t.hasOwnProperty(n)&&(t[n],r=r+i+"="+encodeURIComponent(t[n])+"&");else r=r+i+"="+encodeURIComponent(t)}return r="&"===r[r.length-1]?r.substr(0,r.length-1):r}}()},{"./jquery.class":7,"./log":8,"./utils":14,cookie:75}],7:[function(e,t,r){!function(){var e=r||this,o=!1,s=/xyz/.test(function(){return xyz})?/\b_super\b/:/.*/;e.Class=function(){},e.Class.extend=function(e){var t,n=this.prototype,r=(o=!0,new this);for(t in o=!1,e)r[t]="function"==typeof e[t]&&"function"==typeof n[t]&&s.test(e[t])?function(r,i){return function(){var e=this._super,t=(this._super=n[r],i.apply(this,arguments));return this._super=e,t}}(t,e[t]):e[t];function i(){!o&&this.init&&this.init.apply(this,arguments)}return i.prototype=r,(i.constructor=i).extend=arguments.callee,i}}()},{}],8:[function(f,e,h){!function(c){!function(){!function(){"use strict";function t(e){s.isString(e)&&a.hasOwnProperty(e)?c.env.LOG_LEVEL=a[e]:!isNaN(parseInt(e,10))&&s.keyOf(parseInt(e,10),a)?c.env.LOG_LEVEL=e:c.env.LOG_LEVEL=a.ERROR}var e,r,i,n,o,s=f("./utils"),a={ALL:4,INFO:3,WARN:2,ERROR:1,NONE:0};c.env.LOG_LEVEL?t(c.env.LOG_LEVEL):c.env.LOG_LEVEL=a.ERROR,e=r=i=n=function(){},"undefined"!=typeof console&&(o=function(r){return function(t){try{console[r].apply(console,arguments)}catch(e){console[r](t)}}},console.log&&(e=o("log")),console.error&&(i=o("error")),console.warn&&(r=o("warn")),console.info&&(n=o("info"))),h.Logger={log:function(){c.env.LOG_LEVEL>=a.ALL&&e.apply(null,arguments)},error:function(){c.env.LOG_LEVEL>=a.ERROR&&i.apply(null,arguments)},warn:function(){c.env.LOG_LEVEL>=a.WARN&&r.apply(null,arguments)},info:function(){c.env.LOG_LEVEL>=a.INFO&&n.apply(null,arguments)},printMessages:function(e){e=e||[];for(var t=0;t<e.length;t++){var r=e[t],i=r.type,n="[SPLUNKD] "+r.text;switch(i){case"HTTP":case"FATAL":case"ERROR":this.error(n);break;case"WARN":this.warn(n);break;case"INFO":this.info(n);break;case"HTTP":this.error(n);break;default:this.info(n)}}},setLevel:function(e){t.apply(this,arguments)},levels:a}}()}.call(this)}.call(this,f("_process"))},{"./utils":14,_process:205}],9:[function(e,t,r){!function(){"use strict";(r||this).Paths={apps:"/services/apps/local",capabilities:"authorization/capabilities",configurations:"configs",dataModels:"datamodel/model",deploymentClient:"deployment/client",deploymentServers:"deployment/server",deploymentServerClasses:"deployment/serverclass",deploymentTenants:"deployment/tenants",eventTypes:"saved/eventtypes",firedAlerts:"alerts/fired_alerts",indexes:"data/indexes",info:"/services/server/info",inputs:null,jobs:"search/jobs",jobsV2:"search/v2/jobs",licenseGroups:"licenser/groups",licenseMessages:"licenser/messages",licensePools:"licenser/pools",licenseSlaves:"licenser/slaves",licenseStacks:"licenser/stacks",licenses:"licenser/licenses",loggers:"server/logger",login:"/services/auth/login",messages:"messages",passwords:"admin/passwords",parser:"search/parser",parserV2:"search/v2/parser",pivot:"datamodel/pivot",properties:"properties",roles:"authorization/roles",savedSearches:"saved/searches",settings:"server/settings",storagePasswords:"storage/passwords",users:"/services/authentication/users",typeahead:"search/typeahead",views:"data/ui/views",currentUser:"/services/authentication/current-context",submitEvent:"/services/receivers/simple"}}()},{}],10:[function(t,e,i){!function(){function s(e){for(var t,r={},i=e.split("\n"),n=0;n<i.length;n++)""!==a.trim(i[n])&&(r[(t=i[n].split(": "))[0]]=t[1]);return r}var e=t("../../http"),a=t("../../utils"),r=t("../../../package.json").version;(i||this).JQueryHttp=e.extend({init:function(e){this._super(e)},makeRequest:function(e,t){t.headers["Splunk-Client"]="splunk-sdk-javascript/"+r;var n,o=this,e={url:e,type:t.method,headers:t.headers,data:t.body||"",timeout:Math.max(t.timeout,t.response_timeout)||0,dataType:"json",success:a.bind(this,function(e,t,r){r={statusCode:r.status,headers:s(r.getAllResponseHeaders())},t=this._buildResponse(t,r,e);return Promise.resolve(t)}),error:function(e,t,r){if("timeout"===t)return n=o._buildResponse("abort",{headers:{},statusCode:"abort",body:{}},{}),Promise.reject(n);var i={statusCode:e.status,headers:s(e.getAllResponseHeaders())},t=("abort"===t&&(i.statusCode="abort",e.responseText="{}"),JSON.parse(e.responseText));return n=o._buildResponse(r,i,t),Promise.reject(n)}};return $.ajax(e).then(e=>n).catch(e=>n)},parseJson:function(e){return e}})}()},{"../../../package.json":259,"../../http":6,"../../utils":14}],11:[function(n,e,f){!function(){function s(e){for(var t,r={},i=e.split("\n"),n=0;n<i.length;n++)""!==o.trim(i[n])&&(r[(t=i[n].split(": "))[0]]=t[1]);return r}var e=n("../../http"),o=n("../../utils"),i=n("../../../package.json").version,t=f||this;function a(e){for(var i=a.options,t=i.parser[i.strictMode?"strict":"loose"].exec(e),n={},r=14;r--;)n[i.key[r]]=t[r]||"";return n[i.q.name]={},n[i.key[12]].replace(i.q.parser,function(e,t,r){t&&(n[i.q.name][t]=r)}),n}a.options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};function c(e){return(e=e||"").replace(r,"\\$&")}var r=/[.*+?|()\[\]{}\\$\^]/g;t.ProxyHttp=e.extend({init:function(e){this.prefix=e,this._super()},makeRequest:function(e,t){t.headers["X-ProxyDestination"]=e,t.headers["Splunk-Client"]="splunk-sdk-javascript/"+i;var n,r=a(e),r=(r.protocol||"")+"://"+r.authority,o=(e=e.replace(new RegExp(c(r),"i"),""),e=this.prefix+e,this),r={url:e,type:t.method,headers:t.headers,data:t.body||"",timeout:Math.max(t.timeout,t.response_timeout)||0,dataType:"text",success:function(e,t,r){r={statusCode:r.status,headers:s(r.getAllResponseHeaders())};return n=o._buildResponse(t,r,e),Promise.resolve(n)},error:function(e,t,r){if("timeout"===t)return n=o._buildResponse("abort",{headers:{},statusCode:"abort",body:{}},{}),Promise.reject(n);var i={statusCode:e.status,headers:s(e.getAllResponseHeaders())},t=("abort"===t&&(i.statusCode="abort",e.responseText="{}"),e.responseText);return n=o._buildResponse(r,i,t),Promise.reject(n)}};return $.ajax(r).then(e=>n).catch(e=>n)},makeRequestAsync:function(e,t){t.headers["X-ProxyDestination"]=e,t.headers["Splunk-Client"]="splunk-sdk-javascript/"+i;var n,r=a(e),r=(r.protocol||"")+"://"+r.authority,o=(e=e.replace(new RegExp(c(r),"i"),""),e=this.prefix+e,this),r={url:e,type:t.method,headers:t.headers,data:t.body||"",timeout:Math.max(t.timeout,t.response_timeout)||0,dataType:"text",success:function(e,t,r){r={statusCode:r.status,headers:s(r.getAllResponseHeaders()),body:JSON.parse(e)};return n=r,Promise.resolve(n)},error:function(e,t,r){if("timeout"===t)return n=o._buildResponse("abort",{headers:{},statusCode:"abort",body:{}},{}),Promise.reject(n);var i={statusCode:e.status,headers:s(e.getAllResponseHeaders())},t=("abort"===t&&(i.statusCode="abort",e.responseText="{}"),e.responseText);return n=o._buildResponse(r,i,t),Promise.reject(n)}};return $.ajax(r).then(e=>n).catch(e=>n)},parseJson:function(e){return JSON.parse(e)}}),t.SplunkWebHttp=t.ProxyHttp.extend({init:function(){this._super("/en-US/splunkd/__raw")}})}()},{"../../../package.json":259,"../../http":6,"../../utils":14}],12:[function(t,e,r){!function(a){!function(){!function(){var o=t("needle"),e=t("../../http"),s=(t("../../utils"),t("../../../package.json").version);(r||this).NodeHttp=e.extend({init:function(){this._super()},makeRequest:function(e,i){var t={url:e,method:i.method,headers:i.headers||{},body:i.body||"",timeout:i.timeout||0,jar:!1,followAllRedirects:!0,strictSSL:!1,rejectUnauthorized:!1},n=(null!=i.response_timeout&&(t.response_timeout=i.response_timeout),t.headers["Content-Length"]=a.byteLength(t.body,"utf8"),t.headers["User-Agent"]="splunk-sdk-javascript/"+s,i.query&&["xml","csv"].includes(i.query.output_mode)&&(t.parse_response=!1),this);function r(e=null,t=null){var r={headers:t?t.headers:{},statusCode:t?t.statusCode:600},t=t?t.body:{},e=i.query&&["xml","csv"].includes(i.query.output_mode)?n._buildResponse(e,r,t):n._buildResponse(e,r,JSON.stringify(t));return e}return o(t.method,t.url,t.body,t).then(e=>r(null,e)).catch(e=>{if("ECONNRESET"==e.code&&null!=t.response_timeout)throw r("abort",{headers:{},statusCode:"abort",body:{}});throw r(e,null)})},makeRequestAsync:async function(e,t){e={url:e,method:t.method,headers:t.headers||{},body:t.body||"",timeout:t.timeout||0,jar:!1,followAllRedirects:!0,strictSSL:!1,rejectUnauthorized:!1};null!=t.response_timeout&&(e.response_timeout=t.response_timeout),e.headers["Content-Length"]=a.byteLength(e.body,"utf8"),e.headers["User-Agent"]="splunk-sdk-javascript/"+s;return o(e.method,e.url,e.body,e)},parseJson:function(e){return JSON.parse(e)}})}()}.call(this)}.call(this,t("buffer").Buffer)},{"../../../package.json":259,"../../http":6,"../../utils":14,buffer:70,needle:173}],13:[function(i,o,s){!function(){"use strict";var e=i("./context"),n=(i("./http"),i("./paths").Paths),t=i("./jquery.class").Class,c=i("./utils"),a=s||this,r=null,e=e.extend({init:function(){this._super.apply(this,arguments)}});o.exports=a=r=e.extend({init:function(){this._super.apply(this,arguments),this.specialize=c.bind(this,this.specialize),this.apps=c.bind(this,this.apps),this.configurations=c.bind(this,this.configurations),this.indexes=c.bind(this,this.indexes),this.savedSearches=c.bind(this,this.savedSearches),this.jobs=c.bind(this,this.jobs),this.users=c.bind(this,this.users),this.currentUser=c.bind(this,this.currentUser),this.views=c.bind(this,this.views),this.firedAlertGroups=c.bind(this,this.firedAlertGroups),this.dataModels=c.bind(this,this.dataModels)},specialize:function(e,t){return new r(this.http,{scheme:this.scheme,host:this.host,port:this.port,username:this.username,password:this.password,owner:e,app:t,sessionKey:this.sessionKey,version:this.version})},apps:function(){return new a.Applications(this)},configurations:function(e){return new a.Configurations(this,e)},indexes:function(e){return new a.Indexes(this,e)},savedSearches:function(e){return new a.SavedSearches(this,e)},storagePasswords:function(e){return new a.StoragePasswords(this,e)},firedAlertGroups:function(e){return new a.FiredAlertGroupCollection(this,e)},jobs:function(e){return new a.Jobs(this,e)},dataModels:function(e){return new a.DataModels(this,e)},users:function(){return new a.Users(this)},views:function(e){return new a.Views(this,e)},search:function(e,t,r,i){!i&&c.isNumber(r)&&(i=r,r=null);let n=new a.Jobs(this,r);return n.search(e,t,i)},getJob:function(e,t,r){!r&&c.isNumber(r)&&(r=t,t=null);let i=new a.Job(this,e,t);return i.fetch({},r)},oneshotSearch:function(e,t,r,i){!i&&c.isNumber(i)&&(i=r,r=null);let n=new a.Jobs(this,r);return n.oneshotSearch(e,t,i)},currentUser:function(r){var i=this;return this.get(n.currentUser,{},r).then(e=>{e=e.data.entry[0].content.username;let t=new a.User(i,e);return t.fetch({},r)})},serverInfo:function(e){let t=new a.ServerInfo(this);return t.fetch({},e)},parse:function(e,t,r){return!r&&c.isNumber(t)&&(r=t,t={}),(t=t||{}).q=e,this.disableV2SearchApi()?this.get(n.parser,t,r).then(e=>e.data):this.post(n.parserV2,t,r).then(e=>e.data)},typeahead:function(e,t,r){return this.get(n.typeahead,{count:t||10,prefix:e},r).then(e=>{return(e.data||{}).results||[]})},log:function(e,t,r){!r&&c.isNumber(t)&&(r=t,t={}),t=t||{},c.isObject(e)&&(e=JSON.stringify(e));var i=this.paths.submitEvent;return this.request(i,"POST",t,{},e,{"Content-Type":"text/plain"},r).then(e=>e.data)}}),a.Endpoint=t.extend({init:function(e,t){if(!e)throw new Error("Passed in a null Service.");if(!t)throw new Error("Passed in an empty path.");this.service=e,this.qualifiedPath=t,this.get=c.bind(this,this.get),this.post=c.bind(this,this.post),this.del=c.bind(this,this.del)},createUrl:function(e,t){var r=e.replace(/(\/services|\/servicesNS\/[^/]+\/[^/]+)\/(.*)/,"$1"),i=(e.replace(/(\/services|\/servicesNS\/[^/]+\/[^/]+)\/(.*)/,"$2"),e.match(/\/(?:servicesNS\/[^/]+\/[^/]+|services)\/[^/]+\/v(\d+)\//)),i=(i=i?i.length:0,t.match(/^[^/]+\/v(\d+)\//)),i=(i=i?i.length:0)||1;return 1<=(i=-1==t.indexOf("/")?-1:i)?r+"/"+t:e+"/"+t},get:function(e,t,r,i){e=this.createUrl(this.qualifiedPath,e);return this.service.get(e,t,r,i)},post:function(e,t,r){e=this.createUrl(this.qualifiedPath,e);return this.service.post(e,t,r)},del:function(e,t,r){let i=this.qualifiedPath;return e&&(i=i+"/"+e),this.service.del(i,t,r)}}),a.Resource=a.Endpoint.extend({init:function(e,t,r){t=e.fullpath(t,r);this._super(e,t),this.namespace=r,this._properties={},this._state={},this._load=c.bind(this,this._load),this.fetch=c.bind(this,this.fetch),this.properties=c.bind(this,this.properties),this.state=c.bind(this,this.state),this.path=c.bind(this,this.path)},path:function(){throw new Error("MUST BE OVERRIDDEN")},_load:function(e){this._properties=e||{},this._state=e||{}},fetch:function(){throw new Error("MUST BE OVERRIDDEN")},properties:function(){return this._properties},state:function(){return this._state}}),a.Entity=a.Resource.extend({fetchOnUpdate:!1,init:function(e,t,r){this._super(e,t,r),this._load=c.bind(this,this._load),this.fetch=c.bind(this,this.fetch),this.remove=c.bind(this,this.remove),this.update=c.bind(this,this.update),this.fields=c.bind(this,this.fields),this.links=c.bind(this,this.links),this.acl=c.bind(this,this.acl),this.acl_update=c.bind(this,this.acl_update),this.author=c.bind(this,this.author),this.updated=c.bind(this,this.updated),this.published=c.bind(this,this.published),this.enable=c.bind(this,this.enable),this.disable=c.bind(this,this.disable),this.reload=c.bind(this,this.reload),this._properties={},this._fields={},this._acl={},this._links={}},_load:function(e){e=c.isArray(e)?e[0]:e,this._super(e=e||{content:{},fields:{},acl:{},links:{}}),this._properties=e.content||{},this._fields=e.fields||this._fields||{},this._acl=e.acl||{},this._links=e.links||{},this._author=e.author||null,this._updated=e.updated||null,this._published=e.published||null},fields:function(){return this._fields},acl:function(){return this._acl},acl_update:function(e,t){if(!e.hasOwnProperty("sharing"))throw new Error("Required argument 'sharing' is missing.");if(e.hasOwnProperty("owner"))return this.post("acl",e,t).then(e=>this.fetch({}));throw new Error("Required argument 'owner' is missing.")},links:function(){return this._links},author:function(){return this._author},updated:function(){return this._updated},published:function(){return this._published},fetch:function(e,t){c.isNumber(e)&&!t&&(t=e,e={});var r=this;return this.get("",e=e||{},t).then(e=>(r._load(e.data?e.data.entry:null),r))},remove:function(e){return this.del("",{},e)},update:function(e,t){if(e.hasOwnProperty("name"))throw new Error("Cannot set 'name' field in 'update'");var r=this;return this.post("",e,t).then(e=>r.fetchOnUpdate?r.fetch({},t):(r._load(e.data.entry),r)).catch(e=>{throw[e,r]})},disable:function(e){var t=this;return this.post("disable",{},e).then(e=>t)},enable:function(e){var t=this;return this.post("enable",{},e).then(e=>t)},reload:function(e){var t=this;return this.post("_reload",{},e).then(e=>t)}}),a.Collection=a.Resource.extend({fetchOnEntityCreation:!1,init:function(e,t,r){this._super(e,t,r),this._load=c.bind(this,this._load),this.fetch=c.bind(this,this.fetch),this.create=c.bind(this,this.create),this.createAsync=c.bind(this,this.createAsync),this.list=c.bind(this,this.list),this.item=c.bind(this,this.item),this.instantiateEntity=c.bind(this,this.instantiateEntity),this._entities=[],this._entitiesByName={},this._properties={},this._paging={},this._links={}},instantiateEntity:function(e){throw new Error("MUST BE OVERRIDDEN")},_load:function(e){this._super(e);let r=[],i={};var n=e.entry||[];for(let t=0;t<n.length;t++){var o=n[t];let e=this.instantiateEntity(o);e._load(o),r.push(e),i.hasOwnProperty(e.name)?i[e.name].push(e):i[e.name]=[e]}this._entities=r,this._entitiesByName=i,this._paging=e.paging||{},this._links=e.links||{},this._updated=e.updated||null},links:function(){return this._links},paging:function(){return this._paging},updated:function(){return this._updated},fetch:function(e,t){c.isNumber(e)&&!t&&(t=e,e={}),(e=e||{}).count||(e.count=0);var r=this;let i=r.get("",e,t);return i.then(e=>(r._load(e.data),r)).catch(e=>{throw e})},fetchAsync:async function(e,t){c.isNumber(e)&&!t&&(t=e,e={}),(e=e||{}).count||(e.count=0);e=await this.get("",e,t,!0);return this._load(e.body),this},item:function(e,r){if(c.isEmpty(r)&&(r=null),!e)throw new Error("Must suply a non-empty name.");if(r&&("-"===r.app||"-"===r.owner))throw new Error("When searching for an entity, wildcards are not allowed in the namespace. Please refine your search.");let i=null;if(!this._entitiesByName.hasOwnProperty(e))return null;{let t=this._entitiesByName[e];if(1===t.length&&!r)return t[0];if(1===t.length&&r)return i=this.service.fullpath(t[0].path(),r),t[0].qualifiedPath===i?t[0]:null;if(1<t.length&&!r)throw new Error("Ambiguous match for name '"+e+"'");for(let e=0;e<t.length;e++){var n=t[e];if(i=this.service.fullpath(t[e].path(),r),n.qualifiedPath===i)return n}}},create:function(e,i){i=i||0;var n=this;return this.post("",e,i).then(e=>{let t=e.data.entry,r=(c.isArray(t)&&(t=t[0]),n.instantiateEntity(t));return r._load(t),n.fetchOnEntityCreation?r.fetch({},i):r})},list:function(){return c.clone(this._entities)}}),a.SavedSearch=a.Entity.extend({path:function(){return n.savedSearches+"/"+encodeURIComponent(this.name)},init:function(e,t,r){this.name=t,this._super(e,this.path(),r),this.acknowledge=c.bind(this,this.acknowledge),this.dispatch=c.bind(this,this.dispatch),this.history=c.bind(this,this.history),this.suppressInfo=c.bind(this,this.suppressInfo)},alertCount:function(){return parseInt(this.properties().triggered_alert_count,10)||0},acknowledge:function(e){var t=this;return this.post("acknowledge",{},e).catch(e=>{throw[e,t]})},dispatch:function(e,t){!t&&c.isNumber(e)&&(t=e,e={});var r=this;return this.post("dispatch",e=e||{},t).then(e=>{e=e.data.sid;return[new a.Job(r.service,e,r.namespace),r]})},firedAlertGroup:function(){return new a.FiredAlertGroup(this.service,this.name)},history:function(e,t){!t&&c.isNumber(e)&&(t=e,e={});var s=this;return this.get("history",e=e||{},t).then(r=>{let i=[];var e=r.data.entry||[];for(let t=0;t<e.length;t++){var n=r.data.entry[t],o=c.namespaceFromProperties(n);let e=new a.Job(s.service,n.name,o);e._load(n),i.push(e)}return[i,s]})},suppressInfo:function(e){var t=this;return this.get("suppress",{},e).then(e=>[e.data.entry.content,t])},update:function(r,i){if(c.isNumber(r)&&!i&&(i=r,r={}),(r=r||{}).search)return this._super(r,i);{let t=this._super;return this.fetch({},i).then(e=>(r.search=e.properties().search,t.call(e,r,i)))}}}),a.SavedSearches=a.Collection.extend({path:function(){return n.savedSearches},instantiateEntity:function(e){var t=c.namespaceFromProperties(e);return new a.SavedSearch(this.service,e.name,t)},init:function(e,t){this._super(e,this.path(),t)}}),a.StoragePassword=a.Entity.extend({path:function(){return n.storagePasswords+"/"+encodeURIComponent(this.name)},init:function(e,t,r){this.name=t,this._super(e,this.path(),r)}}),a.StoragePasswords=a.Collection.extend({fetchOnEntityCreation:!0,path:function(){return n.storagePasswords},instantiateEntity:function(e){var t=c.namespaceFromProperties(e);return new a.StoragePassword(this.service,e.name,t)},init:function(e,t){this._super(e,this.path(),t)},create:function(e,t){if("-"==this.service.app||"-"==this.service.owner)throw new Error("While creating StoragePasswords, namespace cannot have wildcards.");return this._super(e,t)},createOrReplace:async function(e,t){var{name:r,realm:i}=e,e=(this.does_storage_password_exist(i,r)&&await this.del(i+":"+r+":"),await this.post("",e,t));let n=e.data.entry,o=(c.isArray(n)&&(n=n[0]),this.instantiateEntity(n)),s=(o._load(n),this.fetchOnEntityCreation&&await o.fetch(t),!1);for(;!s;)await this.fetch(t),s=this.does_storage_password_exist(i,r);return o},does_storage_password_exist:function(e,t){var r=this.list(),i=e+":"+t+":";for(let e=0;e<r.length;e++)if(r[e].name===i)return!0;return!1}}),a.FiredAlert=a.Entity.extend({path:function(){return n.firedAlerts+"/"+encodeURIComponent(this.name)},actions:function(){return this.properties().actions||[]},alertType:function(){return this.properties().alert_type||null},isDigestMode:function(){return!!this.properties().digest_mode},expirationTime:function(){return this.properties().expiration_time_rendered||null},savedSearchName:function(){return this.properties().savedsearch_name||null},severity:function(){return parseInt(this.properties().severity,10)||-1},sid:function(){return this.properties().sid||null},triggerTime:function(){return this.properties().trigger_time||null},triggerTimeRendered:function(){return this.properties().trigger_time_rendered||null},triggeredAlertCount:function(){return parseInt(this.properties().triggered_alerts,10)||-1},init:function(e,t,r){this.name=t,this._super(e,this.path(),r)}}),a.FiredAlertGroup=a.Entity.extend({path:function(){return n.firedAlerts+"/"+encodeURIComponent(this.name)},count:function(){return parseInt(this.properties().triggered_alert_count,10)||0},list:function(e,t){!t&&c.isNumber(e)&&(t=e,e={});var s=this;return this.get("",e=e||{},t).then(r=>{let i=[];var e=r.data.entry||[];for(let t=0;t<e.length;t++){var n=r.data.entry[t],o=c.namespaceFromProperties(n);let e=new a.FiredAlert(s.service,n.name,o);e._load(n),i.push(e)}return[i,s]})},init:function(e,t,r){this.name=t,this._super(e,this.path(),r),this.list=c.bind(this,this.list)}}),a.FiredAlertGroupCollection=a.Collection.extend({path:function(){return n.firedAlerts},instantiateEntity:function(e){var t=c.namespaceFromProperties(e);return new a.FiredAlertGroup(this.service,e.name,t)},remove:function(){throw new Error("To remove an alert, remove the saved search with the same name.")},init:function(e,t){this._super(e,this.path(),t),this.instantiateEntity=c.bind(this,this.instantiateEntity),this.remove=c.bind(this,this.remove)}}),a.Application=a.Entity.extend({fetchOnUpdate:!0,path:function(){return n.apps+"/"+encodeURIComponent(this.name)},init:function(e,t){this.name=t,this._super(e,this.path(),{}),this.setupInfo=c.bind(this,this.setupInfo),this.updateInfo=c.bind(this,this.updateInfo)},setupInfo:function(e){var t=this;return this.get("setup",{},e).then(e=>[e.data.entry.content,t])},updateInfo:function(e){var t=this;return this.get("update",{},e).then(e=>[e.data.entry.content,t])}}),a.Applications=a.Collection.extend({fetchOnEntityCreation:!0,path:function(){return n.apps},instantiateEntity:function(e){return new a.Application(this.service,e.name,{})},init:function(e){this._super(e,this.path(),{})}}),a.ServerInfo=a.Entity.extend({path:function(){return n.info},init:function(e){this.name="server-info",this._super(e,this.path(),{})}}),a.User=a.Entity.extend({path:function(){return n.users+"/"+encodeURIComponent(this.name)},init:function(e,t){this.name=t,this._super(e,this.path(),{})}}),a.Users=a.Collection.extend({fetchOnEntityCreation:!0,path:function(){return n.users},instantiateEntity:function(e){return new a.User(this.service,e.name,{})},init:function(e){this._super(e,this.path(),{})},create:function(i,n){c.isNumber(i)&&!n&&(n=i,i={});var o=this;return this.post("",i,n).then(e=>{var t={name:i.name};let r=o.instantiateEntity(t);return r.fetch({},n)})}}),a.View=a.Entity.extend({path:function(){return n.views+"/"+encodeURIComponent(this.name)},init:function(e,t,r){this.name=t,this._super(e,this.path(),r)}}),a.Views=a.Collection.extend({path:function(){return n.views},instantiateEntity:function(e){var t=c.namespaceFromProperties(e);return new a.View(this.service,e.name,t)},init:function(e,t){this._super(e,this.path(),t)}}),a.Index=a.Entity.extend({path:function(){return n.indexes+"/"+encodeURIComponent(this.name)},init:function(e,t,r){this.name=t,this._super(e,this.path(),r),this.submitEvent=c.bind(this,this.submitEvent)},submitEvent:function(e,t,r){!r&&c.isNumber(t)&&(r=t,t={}),(t=t||{}).index=this.name;var i=this;return this.service.log(e,t,r).then(e=>[e,i]).catch(e=>{throw[e,i]})},remove:function(e){if(this.service.versionCompare("5.0")<0)throw new Error("Indexes cannot be removed in Splunk 4.x");return this._super(e)}}),a.Indexes=a.Collection.extend({path:function(){return n.indexes},instantiateEntity:function(e){var t=c.namespaceFromProperties(e);return new a.Index(this.service,e.name,t)},init:function(e,t){this._super(e,this.path(),t)},create:function(e,t,r){return c.isObject(e)&&c.isNumber(t)&&!r&&(r=t,e=(t=e).name),(t=t||{}).name=e,this._super(t,r)}}),a.ConfigurationStanza=a.Entity.extend({path:function(){var e="default"===this.name?"_new":this.name;return n.configurations+"/conf-"+encodeURIComponent(this.file)+"/"+encodeURIComponent(e)},init:function(e,t,r,i){this.name=r,this.file=t,this._super(e,this.path(),i)}}),a.ConfigurationFile=a.Collection.extend({path:function(){return n.configurations+"/conf-"+encodeURIComponent(this.name)},getDefaultStanza:function(){return new a.ConfigurationStanza(this.service,this.name,"default",this.namespace)},instantiateEntity:function(e){var t=c.namespaceFromProperties(e);return new a.ConfigurationStanza(this.service,this.name,e.name,t)},init:function(e,t,r){this.name=t,this._super(e,this.path(),r)},create:function(e,t,r){return c.isObject(e)&&c.isNumber(t)&&!r&&(r=t,e=(t=e).name),c.isNumber(t)&&!r&&(r=t,t={}),(t=t||{}).name=e,this._super(t,r)}}),a.Configurations=a.Collection.extend({fetchOnEntityCreation:!0,path:function(){return n.properties},instantiateEntity:function(e){return new a.ConfigurationFile(this.service,e.name,this.namespace)},init:function(e,t){if(!t||"-"===t.owner||"-"===t.app)throw new Error("Configurations requires a non-wildcard owner/app");this._super(e,this.path(),t)},create:function(r,i){c.isObject(r)&&(r=r.__conf);var n=this;return this.post("",{__conf:r},i).then(e=>{let t=new a.ConfigurationFile(n.service,r);return t.fetch({},i)})},getConfFile:async function(t,e){let r=await this.get("",{__conf:t},e,!0);var i=r&&r.body&&r.body.entry&&r.body.entry.filter(e=>e.name===t);if(i&&0==i.length)return null;let n=new a.ConfigurationFile(this.service,t);return await n.fetchAsync(e)},getStanza:async function(e,t){e=e.item(t);return null==e?null:e},createAsync:async function(e,t,r,i){let n=await this.getConfFile(e),o=(null==n&&(await this.create({__conf:e},i),n=await(n=new a.ConfigurationFile(this.service,e)).fetchAsync(i)),await this.getStanza(n,t));return null==o?n.create(t,r,i):o.update(r,i)}}),a.Job=a.Entity.extend({path:function(){return this.disableV2SearchApi()?n.jobs+"/"+encodeURIComponent(this.name):n.jobsV2+"/"+encodeURIComponent(this.name)},init:function(e,t,r){this.version=e.version,this.versionCompare=e.versionCompare,this.disableV2SearchApi=e.disableV2SearchApi,this.name=t,this._super(e,this.path(),r),this.sid=t,this.cancel=c.bind(this,this.cancel),this.disablePreview=c.bind(this,this.disablePreview),this.enablePreview=c.bind(this,this.enablePreview),this.events=c.bind(this,this.events),this.finalize=c.bind(this,this.finalize),this.pause=c.bind(this,this.pause),this.preview=c.bind(this,this.preview),this.results=c.bind(this,this.results),this.searchlog=c.bind(this,this.searchlog),this.setPriority=c.bind(this,this.setPriority),this.setTTL=c.bind(this,this.setTTL),this.summary=c.bind(this,this.summary),this.timeline=c.bind(this,this.timeline),this.touch=c.bind(this,this.touch),this.unpause=c.bind(this,this.unpause)},cancel:function(e){return this.post("control",{action:"cancel"},e)},disablePreview:function(e){var t=this;return this.post("control",{action:"disablepreview"},e).catch(e=>{throw[e,t]})},enablePreview:function(e){var t=this;return this.post("control",{action:"enablepreview"},e).catch(e=>{throw[e,t]})},events:function(e,t){c.isNumber(e)&&!t&&(t=e,e={}),(e=e||{}).output_mode=e.output_mode||"json_rows";var r=this;let i=n.jobsV2+"/"+encodeURIComponent(this.name)+"/events";return this.disableV2SearchApi()?(i=n.jobs+"/"+encodeURIComponent(this.name)+"/events",this.get(i,e,t).then(e=>[e.data,r])):this.post(i,e,t).then(e=>[e.data,r])},finalize:function(e){var t=this;return this.post("control",{action:"finalize"},e).catch(e=>{throw[e,t]})},iterator:function(e,t){return new a.PaginatedEndpointIterator(this[e],t)},pause:function(e){var t=this;return this.post("control",{action:"pause"},e).catch(e=>{throw[e,t]})},preview:function(e,t){c.isNumber(e)&&!t&&(t=e,e={}),(e=e||{}).output_mode=e.output_mode||"json_rows";var r=this;let i=n.jobsV2+"/"+encodeURIComponent(this.name)+"/results_preview";return this.disableV2SearchApi()?(i=n.jobs+"/"+encodeURIComponent(this.name)+"/results_preview",this.get(i,e,t).then(e=>[e.data,r])):this.post(i,e,t).then(e=>[e.data,r])},results:function(e,t){c.isNumber(e)&&!t&&(t=e,e={}),(e=e||{}).output_mode=e.output_mode||"json_rows";var r=this;let i=n.jobsV2+"/"+encodeURIComponent(this.name)+"/results";return this.disableV2SearchApi()?(i=n.jobs+"/"+encodeURIComponent(this.name)+"/results",this.get(i,e,t).then(e=>[e.data,r])):this.post(i,e,t).then(e=>[e.data,r])},searchlog:function(e){var t=this;return this.get("search.log",{},e).then(e=>[e.data,t])},setPriority:function(e,t){var r=this;return this.post("control",{action:"setpriority",priority:e},t).catch(e=>{throw[e,r]})},setTTL:function(e,t){var r=this;return this.post("control",{action:"setttl",ttl:e},t).catch(e=>{throw[e,r]})},summary:function(e,t){c.isNumber(e)&&!t&&(t=e,e={});var r=this;return this.get("summary",e,t).then(e=>[e.data,r])},timeline:function(e,t){c.isNumber(e)&&!t&&(t=e,e={});var r=this;return this.get("timeline",e,t).then(e=>[e.data,r])},touch:function(e){var t=this;return this.post("control",{action:"touch"},e).catch(e=>{throw[e,t]})},track:async function(e,t){var r=e.period||500,i=!((t=c.isFunction(t)?{done:t}:t).progress||t.done||t.failed||t.error);t.ready=t.ready||function(){},t.progress=t.progress||function(){},t.done=t.done||function(){},t.failed=t.failed||function(){},t.error=t.error||function(){},t._preready=t._preready||function(){},t._stoppedAfterReady=t._stoppedAfterReady||function(){};let n=!1,o=!1;for(;!o;)try{let e=await this.fetch();var s=e.properties().dispatchState;if("QUEUED"===s||"PARSING"===s)t._preready(e);else{if(!n&&(t.ready(e),n=!0,i))return o=!0,t._stoppedAfterReady(e);t.progress(e);var a=e.properties();if("DONE"===s&&a.isDone)return o=!0,t.done(e);if("FAILED"===s&&a.isFailed)return o=!0,t.failed(e)}await c.sleep(r)}catch(e){return t.error(e)}},unpause:function(e){var t=this;return this.post("control",{action:"unpause"},e).catch(e=>{throw[e,t]})}}),a.Jobs=a.Collection.extend({path:function(){return this.disableV2SearchApi()?n.jobs:n.jobsV2},instantiateEntity:function(e){var t=e.content.sid,e=c.namespaceFromProperties(e);return new a.Job(this.service,t,e)},init:function(e,t){this.version=e.version,this.versionCompare=e.versionCompare,this.disableV2SearchApi=e.disableV2SearchApi,this._super(e,this.path(),t),this.create=c.bind(this,this.create)},create:function(e,t,r){if(!c.isObject(e)||!c.isNumber(t)&&t||r||(r=t,e=(t=e).search),(t=t||{}).search=e,"oneshot"===(t.exec_mode||"").toLowerCase())return Promise.reject(new Error("Please use splunkjs.Service.Jobs.oneshotSearch for exec_mode=oneshot"));if(!t.search)return Promise.reject("Must provide a query to create a search job");var i=this;return this.post("",t,r).then(e=>{return new a.Job(i.service,e.data.sid,i.namespace)})},search:function(e,t,r){return this.create(e,t,r)},oneshotSearch:function(e,t,r){if(c.isObject(e)&&c.isNumber(t)&&!r&&(r=t,e=(t=e).search),(t=t||{}).search=e,t.exec_mode="oneshot",!t.search)return Promise.reject("Must provide a query to create a search job");var e=t.output_mode||"json_rows",i=this.qualifiedPath;return this.service.request(i,"POST",{output_mode:e},t,null,{},r).then(e=>e.data)}}),a.DataModelField=t.extend({_types:["string","number","timestamp","objectCount","childCount","ipv4","boolean"],init:function(e){(e=e||{}).owner=e.owner||"",this.name=e.fieldName,this.displayName=e.displayName,this.type=e.type,this.multivalued=e.multivalue,this.required=e.required,this.hidden=e.hidden,this.editable=e.editable,this.comment=e.comment||null,this.fieldSearch=e.fieldSearch,this.lineage=e.owner.split("."),this.owner=this.lineage[this.lineage.length-1]},isString:function(){return"string"===this.type},isNumber:function(){return"number"===this.type},isTimestamp:function(){return"timestamp"===this.type},isObjectcount:function(){return"objectCount"===this.type},isChildcount:function(){return"childCount"===this.type},isIPv4:function(){return"ipv4"===this.type},isBoolean:function(){return"boolean"===this.type}}),a.DataModelConstraint=t.extend({init:function(e){(e=e||{}).owner=e.owner||"",this.query=e.search,this.lineage=e.owner.split("."),this.owner=this.lineage[this.lineage.length-1]}}),a.DataModelCalculation=t.extend({_types:["Lookup","Eval","GeoIP","Rex"],init:function(t){(t=t||{}).owner=t.owner||"",this.id=t.calculationID,this.type=t.calculationType,this.comment=t.comment||null,this.editable=t.editable,this.lineage=t.owner.split("."),this.owner=this.lineage[this.lineage.length-1],this.outputFields=[];for(let e=0;e<t.outputFields.length;e++)this.outputFields[t.outputFields[e].fieldName]=new a.DataModelField(t.outputFields[e]);"Eval"!==this.type&&"Rex"!==this.type||(this.expression=t.expression),"GeoIP"!==this.type&&"Rex"!==this.type||(this.inputField=t.inputField),"Lookup"===this.type&&(this.lookupName=t.lookupName,this.inputFieldMappings=t.lookupInputs[0])},outputFieldNames:function(){return Object.keys(this.outputFields)},isEditable:function(){return!!this.editable},isLookup:function(){return"Lookup"===this.type},isEval:function(){return"Eval"===this.type},isRex:function(){return"Rex"===this.type},isGeoIP:function(){return"GeoIP"===this.type}}),a.Pivot=t.extend({init:function(e,t){this.service=e,this.search=t.search,this.drilldownSearch=t.drilldown_search,this.prettyQuery=this.openInSearch=t.open_in_search,this.pivotSearch=t.pivot_search,this.tstatsSearch=t.tstats_search||null,this.run=c.bind(this,this.run)},run:function(e,t){return c.isNumber(e)&&!t&&(t=e,e={}),e&&0!==Object.keys(e).length||(e={}),this.service.search(this.tstatsSearch||this.pivotSearch,e,t)}}),a.PivotSpecification=t.extend({_comparisons:{boolean:["=","is","isNull","isNotNull"],string:["=","is","isNull","isNotNull","contains","doesNotContain","startsWith","endsWith","regex"],number:["=","!=","<",">","<=",">=","is","isNull","isNotNull"],ipv4:["is","isNull","isNotNull","contains","doesNotContain","startsWith"]},_binning:["auto","year","month","day","hour","minute","second"],_sortDirection:["ASCENDING","DESCENDING","DEFAULT"],_statsFunctions:["list","values","first","last","count","dc","sum","average","max","min","stdev","duration","earliest","latest"],init:function(e){this.dataModelObject=e,this.columns=[],this.rows=[],this.filters=[],this.cells=[],this.accelerationNamespace=e.dataModel.isAccelerated()?e.dataModel.name:null,this.run=c.bind(this,this.run),this.pivot=c.bind(this,this.pivot)},setAccelerationJob:function(e){if(e=e&&e instanceof r.Job?e.sid:e)return this.accelerationNamespace="sid="+e,this;throw new Error("Sid to use for acceleration must not be null.")},addFilter:function(e,t,r,i){if(!this.dataModelObject.hasField(e))throw new Error("Cannot add filter on a nonexistent field.");if(t!==this.dataModelObject.fieldByName(e).type)throw new Error("Cannot add "+t+" filter on "+e+" because it is of type "+this.dataModelObject.fieldByName(e).type);if(!c.contains(this._comparisons[t],r))throw new Error("Cannot add "+t+" filter because "+r+" is not a valid comparison operator");let n={fieldName:e,owner:this.dataModelObject.fieldByName(e).lineage.join("."),type:t};return c.contains(["boolean","string","ipv4","number"],n.type)&&(n.rule={comparator:r,compareTo:i}),this.filters.push(n),this},addLimitFilter:function(e,t,r,i,n){if(!this.dataModelObject.hasField(e))throw new Error("Cannot add limit filter on a nonexistent field.");let o=this.dataModelObject.fieldByName(e);if(!c.contains(["string","number","objectCount"],o.type))throw new Error("Cannot add limit filter on "+e+" because it is of type "+o.type);if("string"===o.type&&!c.contains(["count","dc"],n))throw new Error("Stats function for fields of type string must be COUNT or DISTINCT_COUNT; found "+n);if("number"===o.type&&!c.contains(["count","dc","average","sum"],n))throw new Error("Stats function for fields of type number must be one of COUNT, DISTINCT_COUNT, SUM, or AVERAGE; found "+n);if("objectCount"===o.type&&!c.contains(["count"],n))throw new Error("Stats function for fields of type object count must be COUNT; found "+n);let s={fieldName:e,owner:o.lineage.join("."),type:o.type,attributeName:t,attributeOwner:this.dataModelObject.fieldByName(t).lineage.join("."),sortDirection:r,limitAmount:i,statsFn:n};return s.limitType="ASCENDING"===r?"lowest":"highest",this.filters.push(s),this},addRowSplit:function(e,t){if(!this.dataModelObject.hasField(e))throw new Error("Did not find field "+e);var r=this.dataModelObject.fieldByName(e);if(!c.contains(["number","string"],r.type))throw new Error("Field was of type "+r.type+", expected number or string.");let i={fieldName:e,owner:r.owner,type:r.type,label:t};return"number"===r.type&&(i.display="all"),this.rows.push(i),this},addRangeRowSplit:function(e,t,r){if(!this.dataModelObject.hasField(e))throw new Error("Did not find field "+e);var i=this.dataModelObject.fieldByName(e);if("number"!==i.type)throw new Error("Field was of type "+i.type+", expected number.");let n={};return c.isUndefined(r.start)||null===r.start||(n.start=r.start),c.isUndefined(r.end)||null===r.end||(n.end=r.end),c.isUndefined(r.step)||null===r.step||(n.size=r.step),c.isUndefined(r.limit)||null===r.limit||(n.maxNumberOf=r.limit),this.rows.push({fieldName:e,owner:i.owner,type:i.type,label:t,display:"ranges",ranges:n}),this},addBooleanRowSplit:function(e,t,r,i){if(!this.dataModelObject.fieldByName(e))throw new Error("Did not find field "+e);var n=this.dataModelObject.fieldByName(e);if("boolean"!==n.type)throw new Error("Field was of type "+n.type+", expected boolean.");return this.rows.push({fieldName:e,owner:n.owner,type:n.type,label:t,trueLabel:r,falseLabel:i}),this},addTimestampRowSplit:function(e,t,r){if(!this.dataModelObject.hasField(e))throw new Error("Did not find field "+e);var i=this.dataModelObject.fieldByName(e);if("timestamp"!==i.type)throw new Error("Field was of type "+i.type+", expected timestamp.");if(c.contains(this._binning,r))return this.rows.push({fieldName:e,owner:i.owner,type:i.type,label:t,period:r}),this;throw new Error("Inva