How to use @clevercloud/client - 10 common examples

To help you get started, we’ve selected a few @clevercloud/client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CleverCloud / clever-tools / src / models / log.js View on Github external
function getOldLogs (appId, beforeDate, afterDate, filter, deployment_id) {

  const limit = (beforeDate == null && afterDate == null) ? 300 : null;
  const before = (beforeDate != null) ? beforeDate.toISOString() : null;
  const after = (afterDate != null) ? afterDate.toISOString() : null;

  const logsProm = fetchOldLogs({ appId, limit, before, after, filter, deployment_id }).then(sendToApi);

  return Bacon.fromPromise(logsProm)
    .flatMapLatest((logs) => Bacon.fromArray(logs.reverse()));
};
github CleverCloud / clever-tools / src / commands / status.js View on Github external
async function status (params) {
  const { alias } = params.options;
  const { org_id, app_id: appId } = await AppConfig.getAppData(alias).toPromise();

  const instances = await getAllInstances({ id: org_id, appId }).then(sendToApi);
  const app = await getApplication({ id: org_id, appId }).then(sendToApi);

  Logger.println(computeStatus(instances, app));
  Logger.println(displayScalability(app));
}
github CleverCloud / clever-tools / src / models / application.js View on Github external
async function setDedicatedBuildInstance (appId, orgaId, enableSeparateBuild) {
  const app = await application.get({ id: orgaId, appId }).then(sendToApi);
  const newConfig = { ...app, separateBuild: enableSeparateBuild };
  return application.update({ id: orgaId, appId }, newConfig).then(sendToApi);
};
github CleverCloud / clever-tools / src / models / application.js View on Github external
async function setScalability (appId, orgaId, scalabilityParameters) {
  Logger.info('Scaling the app: ' + appId);

  const app = await application.get({ id: orgaId, appId }).then(sendToApi);
  const instance = _.cloneDeep(app.instance);

  instance.minFlavor = instance.minFlavor.name;
  instance.maxFlavor = instance.maxFlavor.name;

  const newConfig = mergeScalabilityParameters(scalabilityParameters, instance);

  return application.update({ id: orgaId, appId }, newConfig).then(sendToApi);
};
github CleverCloud / clever-tools / src / models / organisation.js View on Github external
async function getByNameProm (name) {

  const fullSummary = await getSummary({}).then(sendToApi);
  const filteredOrgs = _.filter(fullSummary.organisations, { name });

  if (filteredOrgs.length === 0) {
    throw new Error('Organisation not found');
  }
  if (filteredOrgs.length > 1) {
    throw new Error('Ambiguous organisation name');
  }

  return filteredOrgs[0];
}
github CleverCloud / clever-tools / src / models / application.js View on Github external
async function setDedicatedBuildInstance (appId, orgaId, enableSeparateBuild) {
  const app = await application.get({ id: orgaId, appId }).then(sendToApi);
  const newConfig = { ...app, separateBuild: enableSeparateBuild };
  return application.update({ id: orgaId, appId }, newConfig).then(sendToApi);
};
github CleverCloud / clever-tools / src / models / application.js View on Github external
async function setScalability (appId, orgaId, scalabilityParameters) {
  Logger.info('Scaling the app: ' + appId);

  const app = await application.get({ id: orgaId, appId }).then(sendToApi);
  const instance = _.cloneDeep(app.instance);

  instance.minFlavor = instance.minFlavor.name;
  instance.maxFlavor = instance.maxFlavor.name;

  const newConfig = mergeScalabilityParameters(scalabilityParameters, instance);

  return application.update({ id: orgaId, appId }, newConfig).then(sendToApi);
};
github CleverCloud / clever-tools / src / commands / drain.js View on Github external
async function enable (params) {
  const [drainId] = params.args;
  const { alias } = params.options;

  const { app_id: appId } = await AppConfig.getAppData(alias).toPromise();
  await updateDrainState({ appId, drainId }, { state: 'ENABLED' }).then(sendToApi);

  Logger.println('Your drain has been enabled');
}
github CleverCloud / clever-tools / src / commands / drain.js View on Github external
async function disable (params) {
  const [drainId] = params.args;
  const { alias } = params.options;

  const { app_id: appId } = await AppConfig.getAppData(alias).toPromise();
  await updateDrainState({ appId, drainId }, { state: 'DISABLED' }).then(sendToApi);

  Logger.println('Your drain has been disabled');
}
github CleverCloud / clever-tools / src / models / user.js View on Github external
function getCurrent () {
  return get({}).then(sendToApi);
};