Skip to content

Release/2.0.0 #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 58 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4235212
code refactor
akaila-splunk Jun 27, 2022
3d29152
Update http.js
akaila-splunk Jul 5, 2022
27c389c
Update context.js
akaila-splunk Jul 5, 2022
e398c2d
Update service.js
akaila-splunk Jul 5, 2022
18e2f92
Update service.js
akaila-splunk Jul 5, 2022
4d6a05f
Update service.js
akaila-splunk Jul 12, 2022
a523a50
Promise refractoring
ashah-splunk Aug 2, 2022
0e19ed4
promise refactor changes
ashah-splunk Aug 4, 2022
2d8e4d2
Test cases updated with Async/await
ashah-splunk Aug 5, 2022
c231ff4
refactor crud func. methods
akaila-splunk Aug 8, 2022
dfe4c01
browser test cases updated.
ashah-splunk Aug 9, 2022
9a3fb7b
code refactoring
ashah-splunk Aug 9, 2022
14a09ef
Update endpoint.js
ashah-splunk Aug 9, 2022
9e1c203
update methods comment and example
akaila-splunk Aug 12, 2022
c4ee9e6
Update proxy_http.js
akaila-splunk Aug 17, 2022
8d6a651
testcase refactor
akaila-splunk Aug 30, 2022
c54ed14
Update test_utils.js
ashah-splunk Aug 30, 2022
13db35a
review updates
ashah-splunk Sep 19, 2022
8bb498a
Update browser.test.entry.js
ashah-splunk Sep 19, 2022
e640a36
merge updates from develop branch
ashah-splunk Sep 20, 2022
a565176
added acl_update method
akaila-splunk Oct 6, 2022
8e8de19
added test cases for acl_update method
akaila-splunk Oct 6, 2022
53e7dab
updated compiled files
ashah-splunk Oct 6, 2022
7ac1dfc
Update release.yml
akaila-splunk Oct 7, 2022
0b2722a
Update release.yml
akaila-splunk Oct 7, 2022
9c2633e
refactor browser side testcases
akaila-splunk Oct 11, 2022
882af21
updated compile files
ashah-splunk Oct 11, 2022
271c275
conflict resolve
ashah-splunk Oct 12, 2022
507f2f8
compiled files conflict resolve
ashah-splunk Oct 12, 2022
804c828
Revert "conflict resolve"
ashah-splunk Oct 12, 2022
6f73da3
Revert "compiled files conflict resolve"
ashah-splunk Oct 12, 2022
b6b17a8
conflict resolve
ashah-splunk Oct 12, 2022
dc131cc
Merge branch 'develop' into callback-promises-migration
ashah-splunk Oct 12, 2022
750f32d
compiled files
ashah-splunk Oct 12, 2022
a3388b5
Update package-lock.json
ashah-splunk Oct 12, 2022
c281e53
README changes
ashah-splunk Oct 14, 2022
479d8a1
Merge pull request #166 from splunk/minimist-upgrade
ashah-splunk Oct 27, 2022
770730f
Merge pull request #167 from splunk/doc-generation-update
ashah-splunk Oct 28, 2022
cd9e97c
replace statuscode with 504
akaila-splunk Oct 31, 2022
6b7d83b
compiled files
ashah-splunk Oct 31, 2022
122ba74
Update CHANGELOG.md
akaila-splunk Oct 31, 2022
4465c19
update browser-side abort timeout
akaila-splunk Nov 2, 2022
e7aa58d
compiled files
ashah-splunk Nov 2, 2022
1fdb749
Merge pull request #162 from splunk/callback-promises-migration
akaila-splunk Nov 15, 2022
c115bd6
Merge branch 'develop' into DVPL-11649
ashah-splunk Nov 18, 2022
2956b57
Merge branch 'master' into sync-with-master
ashah-splunk Nov 18, 2022
dc563be
compiled files updated
ashah-splunk Nov 18, 2022
e82b602
Merge pull request #169 from splunk/sync-with-master
ashah-splunk Nov 18, 2022
b2a6efd
Merge branch 'develop' into DVPL-11649
ashah-splunk Nov 18, 2022
3d66ed0
compile files updated
ashah-splunk Nov 21, 2022
9d7404e
Update index.js
ashah-splunk Nov 23, 2022
79e5f7d
Merge pull request #170 from splunk/DVPL-11649
ashah-splunk Dec 2, 2022
a27dfd1
Create or Replace feature for StoragePasswords
ashah-splunk Dec 2, 2022
812cc52
Merge pull request #171 from splunk/support-refactored-examples
ashah-splunk Jan 23, 2023
6117e6c
version 2.0.0 release changes
akaila-splunk Jan 27, 2023
a6c1ceb
updated compiled files
ashah-splunk Jan 27, 2023
a16d8bd
added promise example in README.md file
akaila-splunk Jan 30, 2023
16a71a8
Update README.md
akaila-splunk Jan 31, 2023
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
8 changes: 3 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ jobs:
id: pkgjson

- name: Generate docs
run: |
node sdkdo docs
zip -r docs.zip docs-${{ steps.pkgjson.outputs.packageVersion }}
run: node sdkdo docs

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: apidocs
path: docs.zip
name: js_sdk_docs
path: docs-${{ steps.pkgjson.outputs.packageVersion }}/
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Splunk Enterprise SDK for JavaScript Changelog

## v2.0.0

### New features and APIs
* Callbacks have been removed and instead we are returning Promises which enables users to use Async/Await features of JS. ([PR#162](https://github.com/splunk/splunk-sdk-javascript/pull/162))
* Added 'response_timeout' parameter which enables user to specify the timeout for a particular API call.
* Removed Async.js file and the required methods have been migrated to Utils.js following the Promise structure.

### Minor changes
* Update doc generation logic in GitHub ci ([PR#167](https://github.com/splunk/splunk-sdk-javascript/pull/167))
* Updated minimist library versions ([PR#166](https://github.com/splunk/splunk-sdk-javascript/pull/166))
* Added feature that allows to update ACL properties of an entity ([PR#170](https://github.com/splunk/splunk-sdk-javascript/pull/170))
* Support for updated SDK examples ([PR#171](https://github.com/splunk/splunk-sdk-javascript/pull/171))

## v1.12.1

### Minor changes
Expand Down
187 changes: 99 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Build Status](https://travis-ci.org/splunk/splunk-sdk-javascript.svg?branch=master)](https://travis-ci.org/splunk/splunk-sdk-javascript)
# The Splunk Enterprise Software Development Kit for JavaScript

#### Version 1.12.1
#### Version 2.0.0

The Splunk Enterprise Software Development Kit (SDK) for JavaScript contains library code and examples designed to enable developers to build applications using the Splunk platform and JavaScript. This SDK supports server-side and client-side JavaScript.

Expand Down Expand Up @@ -52,12 +52,44 @@ To use the Splunk Enterprise SDK for JavaScript with your Node.js programs, inst

Then, to include the Splunk Enterprise SDK for JavaScript, use the `require` function in your code:

var splunkjs = require('splunk-sdk');
let splunkjs = require('splunk-sdk');

## Usage

The following examples show you how to list search jobs using client-side and server-side code.

### Migrate from Callbacks(v1.x) to Promise/async-await(v2.x)

Previous Callback Approach:
```javascript
let appName = "<app-name>";

service.apps().fetch(function (err, apps) {
if (err) {
done(err);
}
let appList = apps.list();
// other code
done();
});
```

From v2.x, Splunk Enterprise SDK for JavaScript methods are updated to return Promises, which will enable users to utilize Async/await feature of JS.

Promise Approach:
```javascript
let appName = "<app-name>";
try {
let apps = await service.apps().fetch();
let appList = apps.list();
// other code
} catch (err) {
console.log("There was an error retrieving the list of applications:", err);
}
```

>**Note**: `abort()` method has been replaced with 'response_timeout' parameter which enables user to specify the timeout for a particular API call.

### Client-side code example

This HTML example uses the Splunk Enterprise SDK for JavaScript to list all jobs:
Expand All @@ -66,22 +98,18 @@ This HTML example uses the Splunk Enterprise SDK for JavaScript to list all jobs
<script type="text/javascript" src="jquery.min.js"></script>

<script type="text/javascript" charset="utf-8">

var service = new splunkjs.Service({username: "admin", password: "changed!"});
service.login(function(err, success) {
if (err) {
throw err;
try {
let service = new splunkjs.Service({username: "admin", password: "changed!"});
await service.login();
console.log("Login was successful");
let jobs = await service.jobs().fetch();
let jobList = jobs.list();
for(let i = 0; i < jobList.length; i++) {
console.log("Job " + i + ": " + jobList[i].sid);
}

console.log("Login was successful: " + success);
service.jobs().fetch(function(err, jobs) {
var jobList = jobs.list();
for(var i = 0; i < jobList.length; i++) {
console.log("Job " + i + ": " + jobList[i].sid);
}
});
});

} catch(err) {
console.log(err);
}
</script>
```

Expand All @@ -92,22 +120,21 @@ This example shows how to use the Splunk Enterprise SDK for JavaScript and Node.
##### Login with username and password

```javascript
var splunkjs = require('splunk-sdk');

var service = new splunkjs.Service({username: "admin", password: "changed!"});
service.login(function(err, success) {
if (err) {
throw err;
}
let splunkjs = require('splunk-sdk');

let service = new splunkjs.Service({username: "admin", password: "changed!"});
try {
await service.login();
console.log("Login was successful: " + success);
service.jobs().fetch(function(err, jobs) {
var jobList = jobs.list();
for(var i = 0; i < jobList.length; i++) {
console.log("Job " + i + ": " + jobList[i].sid);
}
});
});
let jobs = await jobs.fetch();
let jobList = jobs.list();
for(let i = 0; i < jobList.length; i++) {
console.log("Job " + i + ": " + jobList[i].sid);
}
} catch(err) {
console.log(err);
}

```
##### Login with sessionKey

Expand All @@ -117,24 +144,20 @@ curl -k -u <username>:<password> <scheme>://<host>:<port>/services/auth/login -
```

```javascript
var serviceWithSessionKey = new splunkjs.Service(
{
// Replace the host if you are accessing remote host
scheme: 'https',
host: 'localhost',
port: '8089',
sessionKey: SESSION_KEY, // Add your sessionKey here
version: '9.0',
});

serviceWithSessionKey.get("search/jobs", { count: 1 }, function (err, res) {
if (err) {
console.log(err);
} else }
console.log("Login successful with sessionKey");
}
let serviceWithSessionKey = new splunkjs.Service({
// Replace the host if you are accessing remote host
scheme: 'https',
host: 'localhost',
port: '8089',
sessionKey: SESSION_KEY, // Add your sessionKey here
version: '9.0',
});
```
try {
let jobs = await serviceWithSessionKey.jobs({ count: 1 });
console.log("Login successful with sessionKey");
} catch(err) {
console.log(err);
}

##### Login with token

Expand All @@ -159,22 +182,21 @@ Go to settings > Tokens and click on 'Enable Token Authentication'
```

```javascript
var serviceWithBearerToken = new splunkjs.Service(
{
// Replace the host if you are accessing remote host
scheme: 'https',
host: 'localhost',
port: '8089',
sessionKey: TOKEN, // Add your token here
version: '8',
});

serviceWithBearerToken.get("search/jobs", { count: 2 }, function (err, res) {
if (err)
console.log(err);
else
console.log("Login successful with bearer token");
let serviceWithBearerToken = new splunkjs.Service({
// Replace the host if you are accessing remote host
scheme: 'https',
host: 'localhost',
port: '8089',
sessionKey: TOKEN, // Add your token here
version: '8',
});
try {
let res = await serviceWithBearerToken.jobs({ count: 2 });
console.log("Login successful with bearer token");
} catch(err) {
console.log(err);
}

```

### Modular inputs examples
Expand Down Expand Up @@ -224,29 +246,18 @@ Save the file as **.splunkrc** in the current user's home directory.

### Create/Update a .conf file
```javascript

Async.chain([
function (done) {
// Fetch configurations
var configs = svc.configurations(namespace);
configs.fetch(done);
},
async function (configs, done) {
// Create a key-value map to store under a stanza
const filename = "app.conf";
const stanzaName = "install";
var keyValueMap = {}
keyValueMap["state"] = "enabled";
keyValueMap["python.version"] = "python3";

// If file/stanza doesn't exist, it will be created
// else it will be updated.
configs.createAsync(filename, stanzaName, keyValueMap, done);
}
],
function (err) {
done();
});
let configs = svc.configurations(namespace);
configs = await configs.fetch();
// Create a key-value map to store under a stanza
const filename = "app.conf";
const stanzaName = "install";
let keyValueMap = {};
keyValueMap["state"] = "enabled";
keyValueMap["python.version"] = "python3";

// If file/stanza doesn't exist, it will be created
// else it will be updated.
await configs.createAsync(filename, stanzaName, keyValueMap);
```

## Development
Expand Down Expand Up @@ -276,9 +287,9 @@ To run all tests, enter:

node sdkdo tests

To run the HTTP and the Async tests, enter:
To run the HTTP and the utils tests, enter:

node sdkdo tests http,async
node sdkdo tests http,utils

To run tests containing a particular string, enter:

Expand Down
Loading