mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-12 07:52:46 +00:00
50 lines
1.3 KiB
CoffeeScript
50 lines
1.3 KiB
CoffeeScript
pine = require('./_pine')
|
|
errors = require('../errors/errors')
|
|
|
|
# Get all environment variables by application
|
|
#
|
|
# @param {String, Number} applicationId application id
|
|
# @param {Function} callback callback(error, environmentVariables)
|
|
#
|
|
# @throw {NotFound} Will throw if no environment variable was found
|
|
#
|
|
# @example Get all environment variables by application
|
|
# resin.models.environmentVariables.getAll (error, environmentVariables) ->
|
|
# throw error if error?
|
|
# console.log(environmentVariables)
|
|
#
|
|
exports.getAllByApplication = (applicationId, callback) ->
|
|
return pine.get
|
|
resource: 'environment_variable'
|
|
options:
|
|
filter:
|
|
application: applicationId
|
|
orderby: 'name asc'
|
|
|
|
.then (environmentVariables) ->
|
|
if not environmentVariables?
|
|
return callback(new errors.NotFound('environment variables'))
|
|
|
|
return callback(null, environmentVariables)
|
|
|
|
.catch (error) ->
|
|
return callback(error)
|
|
|
|
# Remove environment variable
|
|
#
|
|
# @param {String, Number} id environment variable id
|
|
# @param {Function} callback callback(error)
|
|
#
|
|
# @example Remove environment variable
|
|
# resin.models.environmentVariables.remove 51, (error) ->
|
|
# throw error if error?
|
|
#
|
|
exports.remove = (id, callback) ->
|
|
return pine.delete
|
|
resource: 'environment_variable'
|
|
id: id
|
|
.then ->
|
|
return callback()
|
|
.catch (error) ->
|
|
return callback(error)
|