prosociallearnEU / cf-nodejs-client

A Cloud Foundry Client for Node.js
https://prosociallearneu.github.io/cf-nodejs-client/
Apache License 2.0
17 stars 41 forks source link

How to use cf-nodejs-client to control the start and stop of hana cloud #199

Open aiddren opened 1 year ago

aiddren commented 1 year ago

dear support team

We use cf-nodejs-client to control the start and stop of hana cloud db, but an error occurred. How can I fix this error? Does cf-nodejs-client have the feature of controlling hana cloud db?

source code: "use-strict"; const cron = require("node-cron"); const endpoint = "https://api.cf.jp10.hana.ondemand.com"; const username = "XXXXX"; const password = "XXXXX";

const CloudController = new (require("cf-nodejs-client")).CloudController(endpoint); const UsersUAA = new (require("cf-nodejs-client")).UsersUAA; const ServiceInstances = new (require("cf-nodejs-client")).ServiceInstances(endpoint);

controlTarget(ServiceInstances, "stop", name, id);

function controlTarget(target, operation, name, id) { CloudController.getInfo().then((result) => { UsersUAA.setEndPoint(result.authorization_endpoint); return UsersUAA.login(username, password); }).then((result) => { target.setToken(result); return target.stop(id); }).then((result) => { console.log(result); }).catch((reason) => { console.log("catch block: " + reason); }); };

error:

"description": "Service broker error: Service broker hana-cloud failed with: Internal error [ref 2TJgeT5Gp5ZblIEXLjSoSbzN4ko]", "error_code": "CF-ServiceBrokerRequestRejected", "code": 10001, "http": { "method": "PATCH", "status": 422 } }