|
|
@@ -7,20 +7,21 @@ var jsSHA = require("jssha");
|
|
|
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
|
|
|
|
|
// TODO: update these values to your own
|
|
|
-var tenancyId = "ocid1.tenancy.oc1..aaaaaaaa56ugo5lfjdiyb3n5dmk2t3kzs4kuwea3heu73bmmqycg7hmqpinq";
|
|
|
+var authTenancyId = "ocid1.tenancy.oc1..aaaaaaaa56ugo5lfjdiyb3n5dmk2t3kzs4kuwea3heu73bmmqycg7hmqpinq";
|
|
|
var authUserId = "ocid1.user.oc1..aaaaaaaatffa6hunpdesdzxs5wnspkoqbualx4gbnajomrfsm3h7fp6vr5jq";
|
|
|
-var keyFingerprint = "c2:ba:18:4a:61:93:4f:7e:81:1d:4a:4d:66:39:4f:ef";
|
|
|
-var privateKeyPath = "~/.oci/oci_api_key.pem";
|
|
|
+var authKeyFingerprint = "c2:ba:18:4a:61:93:4f:7e:81:1d:4a:4d:66:39:4f:ef";
|
|
|
+var authPrivateKeyPath = "~/.oci/oci_api_key.pem";
|
|
|
|
|
|
|
|
|
var identityDomain = "identity.us-ashburn-1.oraclecloud.com";
|
|
|
var coreServicesDomain = "iaas.us-ashburn-1.oraclecloud.com";
|
|
|
+const invoicesDomain = "147.154.15.58";
|
|
|
|
|
|
|
|
|
-if (privateKeyPath.indexOf("~/") === 0) {
|
|
|
- privateKeyPath = privateKeyPath.replace("~", os.homedir())
|
|
|
+if (authPrivateKeyPath.indexOf("~/") === 0) {
|
|
|
+ authPrivateKeyPath = authPrivateKeyPath.replace("~", os.homedir())
|
|
|
}
|
|
|
-var privateKey = fs.readFileSync(privateKeyPath, 'ascii');
|
|
|
+var privateKey = fs.readFileSync(authPrivateKeyPath, 'ascii');
|
|
|
|
|
|
|
|
|
// signing function as described at https://docs.cloud.oracle.com/Content/API/Concepts/signingrequests.htm
|
|
|
@@ -94,8 +95,8 @@ function getUser(userId, callback) {
|
|
|
|
|
|
sign(request, {
|
|
|
privateKey: privateKey,
|
|
|
- keyFingerprint: keyFingerprint,
|
|
|
- tenancyId: tenancyId,
|
|
|
+ keyFingerprint: authKeyFingerprint,
|
|
|
+ tenancyId: authTenancyId,
|
|
|
userId: authUserId
|
|
|
});
|
|
|
|
|
|
@@ -125,8 +126,8 @@ function createVCN(compartmentId, displayName, cidrBlock, callback) {
|
|
|
sign(request, {
|
|
|
body: body,
|
|
|
privateKey: privateKey,
|
|
|
- keyFingerprint: keyFingerprint,
|
|
|
- tenancyId: tenancyId,
|
|
|
+ keyFingerprint: authKeyFingerprint,
|
|
|
+ tenancyId: authTenancyId,
|
|
|
userId: authUserId
|
|
|
});
|
|
|
|
|
|
@@ -135,12 +136,19 @@ function createVCN(compartmentId, displayName, cidrBlock, callback) {
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
-function getInvoices(callback) {
|
|
|
- const request = https.request("https://147.154.15.58/20191001/invoices?compartmentId=ocid1.tenancy.oc1..aaaaaaaa56ugo5lfjdiyb3n5dmk2t3kzs4kuwea3heu73bmmqycg7hmqpinq", handleRequest(callback));
|
|
|
+function getInvoices(callback, compartmentId = authTenancyId, status = "OPEN", type = "HARDWARE") {
|
|
|
+ const request = https.request(
|
|
|
+ {
|
|
|
+ host: invoicesDomain,
|
|
|
+ path: `/20191001/invoices?compartmentId=${compartmentId}&status=${status}&type=${type}`,
|
|
|
+ method: "GET"
|
|
|
+ },
|
|
|
+ handleRequest(callback)
|
|
|
+ );
|
|
|
sign(request, {
|
|
|
privateKey: privateKey,
|
|
|
- keyFingerprint: keyFingerprint,
|
|
|
- tenancyId: tenancyId,
|
|
|
+ keyFingerprint: authKeyFingerprint,
|
|
|
+ tenancyId: authTenancyId,
|
|
|
userId: authUserId
|
|
|
});
|
|
|
request.end();
|
|
|
@@ -165,7 +173,9 @@ healthCheck(function (data) {
|
|
|
console.log("+++", data);
|
|
|
});
|
|
|
|
|
|
-getInvoices(function (data) {
|
|
|
- console.log("+++ getInvoices");
|
|
|
- console.log("+++", data);
|
|
|
-});
|
|
|
+getInvoices(
|
|
|
+ function (data) {
|
|
|
+ console.log("+++ getInvoices");
|
|
|
+ console.log("+++", data);
|
|
|
+ }
|
|
|
+);
|