diff options
Diffstat (limited to 'lib/api/environments.rb')
-rw-r--r-- | lib/api/environments.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/api/environments.rb b/lib/api/environments.rb index 19b48c1e3cf..11f1cab0c72 100644 --- a/lib/api/environments.rb +++ b/lib/api/environments.rb @@ -8,6 +8,7 @@ module API before { authenticate! } feature_category :continuous_delivery + urgency :low params do requires :id, type: String, desc: 'The project ID' @@ -29,6 +30,8 @@ module API environments = ::Environments::EnvironmentsFinder.new(user_project, current_user, params).execute present paginate(environments), with: Entities::Environment, current_user: current_user + rescue ::Environments::EnvironmentsFinder::InvalidStatesError => exception + bad_request!(exception.message) end desc 'Creates a new environment' do @@ -39,6 +42,7 @@ module API requires :name, type: String, desc: 'The name of the environment to be created' optional :external_url, type: String, desc: 'URL on which this deployment is viewable' optional :slug, absence: { message: "is automatically generated and cannot be changed" } + optional :tier, type: String, values: Environment.tiers.keys, desc: 'The tier of the environment to be created' end post ':id/environments' do authorize! :create_environment, user_project @@ -62,13 +66,14 @@ module API optional :name, type: String, desc: 'DEPRECATED: Renaming environment can lead to errors, this will be removed in 15.0' optional :external_url, type: String, desc: 'The new URL on which this deployment is viewable' optional :slug, absence: { message: "is automatically generated and cannot be changed" } + optional :tier, type: String, values: Environment.tiers.keys, desc: 'The tier of the environment to be created' end put ':id/environments/:environment_id' do authorize! :update_environment, user_project environment = user_project.environments.find(params[:environment_id]) - update_params = declared_params(include_missing: false).extract!(:name, :external_url) + update_params = declared_params(include_missing: false).extract!(:name, :external_url, :tier) if environment.update(update_params) present environment, with: Entities::Environment, current_user: current_user else |