This repository has been archived by the owner on Dec 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
110 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
// Copyright (c) 2019 Alex Williams, Unscramble <[email protected]> | ||
// MIT Licensed | ||
var createHash, createHmac, formData, needle, options, settings; | ||
var createHash, createHmac, formData, fs, needle, options, settings; | ||
|
||
createHash = require('crypto').createHash; | ||
|
||
|
@@ -14,6 +14,13 @@ | |
|
||
formData = require('form-data'); | ||
|
||
fs = require('fs'); | ||
|
||
needle.defaults({ | ||
user_agent: 'nodeclient-on-prem-meta/1.1.0', | ||
response_timeout: 10000 // 10 seconds | ||
}); | ||
|
||
exports.makeSHA256 = function(string) { | ||
return createHash('sha256').update(string).digest('hex'); | ||
}; | ||
|
@@ -42,11 +49,6 @@ | |
|
||
exports.options = options; | ||
|
||
needle.defaults({ | ||
user_agent: 'nodeclient-on-prem-meta/1.0.5', | ||
response_timeout: 10000 // 10 seconds | ||
}); | ||
|
||
exports.buildRequest = function(params = { | ||
method: 'GET', | ||
endpoint: 'version' | ||
|
@@ -97,4 +99,36 @@ | |
}); | ||
}; | ||
|
||
// returns a callback with an error in arg1, or the builddate in arg2 | ||
// the error is an Error object if non-HTTP related | ||
// the error is the request result if 404 or other HTTP error code (4xx or 5xx) | ||
exports.buildOVA = (application, parameters, callback) => { | ||
var apiParams; | ||
apiParams = { | ||
method: 'POST', | ||
endpoint: 'builds', | ||
files: { | ||
app: { | ||
filename: 'app.tcz', | ||
data: fs.readFileSync(application) | ||
} | ||
}, | ||
query: parameters | ||
}; | ||
return this.buildRequest(apiParams, (error, result) => { | ||
if (error) { | ||
callback(error); | ||
} | ||
return this.apiCall(result, function(err, res, data) { | ||
if (err) { | ||
return callback(new Error(err)); | ||
} else if (res.statusCode === 202 && res.statusMessage === 'Accepted') { | ||
return callback(null, data.builddate); | ||
} else { | ||
return callback(data); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
}).call(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"description": "Official On-Prem Meta REST API client and helper library", | ||
"author": "Alexander Williams, Unscramble <[email protected]>", | ||
"name": "@on-prem/on-prem-meta", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
"homepage": "https://on-premises.com", | ||
"main": "lib/on-prem-meta.js", | ||
|
@@ -36,7 +36,7 @@ | |
"url": "https://github.com/on-prem/on-prem-meta-node/issues" | ||
}, | ||
"engines": { | ||
"node": ">=12" | ||
"node": ">=8" | ||
}, | ||
"directories": { | ||
"lib": "lib", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters