Sha256: 82ad9e091caccabd29d570a4b8aca281b8821f85c662446bb3902b1bf668bd49

Contents?: true

Size: 1.75 KB

Versions: 23

Compression:

Stored size: 1.75 KB

Contents

# frozen_string_literal: true

class Gitlab::Client
  # Defines methods related to feature flags.
  # https://docs.gitlab.com/ce/api/features.html
  module Features
    # Get a list of all persisted features, with its gate values.
    #
    # @example
    #   Gitlab.features
    #
    # @return [Array<Gitlab::ObjectifiedHash>]
    def features
      get('/features')
    end

    # Set a features gate value.
    # If a feature with the given name does not exist yet it will be created. The value can be a boolean, or an integer to indicate percentage of time.
    #
    # @example
    #   Gitlab.set_feature('new_library', true)
    #   Gitlab.set_feature('new_library', 8)
    #   Gitlab.set_feature('new_library', true, {user: 'gitlab'})
    #
    # @param  [String] name(required) Name of the feature to create or update
    # @param  [String, Integer] value(required) true or false to enable/disable, or an integer for percentage of time
    # @param  [Hash] options A customizable set of options.
    # @option options [String] :feature_group(optional) A Feature group name
    # @option options [String] :user(optional) A GitLab username
    # @option options [String] :project(optional) A projects path, for example "gitlab-org/gitlab-ce"
    # @return [Gitlab::ObjectifiedHash] Information about the set/created/updated feature.
    def set_feature(name, value, options = {})
      body = { value: value }.merge(options)
      post("/features/#{name}", body: body)
    end

    # Delete a feature.
    #
    # @example
    #   Gitlab.delete_feature('new_library')
    #
    # @param  [String] name Name of the feature to delete
    # @return [void] This API call returns an empty response body.
    def delete_feature(name)
      delete("/features/#{name}")
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
gitlab-5.1.0 lib/gitlab/client/features.rb
gitlab-5.0.0 lib/gitlab/client/features.rb
gitlab-4.20.1 lib/gitlab/client/features.rb
gitlab-4.20.0 lib/gitlab/client/features.rb
fs-gitlab-4.19.3 lib/gitlab/client/features.rb
fs-gitlab-4.19.2 lib/gitlab/client/features.rb
fs-gitlab-4.19.1 lib/gitlab/client/features.rb
gitlab-4.19.0 lib/gitlab/client/features.rb
fs-gitlab-4.18.2 lib/gitlab/client/features.rb
fs-gitlab-4.18.1 lib/gitlab/client/features.rb
gitlab-4.18.0 lib/gitlab/client/features.rb
gitlab-4.17.0 lib/gitlab/client/features.rb
gitlab-4.16.1 lib/gitlab/client/features.rb
gitlab-4.16.0 lib/gitlab/client/features.rb
gitlab-4.15.0 lib/gitlab/client/features.rb
gitlab-4.14.1 lib/gitlab/client/features.rb
gitlab-4.14.0 lib/gitlab/client/features.rb
gitlab-4.13.1 lib/gitlab/client/features.rb
gitlab-4.13.0 lib/gitlab/client/features.rb
gitlab-4.12.0 lib/gitlab/client/features.rb