Welcome to mirror list, hosted at ThFree Co, Russian Federation.

settings.rb « api « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c4cb1c7924ab534fdd6b16f49a7ff2b794f13fdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module API
  class Settings < Grape::API
    before { authenticated_as_admin! }

    helpers do
      def current_settings
        @current_setting ||=
          (ApplicationSetting.current || ApplicationSetting.create_from_defaults)
      end
    end

    # Get current applicaiton settings
    #
    # Example Request:
    #   GET /application/settings
    get "application/settings" do
      present current_settings, with: Entities::ApplicationSetting
    end

    # Modify application settings
    #
    # Example Request:
    #   PUT /application/settings
    put "application/settings" do
      attributes = ["repository_storage"] + current_settings.attributes.keys - ["id"]
      attrs = attributes_for_keys(attributes)

      if current_settings.update_attributes(attrs)
        present current_settings, with: Entities::ApplicationSetting
      else
        render_validation_error!(current_settings)
      end
    end
  end
end