Class: Readiness::GitLab::Groups

Inherits:
Client
  • Object
show all
Defined in:
lib/support_readiness/gitlab/groups.rb

Overview

TODO:

Anything listed on docs.gitlab.com/ee/api/groups.html not currently here

Defines the class Groups within the module Readiness::GitLab.

Author:

  • Jason Colyer

Since:

  • 1.0.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Client

auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries

Constructor Details

#initialize(object = {}) ⇒ Groups

Creates a new Readiness::GitLab::Groups instance

Examples:

require 'support_readiness'
group = Readiness::GitLab::Groups.new

Parameters:

Author:

  • Jason Colyer

Since:

  • 1.0.0



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/support_readiness/gitlab/groups.rb', line 25

def initialize(object = {})
  @allowed_email_domains_list = object['allowed_email_domains_list']
  @auto_devops_enabled = object['auto_devops_enabled']
  @avatar_url = object['avatar_url']
  @default_branch = object['default_branch']
  @default_branch_protection = object['default_branch_protection']
  @default_branch_protection_defaults = object['default_branch_protection_defaults']
  @description = object['description']
  @duo_features_enabled = object['duo_features_enabled']
  @emails_disabled = object['emails_disabled']
  @emails_enabled = object['emails_enabled']
  @extra_shared_runners_minutes_limit = object['extra_shared_runners_minutes_limit']
  @full_name = object['full_name']
  @full_path = object['full_path']
  @id = object['id']
  @ip_restriction_ranges = object['ip_restriction_ranges']
  @ldap_access = object['ldap_access']
  @ldap_cn = object['ldap_cn']
  @lfs_enabled = object['lfs_enabled']
  @lock_duo_features_enabled = object['lock_duo_features_enabled']
  @lock_math_rendering_limits_enabled = object['lock_math_rendering_limits_enabled']
  @marked_for_deletion_on = object['marked_for_deletion_on']
  @math_rendering_limits_enabled = object['math_rendering_limits_enabled']
  @membership_lock = object['membership_lock']
  @mentions_disabled = object['mentions_disabled']
  @name = object['name']
  @organization_id = object['organization_id']
  @parent_id = object['parent_id']
  @path = object['path']
  @prevent_forking_outside_group = object['prevent_forking_outside_group']
  @project_creation_level = object['project_creation_level']
  @repository_storage = object['repository_storage']
  @request_access_enabled = object['request_access_enabled']
  @require_two_factor_authentication = object['require_two_factor_authentication']
  @runners_token = object['runners_token']
  @shared_runners_minutes_limit = object['shared_runners_minutes_limit']
  @shared_runners_setting = object['shared_runners_setting']
  @shared_with_groups = object['shared_with_groups']
  @share_with_group_lock = object['share_with_group_lock']
  @subgroup_creation_level = object['subgroup_creation_level']
  @two_factor_grace_period = object['two_factor_grace_period']
  @visibility = object['visibility']
  @web_url = object['web_url']
  @wiki_access_level = object['wiki_access_level']
end

Instance Attribute Details

#allowed_email_domains_listObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def allowed_email_domains_list
  @allowed_email_domains_list
end

#auto_devops_enabledObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def auto_devops_enabled
  @auto_devops_enabled
end

#avatar_urlObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def avatar_url
  @avatar_url
end

#default_branchObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def default_branch
  @default_branch
end

#default_branch_protectionObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def default_branch_protection
  @default_branch_protection
end

#default_branch_protection_defaultsObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def default_branch_protection_defaults
  @default_branch_protection_defaults
end

#descriptionObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def description
  @description
end

#duo_features_enabledObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def duo_features_enabled
  @duo_features_enabled
end

#emails_disabledObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def emails_disabled
  @emails_disabled
end

#emails_enabledObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def emails_enabled
  @emails_enabled
end

#extra_shared_runners_minutes_limitObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def extra_shared_runners_minutes_limit
  @extra_shared_runners_minutes_limit
end

#full_nameObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def full_name
  @full_name
end

#full_pathObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def full_path
  @full_path
end

#idObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def id
  @id
end

#ip_restriction_rangesObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def ip_restriction_ranges
  @ip_restriction_ranges
end

#ldap_accessObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def ldap_access
  @ldap_access
end

#ldap_cnObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def ldap_cn
  @ldap_cn
end

#lfs_enabledObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def lfs_enabled
  @lfs_enabled
end

#lock_duo_features_enabledObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def lock_duo_features_enabled
  @lock_duo_features_enabled
end

#lock_math_rendering_limits_enabledObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def lock_math_rendering_limits_enabled
  @lock_math_rendering_limits_enabled
end

#marked_for_deletion_onObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def marked_for_deletion_on
  @marked_for_deletion_on
end

#math_rendering_limits_enabledObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def math_rendering_limits_enabled
  @math_rendering_limits_enabled
end

#membership_lockObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def membership_lock
  @membership_lock
end

#mentions_disabledObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def mentions_disabled
  @mentions_disabled
end

#nameObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def name
  @name
end

#organization_idObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def organization_id
  @organization_id
end

#parent_idObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def parent_id
  @parent_id
end

#pathObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def path
  @path
end

#prevent_forking_outside_groupObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def prevent_forking_outside_group
  @prevent_forking_outside_group
end

#project_creation_levelObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def project_creation_level
  @project_creation_level
end

#repository_storageObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def repository_storage
  @repository_storage
end

#request_access_enabledObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def request_access_enabled
  @request_access_enabled
end

#require_two_factor_authenticationObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def require_two_factor_authentication
  @require_two_factor_authentication
end

#runners_tokenObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def runners_token
  @runners_token
end

#share_with_group_lockObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def share_with_group_lock
  @share_with_group_lock
end

#shared_runners_minutes_limitObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def shared_runners_minutes_limit
  @shared_runners_minutes_limit
end

#shared_runners_settingObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def shared_runners_setting
  @shared_runners_setting
end

#shared_with_groupsObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def shared_with_groups
  @shared_with_groups
end

#subgroup_creation_levelObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def subgroup_creation_level
  @subgroup_creation_level
end

#two_factor_grace_periodObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def two_factor_grace_period
  @two_factor_grace_period
end

#visibilityObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def visibility
  @visibility
end

#web_urlObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def web_url
  @web_url
end

#wiki_access_levelObject

Since:

  • 1.0.0



14
15
16
# File 'lib/support_readiness/gitlab/groups.rb', line 14

def wiki_access_level
  @wiki_access_level
end

Class Method Details

.all_members(client, group, filters = []) ⇒ Array

Lists all members in a group. This method can take a long time to run depending on the parameters used.

Examples:

require 'support_readiness'
config = Readiness::GitLab::Configuration.new
config.token = 'test123abc'
client = Readiness::GitLab::Client.new(config)
group = Readiness::GitLab::Groups.new
group.id = 1
members = Readiness::GitLab::Groups.all_members(client, group, ["query=jcolyer"])
puts members.first['username']
# => "jcolyer"

Parameters:

  • client (Object)

    An instance of Client

  • group (Object)

    An instance of Readiness::GitLab::Groups

  • filters (Array) (defaults to: [])

    An array of filter Strings to use. Should be in the format of key=value

Returns:

  • (Array)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/support_readiness/gitlab/groups.rb', line 164

def self.all_members(client, group, filters = [])
  array = []
  page = 1
  loop do
    response = client.connection.get "groups/#{group.id}/members/all?per_page=100&page=#{page}&#{to_param_string(filters)}"
    handle_request_error(0, 'GitLab', response.status) unless response.status == 200
    body = Oj.load(response.body)
    array += body
    break if body.count < 100

    page += 1
  end
  array
end

.members(client, group, filters = []) ⇒ Array

Lists direct members in a group. This method can take a long time to run depending on the parameters used.

Examples:

require 'support_readiness'
config = Readiness::GitLab::Configuration.new
config.token = 'test123abc'
client = Readiness::GitLab::Client.new(config)
group = Readiness::GitLab::Groups.new
group.id = 1
members = Readiness::GitLab::Groups.members(client, group, ["query=jcolyer"])
puts members.first['username']
# => "jcolyer-123"

Parameters:

  • client (Object)

    An instance of Client

  • group (Object)

    An instance of Readiness::GitLab::Groups

  • filters (Array) (defaults to: [])

    An array of filter Strings to use. Should be in the format of key=value

Returns:

  • (Array)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/support_readiness/gitlab/groups.rb', line 128

def self.members(client, group, filters = [])
  array = []
  page = 1
  loop do
    response = client.connection.get "groups/#{group.id}/members?per_page=100&page=#{page}&#{to_param_string(filters)}"
    handle_request_error(0, 'GitLab', response.status) unless response.status == 200
    body = Oj.load(response.body)
    array += body
    break if body.count < 100

    page += 1
  end
  array
end

.milestones(client, group, filters = []) ⇒ Array

Lists all milestones in a group. This method can take a long time to run depending on the parameters used.

Examples:

require 'support_readiness'
config = Readiness::GitLab::Configuration.new
config.token = 'test123abc'
client = Readiness::GitLab::Client.new(config)
group = Readiness::GitLab::Groups.find!(client, 1083469)
milestones = Readiness::GitLab::Groups.milestones(client, project)
pp milestones.count
# => 25

Parameters:

  • client (Object)

    An instance of Client

  • group (Object)

    An instance of Readiness::GitLab::Groups

  • filters (Array) (defaults to: [])

    An array of filter Strings to use. Should be in the format of key=value

Returns:

  • (Array)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.12



199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/support_readiness/gitlab/groups.rb', line 199

def self.milestones(client, group, filters = [])
  array = []
  page = 1
  loop do
    response = client.connection.get "groups/#{group.id}/milestones?per_page=100&page=#{page}&#{to_param_string(filters)}"
    handle_request_error(0, 'GitLab', response.status) unless response.status == 200
    body = Oj.load(response.body)
    array += body
    break if body.count < 100

    page += 1
  end
  array
end

.projects(client, group, filters = []) ⇒ Array

Lists projects in a group. This method can take a long time to run depending on the parameters used.

Examples:

require 'support_readiness'
config = Readiness::GitLab::Configuration.new
config.token = 'test123abc'
client = Readiness::GitLab::Client.new(config)
group = Readiness::GitLab::Groups.new
group.id = 1
projects = Readiness::GitLab::Groups.projects(client, group, ["archived=false", "include_subgroups=true"])
puts projects.first.web_url
# => "https://gitlab.com/gitlab-com/support/support-team-meta"

Parameters:

  • client (Object)

    An instance of Client

  • group (Object)

    An instance of Readiness::GitLab::Groups

  • filters (Array) (defaults to: [])

    An array of filter Strings to use. Should be in the format of key=value

Returns:

  • (Array)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/support_readiness/gitlab/groups.rb', line 92

def self.projects(client, group, filters = [])
  array = []
  page = 1
  loop do
    response = client.connection.get "groups/#{group.id}/projects?per_page=100&page=#{page}&#{to_param_string(filters)}"
    handle_request_error(0, 'GitLab', response.status) unless response.status == 200
    body = Oj.load(response.body)
    array += body.map { |p| Projects.new(p) }
    break if body.count < 100

    page += 1
  end
  array
end