How to use the netlify/src/addons.deleteAddon function in netlify

To help you get started, we’ve selected a few netlify 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 netlify / cli / src / commands / addons / delete.js View on Github external
await this.config.runHook('analytics', {
      eventName: 'command',
      payload: {
        command: 'addons:delete'
      }
    })

    const settings = {
      siteId: siteId,
      addon: addonName,
      instanceId: currentAddon.id
    }
    let addonResponse
    try {
      // TODO update deleteAddon to https://open-api.netlify.com/#/default/deleteServiceInstance
      addonResponse = await deleteAddon(settings, accessToken)
    } catch (e) {
      this.error(e.message)
    }

    if (addonResponse.status === 404) {
      this.log(`No addon "${addonName}" found. Please double check your add-on name and try again`)
      return false
    }

    /* Deleting addons must return with 204 status */
    if (addonResponse.status === 204) {
      this.log(`Addon "${addonName}" deleted`)
    } else {
      this.log(
        `Addon "${addonName}" was not deleted "${addonName}". Returned status: ${addonResponse.status}. Addon deletion must return status 204 from "${addonName}" provider.`
      )