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, #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:

  • the current value of _links



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

def _links
  @_links
end

#add_labels ⇒ Array

Comma-separated label names to add to an issue

Returns:

  • 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

#author ⇒ Hash

Information about the epic author

Returns:

  • the current value of author



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

def author
  @author
end

#closed_at ⇒ String

When the epic was closed

Returns:

  • 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

#color ⇒ String

The color of the epic

Returns:

  • the current value of color



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

def color
  @color
end

#confidential ⇒ Boolean

Whether the epic should be confidential

Returns:

  • the current value of confidential



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

def confidential
  @confidential
end

#created_at ⇒ String

When the epic was created

Returns:

  • 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

#description ⇒ String

The description of the epic

Returns:

  • the current value of description



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

def description
  @description
end

#downvotes ⇒ Integer

The number of downvotes on an epic

Returns:

  • the current value of downvotes



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

def downvotes
  @downvotes
end

#due_date ⇒ String

When the epic is due

Returns:

  • 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_fixed ⇒ String

The fixed due date of an epic

Returns:

  • 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_source ⇒ String

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

Returns:

  • 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_fixed ⇒ Boolean

Whether due date should be sourced from due_date_fixed or from milestones

Returns:

  • 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_id ⇒ Integer

The ID of the epic's group

Returns:

  • 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

#id ⇒ Integer

the ID of the epic

Returns:

  • the current value of id



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

def id
  @id
end

#iid ⇒ Integer

The internal ID of the epic

Returns:

  • the current value of iid



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

def iid
  @iid
end

#imported ⇒ Boolean

If the epic was imported

Returns:

  • the current value of imported



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

def imported
  @imported
end

#imported_from ⇒ String

Where the epic was imported from

Returns:

  • 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

#labels ⇒ Array

The comma-separated list of labels

Returns:

  • the current value of labels



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

def labels
  @labels
end

#parent_id ⇒ Integer

The ID of a parent epic

Returns:

  • 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_iid ⇒ Integer

The internal ID of a parent epic

Returns:

  • 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

#reference ⇒ String

The reference tag for the epic

Returns:

  • the current value of reference



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

def reference
  @reference
end

#references ⇒ Hash

Reference tags for the epic

Returns:

  • the current value of references



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

def references
  @references
end

#remove_labels ⇒ Array

Comma-separated label names to remove from an issue

Returns:

  • 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_date ⇒ String

The start date of the epic

Returns:

  • 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_fixed ⇒ String

The fixed start date of an epic

Returns:

  • 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_source ⇒ String

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

Returns:

  • 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_fixed ⇒ Boolean

Whether start date should be sourced from start_date_fixed or from milestones

Returns:

  • 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

#state ⇒ String

The current state of the epic

Returns:

  • the current value of state



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

def state
  @state
end

#state_event ⇒ String

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

Returns:

  • 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

#subscribed ⇒ Boolean

If the authenticated user is subscribed to the epic

Returns:

  • the current value of subscribed



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

def subscribed
  @subscribed
end

#title ⇒ String

The title of the epic

Returns:

  • the current value of title



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

def title
  @title
end

#updated_at ⇒ String

When the epic was updated

Returns:

  • 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

#upvotes ⇒ Integer

The number of upvotes on an epic

Returns:

  • the current value of upvotes



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

def upvotes
  @upvotes
end

#web_url ⇒ String

The URL of the epic

Returns:

  • 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:

  • The group ID to get the epics from

  • Return epics created by the given user id

  • Return epics created by the user with the given username

  • Return epics matching a comma-separated list of labels names

  • Return epics ordered by created_at, updated_at, or title fields

  • Return epics sorted in asc or desc order

  • Search epics against their title and description

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

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

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

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

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

  • Include epics from the requested group’s ancestors

  • Include epics from the requested group’s descendants

  • Return epics reacted by the authenticated user by the given emoj

Returns:

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:

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



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

def delete!; end

#issues ⇒ Boolean

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:

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



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

def issues; end

#notes ⇒ Boolean

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:

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