Sha256: a001af3851e362463c0c36423a279447908eb66504a581d85be3310847f78c7f
Contents?: true
Size: 1.02 KB
Versions: 24
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true module Geet module Gitlab class Label attr_reader :name, :color def initialize(name, color) @name = name @color = color end # Returns a flat list of names in string form. def self.list(api_interface, **) api_path = "projects/#{api_interface.path_with_namespace(encoded: true)}/labels" response = api_interface.send_request(api_path, multipage: true) response.map do |label_entry| name = label_entry.fetch('name') color = label_entry.fetch('color').sub('#', '') # normalize new(name, color) end end # See https://docs.gitlab.com/ee/api/labels.html#create-a-new-label def self.create(name, color, api_interface, **) api_path = "projects/#{api_interface.path_with_namespace(encoded: true)}/labels" request_data = { name: name, color: "##{color}" } api_interface.send_request(api_path, data: request_data) new(name, color) end end end end
Version data entries
24 entries across 24 versions & 1 rubygems