Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions client/browser_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3411,6 +3411,47 @@ describe("Service Tests ", function(){
assert.ok(err);
}
})

it("ACL update", async function() {
let name = "jssdk_savedsearch_test_acl1";
let originalSearch = "search * | head 1";

let searches = this.service.savedSearches({ owner: this.service.username, app: "sdkappcollection"});
let search = await searches.create({ search: originalSearch, name: name });
assert.ok(search);
let prop = search.acl();
assert.strictEqual(prop["sharing"], "user");
assert.strictEqual(prop["perms"], null);

search = await search.acl_update({sharing:"app",owner:"admin","perms.read":"admin"});
let updatedProp = search.acl();
assert.strictEqual(updatedProp["owner"], "admin");
assert.strictEqual(updatedProp["sharing"], "app");
assert.equal(updatedProp["perms"]["read"], "admin");
await search.remove();
})

it("ACL update fail without sharing", async function() {
let name = "jssdk_savedsearch_test_acl2";
let originalSearch = "search * | head 1";

let searches = this.service.savedSearches({ owner: this.service.username, app: "sdkappcollection"});
let search = await searches.create({ search: originalSearch, name: name });
assert.ok(search);
assert.throws(()=>{search.acl_update({owner:"admin"})}, "Required argument 'sharing' is missing.")
await search.remove();
})

it("ACL update fail without owner", async function() {
let name = "jssdk_savedsearch_test_acl3";
let originalSearch = "search * | head 1";

let searches = this.service.savedSearches({ owner: this.service.username, app: "sdkappcollection"});
let search = await searches.create({ search: originalSearch, name: name });
assert.ok(search);
assert.throws(()=>{search.acl_update({sharing:"app"})}, "Required argument 'owner' is missing.");
await search.remove();
})
});

describe("Fired alerts tests", () => {
Expand Down
65 changes: 48 additions & 17 deletions client/splunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -2796,19 +2796,20 @@ var __exportName = 'splunkjs';
this._super(service, path, namespace);

// We perform the bindings so that every function works properly
this._load = utils.bind(this, this._load);
this.fetch = utils.bind(this, this.fetch);
this.remove = utils.bind(this, this.remove);
this.update = utils.bind(this, this.update);
this.fields = utils.bind(this, this.fields);
this.links = utils.bind(this, this.links);
this.acl = utils.bind(this, this.acl);
this.author = utils.bind(this, this.author);
this.updated = utils.bind(this, this.updated);
this.published = utils.bind(this, this.published);
this.enable = utils.bind(this, this.enable);
this.disable = utils.bind(this, this.disable);
this.reload = utils.bind(this, this.reload);
this._load = utils.bind(this, this._load);
this.fetch = utils.bind(this, this.fetch);
this.remove = utils.bind(this, this.remove);
this.update = utils.bind(this, this.update);
this.fields = utils.bind(this, this.fields);
this.links = utils.bind(this, this.links);
this.acl = utils.bind(this, this.acl);
this.acl_update = utils.bind(this, this.acl_update);
this.author = utils.bind(this, this.author);
this.updated = utils.bind(this, this.updated);
this.published = utils.bind(this, this.published);
this.enable = utils.bind(this, this.enable);
this.disable = utils.bind(this, this.disable);
this.reload = utils.bind(this, this.reload);

// Initial values
this._properties = {};
Expand Down Expand Up @@ -2873,6 +2874,36 @@ var __exportName = 'splunkjs';
return this._acl;
},

/**
* Update the access control list (ACL) information for this entity,
* which contains the permissions for accessing the entity.
*
* @example
*
* let savedSearches = svc.savedSearches({ owner: "owner-name", app: "app-name"});
* let search = await searches.create({ search: "search * | head 1", name: "acl_test" });
* search = await search.acl_update({sharing:"app",owner:"admin","perms.read":"admin"});
*
* @param {Object} options Additional entity-specific arguments (required):
* - `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user (required).
* - `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system" (required).
* @param {Number} response_timeout A timeout period for aborting a request in milisecs (0 means no timeout).
*
* @method splunkjs.Service.Entity
*/
acl_update: function(options, response_timeout) {
if(!options.hasOwnProperty("sharing")) {
throw new Error("Required argument 'sharing' is missing.");
}
if(!options.hasOwnProperty("owner")) {
throw new Error("Required argument 'owner' is missing.");
}

return this.post("acl", options, response_timeout).then((res)=>{
return this.fetch({});
});
},

/**
* Retrieves the links information for this entity, which is the URI of
* the entity relative to the management port of a Splunk instance.
Expand Down Expand Up @@ -28960,7 +28991,7 @@ module.exports={
"_args": [
[
"elliptic@6.5.4",
"/Users/abhis/Documents/GitHub/splunk-sdk-javascript"
"/Users/abhis/Documents/JS/splunk-sdk-javascript"
]
],
"_development": true,
Expand All @@ -28986,7 +29017,7 @@ module.exports={
],
"_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
"_spec": "6.5.4",
"_where": "/Users/abhis/Documents/GitHub/splunk-sdk-javascript",
"_where": "/Users/abhis/Documents/JS/splunk-sdk-javascript",
"author": {
"name": "Fedor Indutny",
"email": "fedor@indutny.com"
Expand Down Expand Up @@ -39453,7 +39484,7 @@ module.exports={
"_args": [
[
"needle@3.0.0",
"/Users/abhis/Documents/GitHub/splunk-sdk-javascript"
"/Users/abhis/Documents/JS/splunk-sdk-javascript"
]
],
"_from": "needle@3.0.0",
Expand All @@ -39479,7 +39510,7 @@ module.exports={
],
"_resolved": "https://registry.npmjs.org/needle/-/needle-3.0.0.tgz",
"_spec": "3.0.0",
"_where": "/Users/abhis/Documents/GitHub/splunk-sdk-javascript",
"_where": "/Users/abhis/Documents/JS/splunk-sdk-javascript",
"author": {
"name": "Tomás Pollak",
"email": "tomas@forkhq.com"
Expand Down
2 changes: 1 addition & 1 deletion client/splunk.min.js

Large diffs are not rendered by default.

106 changes: 89 additions & 17 deletions client/splunk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3486,19 +3486,20 @@ window.SplunkTest = {
this._super(service, path, namespace);

// We perform the bindings so that every function works properly
this._load = utils.bind(this, this._load);
this.fetch = utils.bind(this, this.fetch);
this.remove = utils.bind(this, this.remove);
this.update = utils.bind(this, this.update);
this.fields = utils.bind(this, this.fields);
this.links = utils.bind(this, this.links);
this.acl = utils.bind(this, this.acl);
this.author = utils.bind(this, this.author);
this.updated = utils.bind(this, this.updated);
this.published = utils.bind(this, this.published);
this.enable = utils.bind(this, this.enable);
this.disable = utils.bind(this, this.disable);
this.reload = utils.bind(this, this.reload);
this._load = utils.bind(this, this._load);
this.fetch = utils.bind(this, this.fetch);
this.remove = utils.bind(this, this.remove);
this.update = utils.bind(this, this.update);
this.fields = utils.bind(this, this.fields);
this.links = utils.bind(this, this.links);
this.acl = utils.bind(this, this.acl);
this.acl_update = utils.bind(this, this.acl_update);
this.author = utils.bind(this, this.author);
this.updated = utils.bind(this, this.updated);
this.published = utils.bind(this, this.published);
this.enable = utils.bind(this, this.enable);
this.disable = utils.bind(this, this.disable);
this.reload = utils.bind(this, this.reload);

// Initial values
this._properties = {};
Expand Down Expand Up @@ -3563,6 +3564,36 @@ window.SplunkTest = {
return this._acl;
},

/**
* Update the access control list (ACL) information for this entity,
* which contains the permissions for accessing the entity.
*
* @example
*
* let savedSearches = svc.savedSearches({ owner: "owner-name", app: "app-name"});
* let search = await searches.create({ search: "search * | head 1", name: "acl_test" });
* search = await search.acl_update({sharing:"app",owner:"admin","perms.read":"admin"});
*
* @param {Object} options Additional entity-specific arguments (required):
* - `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user (required).
* - `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system" (required).
* @param {Number} response_timeout A timeout period for aborting a request in milisecs (0 means no timeout).
*
* @method splunkjs.Service.Entity
*/
acl_update: function(options, response_timeout) {
if(!options.hasOwnProperty("sharing")) {
throw new Error("Required argument 'sharing' is missing.");
}
if(!options.hasOwnProperty("owner")) {
throw new Error("Required argument 'owner' is missing.");
}

return this.post("acl", options, response_timeout).then((res)=>{
return this.fetch({});
});
},

/**
* Retrieves the links information for this entity, which is the URI of
* the entity relative to the management port of a Splunk instance.
Expand Down Expand Up @@ -39524,7 +39555,7 @@ module.exports={
"_args": [
[
"elliptic@6.5.4",
"/Users/abhis/Documents/GitHub/splunk-sdk-javascript"
"/Users/abhis/Documents/JS/splunk-sdk-javascript"
]
],
"_development": true,
Expand All @@ -39550,7 +39581,7 @@ module.exports={
],
"_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
"_spec": "6.5.4",
"_where": "/Users/abhis/Documents/GitHub/splunk-sdk-javascript",
"_where": "/Users/abhis/Documents/JS/splunk-sdk-javascript",
"author": {
"name": "Fedor Indutny",
"email": "fedor@indutny.com"
Expand Down Expand Up @@ -50919,7 +50950,7 @@ module.exports={
"_args": [
[
"needle@3.0.0",
"/Users/abhis/Documents/GitHub/splunk-sdk-javascript"
"/Users/abhis/Documents/JS/splunk-sdk-javascript"
]
],
"_from": "needle@3.0.0",
Expand All @@ -50945,7 +50976,7 @@ module.exports={
],
"_resolved": "https://registry.npmjs.org/needle/-/needle-3.0.0.tgz",
"_spec": "3.0.0",
"_where": "/Users/abhis/Documents/GitHub/splunk-sdk-javascript",
"_where": "/Users/abhis/Documents/JS/splunk-sdk-javascript",
"author": {
"name": "Tomás Pollak",
"email": "tomas@forkhq.com"
Expand Down Expand Up @@ -72622,6 +72653,47 @@ exports.setup = function (svc, loggedOutSvc) {
assert.ok(err);
}
})

it("ACL update", async function() {
let name = "jssdk_savedsearch_test_acl1";
let originalSearch = "search * | head 1";

let searches = this.service.savedSearches({ owner: this.service.username, app: "sdkappcollection"});
let search = await searches.create({ search: originalSearch, name: name });
assert.ok(search);
let prop = search.acl();
assert.strictEqual(prop["sharing"], "user");
assert.strictEqual(prop["perms"], null);

search = await search.acl_update({sharing:"app",owner:"admin","perms.read":"admin"});
let updatedProp = search.acl();
assert.strictEqual(updatedProp["owner"], "admin");
assert.strictEqual(updatedProp["sharing"], "app");
assert.equal(updatedProp["perms"]["read"], "admin");
await search.remove();
})

it("ACL update fail without sharing", async function() {
let name = "jssdk_savedsearch_test_acl2";
let originalSearch = "search * | head 1";

let searches = this.service.savedSearches({ owner: this.service.username, app: "sdkappcollection"});
let search = await searches.create({ search: originalSearch, name: name });
assert.ok(search);
assert.throws(()=>{search.acl_update({owner:"admin"})}, "Required argument 'sharing' is missing.")
await search.remove();
})

it("ACL update fail without owner", async function() {
let name = "jssdk_savedsearch_test_acl3";
let originalSearch = "search * | head 1";

let searches = this.service.savedSearches({ owner: this.service.username, app: "sdkappcollection"});
let search = await searches.create({ search: originalSearch, name: name });
assert.ok(search);
assert.throws(()=>{search.acl_update({sharing:"app"})}, "Required argument 'owner' is missing.");
await search.remove();
})
})
);
};
Expand Down
2 changes: 1 addition & 1 deletion client/splunk.test.min.js

Large diffs are not rendered by default.

57 changes: 44 additions & 13 deletions lib/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -964,19 +964,20 @@
this._super(service, path, namespace);

// We perform the bindings so that every function works properly
this._load = utils.bind(this, this._load);
this.fetch = utils.bind(this, this.fetch);
this.remove = utils.bind(this, this.remove);
this.update = utils.bind(this, this.update);
this.fields = utils.bind(this, this.fields);
this.links = utils.bind(this, this.links);
this.acl = utils.bind(this, this.acl);
this.author = utils.bind(this, this.author);
this.updated = utils.bind(this, this.updated);
this.published = utils.bind(this, this.published);
this.enable = utils.bind(this, this.enable);
this.disable = utils.bind(this, this.disable);
this.reload = utils.bind(this, this.reload);
this._load = utils.bind(this, this._load);
this.fetch = utils.bind(this, this.fetch);
this.remove = utils.bind(this, this.remove);
this.update = utils.bind(this, this.update);
this.fields = utils.bind(this, this.fields);
this.links = utils.bind(this, this.links);
this.acl = utils.bind(this, this.acl);
this.acl_update = utils.bind(this, this.acl_update);
this.author = utils.bind(this, this.author);
this.updated = utils.bind(this, this.updated);
this.published = utils.bind(this, this.published);
this.enable = utils.bind(this, this.enable);
this.disable = utils.bind(this, this.disable);
this.reload = utils.bind(this, this.reload);

// Initial values
this._properties = {};
Expand Down Expand Up @@ -1041,6 +1042,36 @@
return this._acl;
},

/**
* Update the access control list (ACL) information for this entity,
* which contains the permissions for accessing the entity.
*
* @example
*
* let savedSearches = svc.savedSearches({ owner: "owner-name", app: "app-name"});
* let search = await searches.create({ search: "search * | head 1", name: "acl_test" });
* search = await search.acl_update({sharing:"app",owner:"admin","perms.read":"admin"});
*
* @param {Object} options Additional entity-specific arguments (required):
* - `owner` (_string_): The Splunk username, such as "admin". A value of "nobody" means no specific user (required).
* - `sharing` (_string_): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system" (required).
* @param {Number} response_timeout A timeout period for aborting a request in milisecs (0 means no timeout).
*
* @method splunkjs.Service.Entity
*/
acl_update: function(options, response_timeout) {
if(!options.hasOwnProperty("sharing")) {
throw new Error("Required argument 'sharing' is missing.");
}
if(!options.hasOwnProperty("owner")) {
throw new Error("Required argument 'owner' is missing.");
}

return this.post("acl", options, response_timeout).then((res)=>{
return this.fetch({});
});
},

/**
* Retrieves the links information for this entity, which is the URI of
* the entity relative to the management port of a Splunk instance.
Expand Down
Loading