How to use the @heroku-cli/command.APIClient function in @heroku-cli/command

To help you get started, we’ve selected a few @heroku-cli/command 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 heroku / cli / packages / autocomplete / src / hooks / recache.ts View on Github external
const rmKey = (cacheKey: string) => fs.remove(path.join(completionsDir, cacheKey))

  if (type === 'app') return rmKey('app')
  if (type === 'addon' && app) return rmKey(`${app}_addons`)
  if (type === 'config' && app) return rmKey(`${app}_config_vars`)
  if (logInOut) return rm()

  const update = async (completion: any, cacheKey: string) => {
    const cachePath = path.join(completionsDir, cacheKey)
    const options = await completion.options({config: this.config})
    await updateCache(cachePath, options)
  }

  // if user is not logged in, exit
  try {
    const heroku = new APIClient(this.config)
    if (!heroku.auth) return
    await heroku.get('/account', {retryAuth: false})
  } catch (err) {
    this.debug(err.message)
    return
  }

  cli.action.start('Updating completions')
  await rm()
  await acCreate.run([], this.config)

  try {
    await update(AppCompletion, 'app')
    await update(PipelineCompletion, 'pipeline')
    await update(SpaceCompletion, 'space')
    await update(TeamCompletion, 'team')
github heroku / cli / packages / webhooks / src / commands / base.ts View on Github external
protected constructor(argv: string[], config: IConfig) {
    super(argv, config)

    const client = new APIClient(this.config, {})
    client.defaults.headers = {
      ...this.heroku.defaults.headers,
      Accept: 'application/vnd.heroku+json; version=3.webhooks',
      authorization: `Basic ${Buffer.from(':' + this.heroku.auth).toString('base64')}`
    }
    this.webhooksClient = client
  }
github heroku / cli / packages / autocomplete / src / completions.ts View on Github external
options: async (ctx: any) => {
    const heroku = new APIClient(ctx.config)
    if (ctx.flags && ctx.flags.app) {
      let {body: configs} = await heroku.get(`/apps/${ctx.flags.app}/config-vars`, {retryAuth: false})
      return Object.keys(configs)
    }
    return []
  },
}