Class: SupportOps::GitLab::Milestones

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

Overview

TODO:
TODO:

Document #save! (create/update)

TODO:

Document #delete!

TODO:

Document issues

TODO:

Document merge_requests

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

Author:

  • Jason Colyer

Since:

  • 1.0.0

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Base

#activate!, #approve!, attributes, #badges, #ban!, #block!, client, #client=, #commits, configure, #contributors, #create_support_pin!, #deactivate!, define_attributes, #delete!, #diffs, #disable_2fa!, #discussions, #emails, #encoded_path, #events, #find, #find!, #gpg_keys, #hard_delete!, #impersonations, #initialize, #issues, #jobs, #latest_pipeline, #members, #memberships, #merge_requests, #move!, #notes, #paid?, #pats, #pipeline_variables, #pipelines, #preferences, #projects, readonly_attributes, #reject!, #revoke!, #rotate!, #save!, #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

#add_labelsArray

Comma-separated label names to add to an issue

Returns:

  • (Array)

    the current value of add_labels



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def add_labels
  @add_labels
end

#created_atString

The date the milestone was created at

Returns:

  • (String)

    the current value of created_at



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def created_at
  @created_at
end

#descriptionString

The description of the milestone

Returns:

  • (String)

    the current value of description



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def description
  @description
end

#due_dateString

The date the milestone is due

Returns:

  • (String)

    the current value of due_date



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def due_date
  @due_date
end

#expiredBoolean

If the milestone is expired or not

Returns:

  • (Boolean)

    the current value of expired



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def expired
  @expired
end

#group_idInteger

the ID of the group the milestone is in

Returns:

  • (Integer)

    the current value of group_id



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def group_id
  @group_id
end

#idInteger

The ID of the group milestone

Returns:

  • (Integer)

    the current value of id



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def id
  @id
end

#iidInteger

The internal ID of the milestone

Returns:

  • (Integer)

    the current value of iid



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def iid
  @iid
end

#start_dateString

The date the milestone starts on

Returns:

  • (String)

    the current value of start_date



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def start_date
  @start_date
end

#stateString

The current state of the milestone

Returns:

  • (String)

    the current value of state



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def state
  @state
end

#state_eventString

The state event of the milestone, close or activate (used for updated only)

Returns:

  • (String)

    the current value of state_event



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def state_event
  @state_event
end

#titleString

The title of the milestone

Returns:

  • (String)

    the current value of title



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def title
  @title
end

#updated_atString

The date the milestone was last updated

Returns:

  • (String)

    the current value of updated_at



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def updated_at
  @updated_at
end

#web_urlString

The URL of the milestone

Returns:

  • (String)

    the current value of web_url



32
33
34
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 32

def web_url
  @web_url
end

Class Method Details

.list(key: value) ⇒ Array

Lists all milestones 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

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

Parameters:

  • group_id (Integer required)

    The group to look within

  • end_date (String optional)

    Return only milestones where start_date <= the provided end_date

  • containing_date (String optional)

    Return only milestones where start_date <= containing_date <= due_date

  • iids (Array optional)

    Return only the milestones having the given iid

  • include_ancestors (xxx optional)

    Include milestones for all parent groups

  • include_descendants (xxx optional)

    Include milestones for group and its descendants

  • search (String optional)

    Return only milestones with a title or description matching the provided string (case-insensitive)

  • search_title (xxx optional)

    Return only milestones with a title matching the provided string (case-insensitive); multiple terms can be provided, separated by an escaped space, either + or %20, and will be ANDed together; example: 17.4+17.5 will match substrings 17.4 and 17.5 (in any order)

  • start_date (String optional)

    Return only milestones where due_date >= the provided start_date

  • state (String optional)

    Return only active or closed milestones

  • title (String optional)

    Return only the milestones having the given title (case-sensitive)

  • updated_after (String optional)

    Return only milestones updated after the given datetime

  • updated_before (String optional)

    Return only milestones updated before the given datetime

Returns:

  • (Array)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/support_ops_gitlab/gitlab/milestones.rb', line 90

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[:group_id] = nil unless args[:group_id]
  args[:end_date] = nil unless args[:end_date]
  args[:containing_date] = nil unless args[:containing_date]
  args[:iids] = nil unless args[:iids]
  args[:include_ancestors] = nil unless args[:include_ancestors]
  args[:include_descendants] = nil unless args[:include_descendants]
  args[:search] = nil unless args[:search]
  args[:search_title] = nil unless args[:search_title]
  args[:start_date] = nil unless args[:start_date]
  args[:state] = nil unless args[:state]
  args[:title] = nil unless args[:title]
  args[:updated_after] = nil unless args[:updated_after]
  args[:updated_before] = nil unless args[:updated_before]
  params = ''
  params += "end_date=#{args[:end_date]}&" unless args[:end_date].nil?
  params += "containing_date=#{args[:containing_date]}&" unless args[:containing_date].nil?
  params += "iids=#{args[:iids]}&" unless args[:iids].nil?
  params += "include_ancestors=#{args[:include_ancestors]}&" unless args[:include_ancestors].nil?
  params += "include_descendants=#{args[:include_descendants]}&" unless args[:include_descendants].nil?
  params += "search=#{args[:search]}&" unless args[:search].nil?
  params += "search_title=#{args[:search_title]}&" unless args[:search_title].nil?
  params += "start_date=#{args[:start_date]}&" unless args[:start_date].nil?
  params += "state=#{args[:state]}&" unless args[:state].nil?
  params += "title=#{args[:title]}&" unless args[:title].nil?
  params += "updated_after=#{args[:updated_after]}&" unless args[:updated_after].nil?
  params += "updated_before=#{args[:updated_before]}&" unless args[:updated_before].nil?
  array = []
  page = 1
  loop do
    response = client.connection.get("groups/#{args[:group_id]}/milestones?#{params}&page=#{page}&per_page=100")
    body = Oj.load(response.body)
    array += body.map { |m| Milestones.new(m) }
    break if body.count < 100

    page += 1
  end
  array
end