Class: SupportOps::GitLab::Epics

Inherits:
Base
  • Object
show all
Defined in:
lib/support_ops_gitlab/gitlab/epics.rb

Overview

Defines the class Epics within the module SupportOps::GitLab.

Author:

  • Jason Colyer

Since:

  • 1.0.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#activate!, #approve!, attributes, #badges, #ban!, #block!, client, #client=, #commits, configure, #contributors, #create_support_pin!, #deactivate!, define_attributes, #diffs, #disable_2fa!, #discussions, #emails, #encoded_path, #events, #find, #find!, #gpg_keys, #hard_delete!, #impersonations, #initialize, #jobs, #latest_pipeline, #members, #memberships, #merge_requests, #move!, #paid?, #pats, #pipeline_variables, #pipelines, #preferences, #projects, readonly_attributes, #reject!, #revoke!, #rotate!, #ssh_keys, #status, #store_original_attributes, #subscribe!, #support_pin, to_hash, #tokens, #unban!, #unblock!, #unsubscribe!, #webhooks

Constructor Details

This class inherits a constructor from SupportOps::GitLab::Base

Instance Attribute Details

Various links related to the epic

Returns:

  • (Hash)

    the current value of _links



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def _links
  @_links
end

#add_labelsArray

Comma-separated label names to add to an issue

Returns:

  • (Array)

    the current value of add_labels



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def add_labels
  @add_labels
end

#authorHash

Information about the epic author

Returns:

  • (Hash)

    the current value of author



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def author
  @author
end

#closed_atString

When the epic was closed

Returns:

  • (String)

    the current value of closed_at



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def closed_at
  @closed_at
end

#colorString

The color of the epic

Returns:

  • (String)

    the current value of color



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def color
  @color
end

#confidentialBoolean

Whether the epic should be confidential

Returns:

  • (Boolean)

    the current value of confidential



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def confidential
  @confidential
end

#created_atString

When the epic was created

Returns:

  • (String)

    the current value of created_at



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def created_at
  @created_at
end

#descriptionString

The description of the epic

Returns:

  • (String)

    the current value of description



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def description
  @description
end

#downvotesInteger

The number of downvotes on an epic

Returns:

  • (Integer)

    the current value of downvotes



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def downvotes
  @downvotes
end

#due_dateString

When the epic is due

Returns:

  • (String)

    the current value of due_date



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def due_date
  @due_date
end

#due_date_fixedString

The fixed due date of an epic

Returns:

  • (String)

    the current value of due_date_fixed



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def due_date_fixed
  @due_date_fixed
end

#due_date_from_inherited_sourceString

When the epic is due (inherited from the source of the epic)

Returns:

  • (String)

    the current value of due_date_from_inherited_source



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def due_date_from_inherited_source
  @due_date_from_inherited_source
end

#due_date_is_fixedBoolean

Whether due date should be sourced from due_date_fixed or from milestones

Returns:

  • (Boolean)

    the current value of due_date_is_fixed



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def due_date_is_fixed
  @due_date_is_fixed
end

#group_idInteger

The ID of the epic’s group

Returns:

  • (Integer)

    the current value of group_id



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def group_id
  @group_id
end

#idInteger

the ID of the epic

Returns:

  • (Integer)

    the current value of id



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def id
  @id
end

#iidInteger

The internal ID of the epic

Returns:

  • (Integer)

    the current value of iid



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def iid
  @iid
end

#importedBoolean

If the epic was imported

Returns:

  • (Boolean)

    the current value of imported



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def imported
  @imported
end

#imported_fromString

Where the epic was imported from

Returns:

  • (String)

    the current value of imported_from



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def imported_from
  @imported_from
end

#labelsArray

The comma-separated list of labels

Returns:

  • (Array)

    the current value of labels



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def labels
  @labels
end

#parent_idInteger

The ID of a parent epic

Returns:

  • (Integer)

    the current value of parent_id



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def parent_id
  @parent_id
end

#parent_iidInteger

The internal ID of a parent epic

Returns:

  • (Integer)

    the current value of parent_iid



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def parent_iid
  @parent_iid
end

#referenceString

The reference tag for the epic

Returns:

  • (String)

    the current value of reference



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def reference
  @reference
end

#referencesHash

Reference tags for the epic

Returns:

  • (Hash)

    the current value of references



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def references
  @references
end

#remove_labelsArray

Comma-separated label names to remove from an issue

Returns:

  • (Array)

    the current value of remove_labels



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def remove_labels
  @remove_labels
end

#start_dateString

The start date of the epic

Returns:

  • (String)

    the current value of start_date



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def start_date
  @start_date
end

#start_date_fixedString

The fixed start date of an epic

Returns:

  • (String)

    the current value of start_date_fixed



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def start_date_fixed
  @start_date_fixed
end

#start_date_from_inherited_sourceString

The start date of the epic (inherited from the source of the epic)

Returns:

  • (String)

    the current value of start_date_from_inherited_source



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def start_date_from_inherited_source
  @start_date_from_inherited_source
end

#start_date_is_fixedBoolean

Whether start date should be sourced from start_date_fixed or from milestones

Returns:

  • (Boolean)

    the current value of start_date_is_fixed



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def start_date_is_fixed
  @start_date_is_fixed
end

#stateString

The current state of the epic

Returns:

  • (String)

    the current value of state



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def state
  @state
end

#state_eventString

State event for an epic; Set ‘close’ to close the epic and ‘reopen’ to reopen it

Returns:

  • (String)

    the current value of state_event



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def state_event
  @state_event
end

#subscribedBoolean

If the authenticated user is subscribed to the epic

Returns:

  • (Boolean)

    the current value of subscribed



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def subscribed
  @subscribed
end

#titleString

The title of the epic

Returns:

  • (String)

    the current value of title



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def title
  @title
end

#updated_atString

When the epic was updated

Returns:

  • (String)

    the current value of updated_at



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def updated_at
  @updated_at
end

#upvotesInteger

The number of upvotes on an epic

Returns:

  • (Integer)

    the current value of upvotes



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def upvotes
  @upvotes
end

#web_urlString

The URL of the epic

Returns:

  • (String)

    the current value of web_url



49
50
51
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 49

def web_url
  @web_url
end

Class Method Details

.list(key: value) ⇒ Array

Lists all epics keys for a group

Examples:

require 'support_ops_gitlab'

SupportOps::GitLab::Configuration.configure do |config|
  config.url = 'https://gitlab.example.com/api/v4'
  config.token = 'abc123'
end

epics = SupportOps::GitLab::Epics.list(group_id: 123456)
pp epics.count
# => 30
pp epics.last.due_date
# => "2018-07-31"

Parameters:

  • group_id (Integer required)

    The group ID to get the epics from

  • author_id (Integer optional)

    Return epics created by the given user id

  • author_username (String optional)

    Return epics created by the user with the given username

  • labels (String optional)

    Return epics matching a comma-separated list of labels names

  • order_by (String optional)

    Return epics ordered by created_at, updated_at, or title fields

  • sort (String optional)

    Return epics sorted in asc or desc order

  • search (String optional)

    Search epics against their title and description

  • state (String optional)

    Search epics against their state, possible filters: opened, closed, and all

  • created_after (String optional)

    Return epics created on or after the given time; expected in ISO 8601 format (2019-03-15T08:00:00Z)

  • created_before (String optional)

    Return epics created on or before the given time; expected in ISO 8601 format (2019-03-15T08:00:00Z)

  • updated_after (String optional)

    Return epics updated on or after the given time; expected in ISO 8601 format (2019-03-15T08:00:00Z)

  • updated_before (String optional)

    Return epics updated on or before the given time; expected in ISO 8601 format (2019-03-15T08:00:00Z)

  • include_ancestor_groups (xxx optional)

    Include epics from the requested group’s ancestors

  • include_descendant_groups (xxx optional)

    Include epics from the requested group’s descendants

  • my_reaction_emoji (String optional)

    Return epics reacted by the authenticated user by the given emoj

Returns:

  • (Array)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 226

def self.list(**args)
  args[:group_id] = nil unless args[:group_id]
  raise 'You have to provide a group_id' if args[:group_id].nil?
  args[:author_id] = nil unless args[:author_id]
  args[:author_username] = nil unless args[:author_username]
  args[:labels] = nil unless args[:labels]
  args[:order_by] = nil unless args[:order_by]
  args[:sort] = nil unless args[:sort]
  args[:search] = nil unless args[:search]
  args[:state] = nil unless args[:state]
  args[:created_after] = nil unless args[:created_after]
  args[:created_before] = nil unless args[:created_before]
  args[:updated_after] = nil unless args[:updated_after]
  args[:updated_before] = nil unless args[:updated_before]
  args[:include_ancestor_groups] = nil unless args[:include_ancestor_groups]
  args[:include_descendant_groups] = nil unless args[:include_descendant_groups]
  args[:my_reaction_emoji] = nil unless args[:my_reaction_emoji]
  params = ''
  params += "active=#{args[:active]}&" unless args[:active].nil?
  params += "author_id=#{args[:author_id]}&" unless args[:author_id].nil?
  params += "author_username=#{args[:author_username]}&" unless args[:author_username].nil?
  params += "labels=#{args[:labels]}&" unless args[:labels].nil?
  params += "order_by=#{args[:order_by]}&" unless args[:order_by].nil?
  params += "sort=#{args[:sort]}&" unless args[:sort].nil?
  params += "search=#{args[:search]}&" unless args[:search].nil?
  params += "state=#{args[:state]}&" unless args[:state].nil?
  params += "created_after=#{args[:created_after]}&" unless args[:created_after].nil?
  params += "created_before=#{args[:created_before]}&" unless args[:created_before].nil?
  params += "updated_after=#{args[:updated_after]}&" unless args[:updated_after].nil?
  params += "updated_before=#{args[:updated_before]}&" unless args[:updated_before].nil?
  params += "include_ancestor_groups=#{args[:include_ancestor_groups]}&" unless args[:include_ancestor_groups].nil?
  params += "include_descendant_groups=#{args[:include_descendant_groups]}&" unless args[:include_descendant_groups].nil?
  params += "my_reaction_emoji=#{args[:my_reaction_emoji]}&" unless args[:my_reaction_emoji].nil?
  array = []
  page = 1
  loop do
    response = client.connection.get("groups/#{args[:group_id]}/epics?#{params}&page=#{page}&per_page=100")
    body = Oj.load(response.body)
    array += body.map { |e| Epics.new(e) }
    break if body.count < 100

    page += 1
  end
  array
end

Instance Method Details

#delete!Boolean

Note:

This is inherited from Base#delete!

Deletes an epic

Examples:

require 'support_ops_gitlab'

SupportOps::GitLab::Configuration.configure do |config|
  config.token = ENV.fetch('GL_TOKEN')
  config.url = 'https://gitlab.com/api/v4'
end

epics = SupportOps::GitLab::Epics.list(group_id: 1)
existing_epic = epics.detect { |e| e.id == 33 }
existing_epic.delete!

Returns:

  • (Boolean)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



21
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 21

def delete!; end

#issuesBoolean

Note:

This is inherited from Base#issues

List issues on an epic

Examples:

require 'support_ops_gitlab'

SupportOps::GitLab::Configuration.configure do |config|
  config.token = ENV.fetch('GL_TOKEN')
  config.url = 'https://gitlab.com/api/v4'
end

epics = SupportOps::GitLab::Epics.list(group_id: 1)
existing_epic = epics.detect { |e| e.id == 33 }
issues = existing_epic.issues
pp issues.count
# => 6

Returns:

  • (Boolean)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



23
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 23

def issues; end

#notesBoolean

Note:

This is inherited from Base#notes

List notes on an epic

Examples:

require 'support_ops_gitlab'

SupportOps::GitLab::Configuration.configure do |config|
  config.token = ENV.fetch('GL_TOKEN')
  config.url = 'https://gitlab.com/api/v4'
end

epics = SupportOps::GitLab::Epics.list(group_id: 1)
existing_epic = epics.detect { |e| e.id == 33 }
notes = existing_epic.notes
pp notes.count
# => 3

Returns:

  • (Boolean)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



23
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 23

def notes; end

#save!Object

Note:

This is inherited from Base#save!

Creates/updates an epic

Examples:

require 'support_ops_gitlab'

SupportOps::GitLab::Configuration.configure do |config|
  config.token = ENV.fetch('GL_TOKEN')
  config.url = 'https://gitlab.com/api/v4'
end

new_epic = SupportOps::GitLab::Epics.new
new_epic.title = 'Epic'
new_epic.description = 'Epic description'
new_epic.parent_id = 29
new_epic.group_id = 1

new_epic.save!

pp new_epic.id
# => 33
require 'support_ops_gitlab'

SupportOps::GitLab::Configuration.configure do |config|
  config.token = ENV.fetch('GL_TOKEN')
  config.url = 'https://gitlab.com/api/v4'
end

epics = SupportOps::GitLab::Epics.list(group_id: 1)
existing_epic = epics.detect { |e| e.id == 33 }
existing_epic.title = 'Epic v2'

existing_epic.save!

pp existing_epic.title
# => "Epic v2"

Returns:

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



47
# File 'lib/support_ops_gitlab/gitlab/epics.rb', line 47

def save!; end