splunk-sdk
Version:
SDK for usage with the Splunk REST API
1 lines • 1.08 MB
JavaScript
!function i(n,s,a){function o(t,e){if(!s[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=s[t]={exports:{}},n[t][0].call(r.exports,function(e){return o(n[t][1][e]||e)},r,r.exports,i,n,s,a)}return s[t].exports}for(var c="function"==typeof require&&require,e=0;e<a.length;e++)o(a[e]);return o}({1:[function(b,m,y){!function(d,p){!function(){function i(e){if((e=p.isBuffer(e)?e:p.from(""+e)).length){var t=0;do{try{var r=e.length-t;t+=n.writeSync(d.stdout.fd,e,t,r,-1)}catch(e){}}while(t<e.length)}}var o,c=b("util"),n=b("fs"),e=(c.format||(o=/%[sdj%]/g,c.format=function(e){if("string"!=typeof e){for(var t=[],r=0;r<arguments.length;r++)t.push(c.inspect(arguments[r]));return t.join(" ")}for(var r=1,i=arguments,n=i.length,s=String(e).replace(o,function(e){if(n<=r)return e;switch(e){case"%s":return String(i[r++]);case"%d":return Number(i[r++]);case"%j":return JSON.stringify(i[r++]);case"%%":return"%";default:return e}}),a=i[r];r<n;a=i[++r])s+=null===a||"object"!=typeof a?" "+a:" "+c.inspect(a);return s}),b("events").EventEmitter),t=b("path"),u=b("tty"),r=t.basename;function h(e,t){this.flags=e,this.required=~e.indexOf("<"),this.optional=~e.indexOf("["),this.bool=!~e.indexOf("-no-"),1<(e=e.split(/[ ,|]+/)).length&&!/^[[<]/.test(e[1])&&(this.short=e.shift()),this.long=e.shift(),this.description=t}function s(e){this.commands=[],this.options=[],this.args=[],this.name=e,this.opts={}}function f(e){return e.split("-").reduce(function(e,t){return e+t[0].toUpperCase()+t.slice(1)})}function a(e,t){t=Math.max(0,t-e.length);return e+Array(t+1).join(" ")}function l(e,t){var r=0;r<(t=t||[]).length&&("--help"!=t[r]&&"-h"!=t[r]||(d.on("exit",function(){i(e.helpInformation()),e.emit("--help"),i("")}),d.exit()))}(y=m.exports=new s).Command=s,(y.Option=h).prototype.name=function(){return this.long.replace("--","").replace("no-","")},h.prototype.is=function(e){return e==this.short||e==this.long},s.prototype.__proto__=e.prototype,s.prototype.command=function(e){var e=e.split(/ +/),t=new s(e.shift());return this.commands.push(t),t.parseExpectedArgs(e),t.parent=this,t},s.prototype.parseExpectedArgs=function(e){var t;if(e.length)return t=this,e.forEach(function(e){switch(e[0]){case"<":t.args.push({required:!0,name:e.slice(1,-1)});break;case"[":t.args.push({required:!1,name:e.slice(1,-1)})}}),this},s.prototype.action=function(t){var s=this;return this.parent.on(this.name,function(r,e){r=r.slice();var n=s.parseOptions(e=e||[]);l(s,n.unknown),0<n.unknown.length&&s.unknownOption(n.unknown[0]),s.options.forEach(function(e,t){var r=e.name(),i=f(r);e.isPresenceRequired&&void 0===s[i]&&!n.required[r]&&s.optionMissing(e)}),s.args.forEach(function(e,t){e.required&&null==r[t]&&s.missingArgument(e.name)}),s.args.length&&r.length<=s.args.length-1?r[s.args.length]=s:r.push(s),t.apply(this,r)}),this},s.prototype.option=function(e,t,r,i,n){var s=this,a=new h(e,t),e=a.name(),o=f(e);return"function"!=typeof r&&(n=i,i=r,r=null),(0==a.bool||a.optional||a.required)&&void 0!==(i=0==a.bool?!0:i)&&(s[o]=i),a.isPresenceRequired=n,this.options.push(a),this.on(e,function(e){null!=e&&r&&(e=r(e)),"boolean"==typeof s[o]||void 0===s[o]?s[o]=s.opts[o]=null==e?!!a.bool&&(i||!0):e:null!==e&&(s[o]=s.opts[o]=e)}),this},s.prototype.parse=function(e){this.rawArgs=e,this.name||(this.name=r(e[1]));e=this.parseOptions(this.normalize(e.slice(2)));return this.args=e.args,this.parseArgs(this.args,e.unknown,e.required)},s.prototype.normalize=function(e){for(var t,r=[],i=0,n=e.length;i<n;++i)1<(t=e[i]).length&&"-"==t[0]&&"-"!=t[1]?t.slice(1).split("").forEach(function(e){r.push("-"+e)}):r.push(t);return r},s.prototype.parseArgs=function(e,t,n){this.commands.length;var r,s=this;return e.length?(r=e[0],this.listeners(r).length?(r=e.shift(),this.executedCommand=r,this.emit(r,e,t)):(this.executedCommand="*",this.emit("*",e))):(l(this,t),0<t.length&&this.unknownOption(t[0]),this.options.forEach(function(e,t){var r=e.name(),i=f(r);e.isPresenceRequired&&void 0===s[i]&&!n[r]&&s.optionMissing(e)})),this},s.prototype.optionFor=function(e){for(var t=0,r=this.options.length;t<r;++t)if(this.options[t].is(e))return this.options[t]},s.prototype.parseOptions=function(e){for(var t,r,i,n=[],s=e.length,a=[],o={},c=0;c<s;++c)if("--"==(i=e[c]))t=!0;else if(t)n.push(i);else if(r=this.optionFor(i))if(r.isPresenceRequired&&(o[r.name()]=!0),r.required){if(null==(i=e[++c]))return this.optionMissingArgument(r);if("-"==i[0])return this.optionMissingArgument(r,i);this.emit(r.name(),i)}else r.optional?(null==(i=e[c+1])||"-"==i[0]?i=null:++c,this.emit(r.name(),i)):this.emit(r.name());else 1<i.length&&"-"==i[0]?(a.push(i),e[c+1]&&"-"!=e[c+1][0]&&a.push(e[++c])):n.push(i);return{args:n,unknown:a,required:o}},s.prototype.missingArgument=function(e){console.error(),console.error(" error: missing required argument `%s'",e),console.error(),d.exit(1)},s.prototype.optionMissingArgument=function(e,t){console.error(),t?console.error(" error: option `%s' argument missing, got `%s'",e.flags,t):console.error(" error: option `%s' argument missing",e.flags),console.error(),d.exit(1)},s.prototype.optionMissing=function(e){console.error(),console.error(" error: option `%s' is missing",e.name()),console.error(),d.exit(1)},s.prototype.unknownOption=function(e){console.error(),console.error(" error: unknown option `%s'",e),console.error(),d.exit(1)},s.prototype.version=function(e,t){return 0==arguments.length?this._version:(this._version=e,this.option(t=t||"-V, --version","output the version number"),this.on("version",function(){console.log(e),d.exit(0)}),this)},s.prototype.description=function(e){return 0==arguments.length?this._description:(this._description=e,this)},s.prototype.usage=function(e){var t=this.args.map(function(e){return e.required?"<"+e.name+">":"["+e.name+"]"}),t="[options"+(this.commands.length?"] [command":"")+"]"+(this.args.length?" "+t:"");return 0==arguments.length?this._usage||t:(this._usage=e,this)},s.prototype.largestOptionLength=function(){return this.options.reduce(function(e,t){return Math.max(e,t.flags.length)},0)},s.prototype.optionHelp=function(){var t=this.largestOptionLength();return[a("-h, --help",t)+" output usage information"].concat(this.options.map(function(e){return a(e.flags,t)+" "+e.description})).join("\n")},s.prototype.commandHelp=function(){return this.commands.length?[""," Commands:","",this.commands.map(function(e){var t=e.args.map(function(e){return e.required?"<"+e.name+">":"["+e.name+"]"}).join(" ");return e.name+(e.options.length?" [options]":"")+" "+t+(e.description()?"\n"+e.description():"")}).join("\n\n").replace(/^/gm," "),""].join("\n"):""},s.prototype.helpInformation=function(){return[""," Usage: "+this.name+" "+this.usage(),""+this.commandHelp()," Options:","",""+this.optionHelp().replace(/^/gm," "),"",""].join("\n")},s.prototype.promptForNumber=function(r,i){var n=this;this.promptSingleLine(r,function e(t){if(t=Number(t),isNaN(t))return n.promptSingleLine(r+"(must be a number) ",e);i(t)})},s.prototype.promptForDate=function(r,i){var n=this;this.promptSingleLine(r,function e(t){if(t=new Date(t),isNaN(t.getTime()))return n.promptSingleLine(r+"(must be a date) ",e);i(t)})},s.prototype.promptSingleLine=function(e,t){if("function"==typeof arguments[2])return this["promptFor"+(t.name||t)](e,arguments[2]);d.stdout.write(e),d.stdin.setEncoding("utf8"),d.stdin.once("data",function(e){t(e.trim())}).resume()},s.prototype.promptMultiLine=function(e,t){var r=[];console.log(e),d.stdin.setEncoding("utf8"),d.stdin.on("data",function(e){"\n"==e||"\r\n"==e?(d.stdin.removeAllListeners("data"),t(r.join("\n"))):r.push(e.trimRight())}).resume()},s.prototype.prompt=function(e,t){if(/ $/.test(e))return this.promptSingleLine.apply(this,arguments);this.promptMultiLine(e,t)},s.prototype.password=function(r,i,n){var s=this,a="";"function"==typeof i&&(n=i,i=""),u.setRawMode(!0),d.stdout.write(r),d.stdin.on("keypress",function(e,t){if(t&&"enter"==t.name)return console.log(),d.stdin.removeAllListeners("keypress"),u.setRawMode(!1),a.trim().length?void n(a):s.password(r,i,n);t&&t.ctrl&&"c"==t.name&&(console.log("%s",a),d.exit()),d.stdout.write(i),a+=e}).resume()},s.prototype.confirm=function(t,r){var i=this;this.prompt(t,function(e){if(!e.trim())return i.confirm(t,r);r(/^y|yes|ok|true$/i.test(e))})},s.prototype.choose=function(r,i){var e=this;r.forEach(function(e,t){console.log(" %d) %s",t+1,e)}),function t(){e.prompt(" : ",function(e){e=parseInt(e,10)-1,null==r[e]?t():i(e,r[e])})}()}}.call(this)}.call(this,b("_process"),b("buffer").Buffer)},{_process:242,buffer:70,events:147,fs:68,path:234,tty:288,util:295}],2:[function(n,s,a){!function(i){!function(){!function(){var e,t,r=a||this;n("dotenv").config();try{i.env=i.env||{}}catch(e){}s.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":5,"./lib/jquery.class":6,"./lib/log":7,"./lib/paths":8,"./lib/platform/client/jquery_http":9,"./lib/platform/client/proxy_http":10,"./lib/platform/node/node_http":11,"./lib/service":12,"./lib/utils":13,_process:242,dotenv:128}],3:[function(o,t,c){!function(){"use strict";var r=o("./paths").Paths,e=o("./jquery.class").Class,i=o("./http"),n=o("./utils"),s=c||this,a={5:"",4.3:"/services/json/v2",default:""};t.exports=s=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=o("./platform/node/node_http").NodeHttp;t=new e}}this.http=t,this.http._setSplunkVersion(this.version);e=n.getWithVersion(this.version,a);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!==s.Sharing.SYSTEM)return"/services/"+e;let r=t.owner||this.owner||"-",i=t.app||this.app||"-";return t.sharing=(t.sharing||"").toLowerCase(),t.sharing===s.Sharing.APP||t.sharing===s.Sharing.GLOBAL?r="nobody":t.sharing===s.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,s,a){var o=this;return this._requestWrapper(function(){return o.http.request(o.urlify(e),{method:t,headers:o._headers(s),query:r,post:i,body:n,timeout:o.timeout},a)})},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 s=e<r.length?parseInt(r[e],10):0,a=e<i.length?parseInt(i[e],10):0;if(s<a)return-1;if(a<s)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}}),s.Sharing={USER:"user",APP:"app",GLOBAL:"global",SYSTEM:"system"}}()},{"./http":5,"./jquery.class":6,"./paths":8,"./platform/node/node_http":11,"./utils":13}],4:[function(e,t,r){window.SplunkTest={Utils:e("../../tests/test_utils"),Http:e("../../tests/test_http"),Context:e("../../tests/test_context"),Service:e("../../tests/test_service")}},{"../../tests/test_context":319,"../../tests/test_http":320,"../../tests/test_service":321,"../../tests/test_utils":322}],5:[function(r,i,e){!function(){"use strict";var e=r("./jquery.class").Class,s=r("./log").Logger,a=r("./utils"),t=r("cookie"),o=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=o=e.extend({init:function(){this.get=a.bind(this,this.get),this.del=a.bind(this,this.del),this.post=a.bind(this,this.post),this.request=a.bind(this,this.request),this._buildResponse=a.bind(this,this._buildResponse),this._setSplunkVersion("none"),this._cookieStore={}},_setSplunkVersion:function(e){this.version=e},_getCookieString:function(){let r="";return a.forEach(this._cookieStore,function(e,t){r=(r=r+t+"=")+e+"; "}),r},_parseCookieHeader:function(e){e=t.parse(e);let r={};return a.forEach(e,function(e,t){r.key||(r.key=t,r.value=e)}),r},get:function(e,t,r,i,n,s){return this.request(e,{method:"GET",headers:t,timeout:i,response_timeout:n,query:r},s)},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=a.getWithVersion(this.version,c)(e),s=e.post||{},t=t+"?"+o.encode(n),n=e.body||o.encode(s),s=i._getCookieString(),s=(0!==s.length&&(e.headers.Cookie=s,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,s);{let e=this.makeRequest(t,s);return e.then(e=>{if(e){var t=e.response.headers["set-cookie"];if(t&&a.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=a.trim(t.headers["content-type"]||t.headers["Content-Type"]||t.headers["Content-type"]||t.headers.contentType)),a.startsWith(n,"application/json")&&r)try{i=this.parseJson(r)||{}}catch(e){s.error("Error in parsing JSON:",r,e),i=r}else i=r;return i&&s.printMessages(i.messages),{response:t,status:t?t.statusCode:0,data:i,error:e}}}),o.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":6,"./log":7,"./utils":13,cookie:108}],6:[function(e,t,r){!function(){var e=r||this,s=!1,a=/xyz/.test(function(){return xyz})?/\b_super\b/:/.*/;e.Class=function(){},e.Class.extend=function(e){var t,n=this.prototype,r=(s=!0,new this);for(t in s=!1,e)r[t]="function"==typeof e[t]&&"function"==typeof n[t]&&a.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(){!s&&this.init&&this.init.apply(this,arguments)}return i.prototype=r,(i.constructor=i).extend=arguments.callee,i}}()},{}],7:[function(u,e,h){!function(c){!function(){!function(){"use strict";function t(e){a.isString(e)&&o.hasOwnProperty(e)?c.env.LOG_LEVEL=o[e]:!isNaN(parseInt(e,10))&&a.keyOf(parseInt(e,10),o)?c.env.LOG_LEVEL=e:c.env.LOG_LEVEL=o.ERROR}var e,r,i,n,s,a=u("./utils"),o={ALL:4,INFO:3,WARN:2,ERROR:1,NONE:0};c.env.LOG_LEVEL?t(c.env.LOG_LEVEL):c.env.LOG_LEVEL=o.ERROR,e=r=i=n=function(){},"undefined"!=typeof console&&(s=function(r){return function(t){try{console[r].apply(console,arguments)}catch(e){console[r](t)}}},console.log&&(e=s("log")),console.error&&(i=s("error")),console.warn&&(r=s("warn")),console.info&&(n=s("info"))),h.Logger={log:function(){c.env.LOG_LEVEL>=o.ALL&&e.apply(null,arguments)},error:function(){c.env.LOG_LEVEL>=o.ERROR&&i.apply(null,arguments)},warn:function(){c.env.LOG_LEVEL>=o.WARN&&r.apply(null,arguments)},info:function(){c.env.LOG_LEVEL>=o.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:o}}()}.call(this)}.call(this,u("_process"))},{"./utils":13,_process:242}],8:[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"}}()},{}],9:[function(t,e,i){!function(){function a(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=t("../../http"),o=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,s=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:o.bind(this,function(e,t,r){r={statusCode:r.status,headers:a(r.getAllResponseHeaders())},t=this._buildResponse(t,r,e);return Promise.resolve(t)}),error:function(e,t,r){if("timeout"===t)return n=s._buildResponse("abort",{headers:{},statusCode:"abort",body:{}},{}),Promise.reject(n);var i={statusCode:e.status,headers:a(e.getAllResponseHeaders())},t=("abort"===t&&(i.statusCode="abort",e.responseText="{}"),JSON.parse(e.responseText));return n=s._buildResponse(r,i,t),Promise.reject(n)}};return $.ajax(e).then(e=>n).catch(e=>n)},parseJson:function(e){return e}})}()},{"../../../package.json":298,"../../http":5,"../../utils":13}],10:[function(n,e,u){!function(){function a(e){for(var t,r={},i=e.split("\n"),n=0;n<i.length;n++)""!==s.trim(i[n])&&(r[(t=i[n].split(": "))[0]]=t[1]);return r}var e=n("../../http"),s=n("../../utils"),i=n("../../../package.json").version,t=u||this;function o(e){for(var i=o.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}o.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=o(e),r=(r.protocol||"")+"://"+r.authority,s=(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:a(r.getAllResponseHeaders())};return n=s._buildResponse(t,r,e),Promise.resolve(n)},error:function(e,t,r){if("timeout"===t)return n=s._buildResponse("abort",{headers:{},statusCode:"abort",body:{}},{}),Promise.reject(n);var i={statusCode:e.status,headers:a(e.getAllResponseHeaders())},t=("abort"===t&&(i.statusCode="abort",e.responseText="{}"),e.responseText);return n=s._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=o(e),r=(r.protocol||"")+"://"+r.authority,s=(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:a(r.getAllResponseHeaders()),body:JSON.parse(e)};return n=r,Promise.resolve(n)},error:function(e,t,r){if("timeout"===t)return n=s._buildResponse("abort",{headers:{},statusCode:"abort",body:{}},{}),Promise.reject(n);var i={statusCode:e.status,headers:a(e.getAllResponseHeaders())},t=("abort"===t&&(i.statusCode="abort",e.responseText="{}"),e.responseText);return n=s._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":298,"../../http":5,"../../utils":13}],11:[function(t,e,r){!function(o){!function(){!function(){var s=t("needle"),e=t("../../http"),a=(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"]=o.byteLength(t.body,"utf8"),t.headers["User-Agent"]="splunk-sdk-javascript/"+a,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 s(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"]=o.byteLength(e.body,"utf8"),e.headers["User-Agent"]="splunk-sdk-javascript/"+a;return s(e.method,e.url,e.body,e)},parseJson:function(e){return JSON.parse(e)}})}()}.call(this)}.call(this,t("buffer").Buffer)},{"../../../package.json":298,"../../http":5,"../../utils":13,buffer:70,needle:209}],12:[function(i,s,a){!function(){"use strict";var e=i("./context"),n=(i("./http"),i("./paths").Paths),t=i("./jquery.class").Class,c=i("./utils"),o=a||this,r=null,e=e.extend({init:function(){this._super.apply(this,arguments)}});s.exports=o=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 o.Applications(this)},configurations:function(e){return new o.Configurations(this,e)},indexes:function(e){return new o.Indexes(this,e)},savedSearches:function(e){return new o.SavedSearches(this,e)},storagePasswords:function(e){return new o.StoragePasswords(this,e)},firedAlertGroups:function(e){return new o.FiredAlertGroupCollection(this,e)},jobs:function(e){return new o.Jobs(this,e)},dataModels:function(e){return new o.DataModels(this,e)},users:function(){return new o.Users(this)},views:function(e){return new o.Views(this,e)},search:function(e,t,r,i){!i&&c.isNumber(r)&&(i=r,r=null);let n=new o.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 o.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 o.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 o.User(i,e);return t.fetch({},r)})},serverInfo:function(e){let t=new o.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)}}),o.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)}}),o.Resource=o.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}}),o.Entity=o.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)}}),o.Collection=o.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 s=n[t];let e=this.instantiateEntity(s);e._load(s),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)}}),o.SavedSearch=o.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 o.Job(r.service,e,r.namespace),r]})},firedAlertGroup:function(){return new o.FiredAlertGroup(this.service,this.name)},history:function(e,t){!t&&c.isNumber(e)&&(t=e,e={});var a=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],s=c.namespaceFromProperties(n);let e=new o.Job(a.service,n.name,s);e._load(n),i.push(e)}return[i,a]})},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)))}}}),o.SavedSearches=o.Collection.extend({path:function(){return n.savedSearches},instantiateEntity:function(e){var t=c.namespaceFromProperties(e);return new o.SavedSearch(this.service,e.name,t)},init:function(e,t){this._super(e,this.path(),t)}}),o.StoragePassword=o.Entity.extend({path:function(){return n.storagePasswords+"/"+encodeURIComponent(this.name)},init:function(e,t,r){this.name=t,this._super(e,this.path(),r)}}),o.StoragePasswords=o.Collection.extend({fetchOnEntityCreation:!0,path:function(){return n.storagePasswords},instantiateEntity:function(e){var t=c.namespaceFromProperties(e);return new o.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,s=(c.isArray(n)&&(n=n[0]),this.instantiateEntity(n)),a=(s._load(n),this.fetchOnEntityCreation&&await s.fetch(t),!1);for(;!a;)await this.fetch(t),a=this.does_storage_password_exist(i,r);return s},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}}),o.FiredAlert=o.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)}}),o.FiredAlertGroup=o.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 a=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],s=c.namespaceFromProperties(n);let e=new o.FiredAlert(a.service,n.name,s);e._load(n),i.push(e)}return[i,a]})},init:function(e,t,r){this.name=t,this._super(e,this.path(),r),this.list=c.bind(this,this.list)}}),o.FiredAlertGroupCollection=o.Collection.extend({path:function(){return n.firedAlerts},instantiateEntity:function(e){var t=c.namespaceFromProperties(e);return new o.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)}}),o.Application=o.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])}}),o.Applications=o.Collection.extend({fetchOnEntityCreation:!0,path:function(){return n.apps},instantiateEntity:function(e){return new o.Application(this.service,e.name,{})},init:function(e){this._super(e,this.path(),{})}}),o.ServerInfo=o.Entity.extend({path:function(){return n.info},init:function(e){this.name="server-info",this._super(e,this.path(),{})}}),o.User=o.Entity.extend({path:function(){return n.users+"/"+encodeURIComponent(this.name)},init:function(e,t){this.name=t,this._super(e,this.path(),{})}}),o.Users=o.Collection.extend({fetchOnEntityCreation:!0,path:function(){return n.users},instantiateEntity:function(e){return new o.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 s=this;return this.post("",i,n).then(e=>{var t={name:i.name};let r=s.instantiateEntity(t);return r.fetch({},n)})}}),o.View=o.Entity.extend({path:function(){return n.views+"/"+encodeURIComponent(this.name)},init:function(e,t,r){this.name=t,this._super(e,this.path(),r)}}),o.Views=o.Collection.extend({path:function(){return n.views},instantiateEntity:function(e){var t=c.namespaceFromProperties(e);return new o.View(this.service,e.name,t)},init:function(e,t){this._super(e,this.path(),t)}}),o.Index=o.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)}}),o.Indexes=o.Collection.extend({path:function(){return n.indexes},instantiateEntity:function(e){var t=c.namespaceFromProperties(e);return new o.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)}}),o.ConfigurationStanza=o.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)}}),o.ConfigurationFile=o.Collection.extend({path:function(){return n.configurations+"/conf-"+encodeURIComponent(this.name)},getDefaultStanza:function(){return new o.ConfigurationStanza(this.service,this.name,"default",this.namespace)},instantiateEntity:function(e){var t=c.namespaceFromProperties(e);return new o.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)}}),o.Configurations=o.Collection.extend({fetchOnEntityCreation:!0,path:function(){return n.properties},instantiateEntity:function(e){return new o.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 o.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 o.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),s=(null==n&&(await this.create({__conf:e},i),n=await(n=new o.ConfigurationFile(this.service,e)).fetchAsync(i)),await this.getStanza(n,t));return null==s?n.create(t,r,i):s.update(r,i)}}),o.Job=o.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 o.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,s=!1;for(;!s;)try{let e=await this.fetch();var a=e.properties().dispatchState;if("QUEUED"===a||"PARSING"===a)t._preready(e);else{if(!n&&(t.ready(e),n=!0,i))return s=!0,t._stoppedAfterReady(e);t.progress(e);var o=e.properties();if("DONE"===a&&o.isDone)return s=!0,t.done(e);if("FAILED"===a&&o.isFailed)return s=!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]})}}),o.Jobs=o.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 o.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 o.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)}}),o.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}}),