Module: Gitlab::Client::Groups

Included in:
Gitlab::Client
Defined in:
lib/gitlab/client/groups.rb

Overview

Defines methods related to groups.

Instance Method Summary collapse

Instance Method Details

#add_group_custom_attribute(key, value, group_id) ⇒ Gitlab::ObjectifiedHash

Creates a new custom_attribute

Examples:

Gitlab.add_custom_attribute('some_new_key', 'some_new_value', 2)

Parameters:

  • key (String)

    The custom_attributes key

  • value (String)

    The custom_attributes value

  • group_id (Integer)

    The ID of a group.

Returns:



340
341
342
343
# File 'lib/gitlab/client/groups.rb', line 340

def add_group_custom_attribute(key, value, group_id)
  url = "/groups/#{group_id}/custom_attributes/#{key}"
  put(url, body: { value: value })
end

#add_group_hook(group_id, url, options = {}) ⇒ Gitlab::ObjectifiedHash

Add a new group hook

Examples:

Gitlab.add_group_hook(3, "https://example.com/my-hook-receiver", {token: "verify me"})

Parameters:

  • group_id (Integer)

    The ID of a group.

  • the (String)

    hook url which will receive the selected events

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :name (Boolean)

    The name of the group.

  • :push_events (Boolean)

    Trigger hook on push events

  • :issues_events (Boolean)

    Trigger hook on issues events

  • :confidential_issues_events (Boolean)

    Trigger hook on confidential issues events

  • :merge_requests_events (Boolean)

    Trigger hook on merge requests events

  • :tag_push_events (Boolean)

    Trigger hook on tag push events

  • :note_events (Boolean)

    Trigger hook on note events

  • :confidential_note_events (Boolean)

    Trigger hook on confidential note events

  • :job_events (Boolean)

    Trigger hook on job events

  • :pipeline_events (Boolean)

    Trigger hook on pipeline events

  • :wiki_page_events (Boolean)

    Trigger hook on wiki page events

  • :deployment_events (Boolean)

    Trigger hook on deployment events

  • :releases_events (Boolean)

    Trigger hook on release events

  • :subgroup_events (Boolean)

    Trigger hook on subgroup events

  • :enable_ssl_verification (Boolean)

    Do SSL verification when triggering the hook

  • :token (String)

    Secret token to validate received payloads; not returned in the response

Returns:



406
407
408
# File 'lib/gitlab/client/groups.rb', line 406

def add_group_hook(group_id, url, options = {})
  post("/groups/#{group_id}/hooks", body: options.merge(url: url))
end

#add_group_member(team_id, user_id, access_level) ⇒ Gitlab::ObjectifiedHash

Adds a user to group.

Examples:

Gitlab.add_group_member(1, 2, 40)

Parameters:

  • team_id (Integer)

    The group id to add a member to.

  • user_id (Integer)

    The user id of the user to add to the team.

  • access_level (Integer)

    Project access level.

Returns:



156
157
158
# File 'lib/gitlab/client/groups.rb', line 156

def add_group_member(team_id, user_id, access_level)
  post("/groups/#{url_encode team_id}/members", body: { user_id: user_id, access_level: access_level })
end

Add LDAP group link

Examples:

Gitlab.add_ldap_group_links(1, 'all', 50, 'ldap')

Parameters:

  • id (Integer)

    The ID of a group

  • cn (String)

    The CN of a LDAP group

  • group_access (Integer)

    Minimum access level for members of the LDAP group.

  • provider (String)

    LDAP provider for the LDAP group

Returns:



292
293
294
# File 'lib/gitlab/client/groups.rb', line 292

def add_ldap_group_links(id, commonname, group_access, provider)
  post("/groups/#{url_encode id}/ldap_group_links", body: { cn: commonname, group_access: group_access, provider: provider })
end

#all_group_members(id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of all group members including inherited members.

Examples:

Gitlab.all_group_members(1)
Gitlab.all_group_members(1, { per_page: 40 })

Parameters:

  • id (Integer)

    The ID of a group.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:



85
86
87
# File 'lib/gitlab/client/groups.rb', line 85

def all_group_members(id, options = {})
  get("/groups/#{url_encode id}/members/all", query: options)
end

#create_group(name, path, options = {}) ⇒ Gitlab::ObjectifiedHash

Creates a new group.

Examples:

Gitlab.create_group('new-group', 'group-path')
Gitlab.create_group('gitlab', 'gitlab-path', { description: 'New Gitlab project' })

Parameters:

  • name (String)

    The name of a group.

  • path (String)

    The path of a group.

Returns:



44
45
46
47
# File 'lib/gitlab/client/groups.rb', line 44

def create_group(name, path, options = {})
  body = { name: name, path: path }.merge(options)
  post('/groups', body: body)
end

#delete_group(id) ⇒ Gitlab::ObjectifiedHash

Delete’s a group.

Examples:

Gitlab.delete_group(42)

Parameters:

  • id (Integer)

    The ID of a group

Returns:



55
56
57
# File 'lib/gitlab/client/groups.rb', line 55

def delete_group(id)
  delete("/groups/#{url_encode id}")
end

#delete_group_custom_attribute(key, group_id = nil) ⇒ Boolean

Delete custom_attribute Will delete a custom_attribute

Examples:

Gitlab.delete_group_custom_attribute('somekey', 2)

Parameters:

  • key (String)

    The custom_attribute key to delete

  • group_id (Integer) (defaults to: nil)

    The ID of a group.

Returns:

  • (Boolean)


354
355
356
# File 'lib/gitlab/client/groups.rb', line 354

def delete_group_custom_attribute(key, group_id = nil)
  delete("/groups/#{group_id}/custom_attributes/#{key}")
end

#delete_group_hook(group_id, hook_id) ⇒ Gitlab::ObjectifiedHash

Delete a group hook

Examples:

Gitlab.delete_group_hook(3, 1)

Parameters:

  • group_id (Integer)

    The ID of a group.

  • hook_id (Integer)

    The ID of a group.

Returns:



448
449
450
# File 'lib/gitlab/client/groups.rb', line 448

def delete_group_hook(group_id, hook_id)
  delete("/groups/#{group_id}/hooks/#{hook_id}")
end

Delete LDAP group link

Examples:

Gitlab.delete_ldap_group_links(1, 'all')

Parameters:

  • id (Integer)

    The ID of a group

  • cn (String)

    The CN of a LDAP group

Returns:



304
305
306
# File 'lib/gitlab/client/groups.rb', line 304

def delete_ldap_group_links(id, commonname, provider)
  delete("/groups/#{url_encode id}/ldap_group_links/#{url_encode provider}/#{url_encode commonname}")
end

#edit_group(id, options = {}) ⇒ Gitlab::ObjectifiedHash

Updates an existing group.

Examples:

Gitlab.edit_group(42)
Gitlab.edit_group(42, { name: 'Group Name' })

Parameters:

  • group (Integer)

    The ID.

  • options (Hash) (defaults to: {})

    A customizable set of options

Options Hash (options):

  • :name (String)

    The name of the group.

  • :path (String)

    The path of the group.

  • :description (String)

    The description of the group.

  • :visibility (String)

    The visibility level of the group. Can be private, internal, or public

  • :lfs_enabled (String)

    Enable/disable Large File Storage (LFS) for the projects in this groupr.

  • :request_access_enabled (String)

    Allow users to request member access.

Returns:



255
256
257
# File 'lib/gitlab/client/groups.rb', line 255

def edit_group(id, options = {})
  put("/groups/#{url_encode id}", body: options)
end

#edit_group_hook(group_id, hook_id, url, options = {}) ⇒ Gitlab::ObjectifiedHash

Edit a group hook

Examples:

Gitlab.edit_group_hook(3, 1, "https://example.com/my-hook-receiver", {token: "verify me"})

Parameters:

  • group_id (Integer)

    The ID of a group.

  • hook_id (Integer)

    The ID of a group.

  • the (String)

    hook url which will receive the selected events

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :name (Boolean)

    The name of the group.

  • :push_events (Boolean)

    Trigger hook on push events

  • :issues_events (Boolean)

    Trigger hook on issues events

  • :confidential_issues_events (Boolean)

    Trigger hook on confidential issues events

  • :merge_requests_events (Boolean)

    Trigger hook on merge requests events

  • :tag_push_events (Boolean)

    Trigger hook on tag push events

  • :note_events (Boolean)

    Trigger hook on note events

  • :confidential_note_events (Boolean)

    Trigger hook on confidential note events

  • :job_events (Boolean)

    Trigger hook on job events

  • :pipeline_events (Boolean)

    Trigger hook on pipeline events

  • :wiki_page_events (Boolean)

    Trigger hook on wiki page events

  • :deployment_events (Boolean)

    Trigger hook on deployment events

  • :releases_events (Boolean)

    Trigger hook on release events

  • :subgroup_events (Boolean)

    Trigger hook on subgroup events

  • :enable_ssl_verification (Boolean)

    Do SSL verification when triggering the hook

  • :token (String)

    Secret token to validate received payloads; not returned in the response

Returns:



436
437
438
# File 'lib/gitlab/client/groups.rb', line 436

def edit_group_hook(group_id, hook_id, url, options = {})
  post("/groups/#{group_id}/hooks/#{hook_id}", body: options.merge(url: url))
end

#edit_group_member(team_id, user_id, access_level) ⇒ Gitlab::ObjectifiedHash

Edit a user of a group.

Examples:

Gitlab.edit_group_member(1, 2, 40)

Parameters:

  • team_id (Integer)

    The group id of member to edit.

  • user_id (Integer)

    The user id of the user to edit.

  • access_level (Integer)

    Project access level.

Returns:



169
170
171
# File 'lib/gitlab/client/groups.rb', line 169

def edit_group_member(team_id, user_id, access_level)
  put("/groups/#{url_encode team_id}/members/#{user_id}", body: { access_level: access_level })
end

#group(id, options = {}) ⇒ Gitlab::ObjectifiedHash

Gets a single group.

Examples:

Gitlab.group(42)

Parameters:

  • id (Integer)

    The ID of a group.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :with_custom_attributes (Boolean)

    Include custom attributes in response (admins only)

  • :with_projects (Boolean)

    Include details about group projects (default: true)

Returns:



31
32
33
# File 'lib/gitlab/client/groups.rb', line 31

def group(id, options = {})
  get("/groups/#{url_encode id}", query: options)
end

#group_billable_members(id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Get a list of group members that are billable.

Examples:

Gitlab.group_billable_members(1)
Gitlab.group_billable_members(1, { per_page: 40 })

Parameters:

  • id (Integer)

    The ID of a group.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:



119
120
121
# File 'lib/gitlab/client/groups.rb', line 119

def group_billable_members(id, options = {})
  get("/groups/#{url_encode id}/billable_members", query: options)
end

#group_custom_attribute(key, group_id) ⇒ Gitlab::ObjectifiedHash

Gets single group custom_attribute.

Examples:

Gitlab.group_custom_attribute('key', 2)

Parameters:

  • key (String)

    The custom_attributes key

  • group_id (Integer)

    The ID of a group.

Returns:



327
328
329
# File 'lib/gitlab/client/groups.rb', line 327

def group_custom_attribute(key, group_id)
  get("/groups/#{group_id}/custom_attributes/#{key}")
end

#group_custom_attributes(group_id) ⇒ Gitlab::ObjectifiedHash

Gets group custom_attributes.

Examples:

Gitlab.group_custom_attributes(2)

Parameters:

  • group_id (Integer)

    The ID of a group.

Returns:



315
316
317
# File 'lib/gitlab/client/groups.rb', line 315

def group_custom_attributes(group_id)
  get("/groups/#{group_id}/custom_attributes")
end

#group_descendants(id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Get a list of descendant groups of a group.

Examples:

Gitlab.group_descendants(42)

Parameters:

  • id (Integer)

    the ID of a group

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :skip_groups (String)

    Skip the group IDs passed.

  • :all_available (String)

    Show all the groups you have access to (defaults to false for authenticated users).

  • :search (String)

    Return the list of authorized groups matching the search criteria.

  • :order_by (String)

    Order groups by name or path. Default is name.

  • :sort (String)

    Order groups in asc or desc order. Default is asc.

  • :statistics (String)

    Include group statistics (admins only).

  • :owned (String)

    Limit to groups owned by the current user.

Returns:



104
105
106
# File 'lib/gitlab/client/groups.rb', line 104

def group_descendants(id, options = {})
  get("/groups/#{url_encode id}/descendant_groups", query: options)
end

#group_hook(group_id, hook_id) ⇒ Gitlab::ObjectifiedHash

get specified group hook

Examples:

Gitlab.group_hook(3, 1)

Parameters:

  • group_id (Integer)

    The ID of a group.

  • hook_id (Integer)

    The ID of the hook.

Returns:



377
378
379
# File 'lib/gitlab/client/groups.rb', line 377

def group_hook(group_id, hook_id)
  get("/groups/#{group_id}/hooks/#{hook_id}")
end

#group_issues(group, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of issues of a group.

Examples:

Gitlab.group_issues(5)

Parameters:

  • group_id (Integer, String)

    The ID or name of a group.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:



267
268
269
# File 'lib/gitlab/client/groups.rb', line 267

def group_issues(group, options = {})
  get("/groups/#{group}/issues", query: options)
end

#group_member(team_id, user_id) ⇒ Gitlab::ObjectifiedHash

Get details of a single group member.

Examples:

Gitlab.group_member(1, 10)

Parameters:

  • team_id (Integer)

    The ID of the group to find a member in.

  • user_id (Integer)

    The user id of the member to find.

Returns:



131
132
133
# File 'lib/gitlab/client/groups.rb', line 131

def group_member(team_id, user_id)
  get("/groups/#{url_encode team_id}/members/#{user_id}")
end

#group_members(id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Get a list of group members.

Examples:

Gitlab.group_members(1)
Gitlab.group_members(1, { per_page: 40 })

Parameters:

  • id (Integer)

    The ID of a group.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:



70
71
72
# File 'lib/gitlab/client/groups.rb', line 70

def group_members(id, options = {})
  get("/groups/#{url_encode id}/members", query: options)
end

#group_merge_requests(group, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of merge requests of a group.

Examples:

Gitlab.group_merge_requests(5)

Parameters:

  • group_id (Integer, String)

    The ID or name of a group.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:



143
144
145
# File 'lib/gitlab/client/groups.rb', line 143

def group_merge_requests(group, options = {})
  get("/groups/#{group}/merge_requests", query: options)
end

#group_projects(id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Get a list of projects under a group

Examples:

Gitlab.group_projects(1)

Parameters:

  • id (Integer)

    The ID of a group

Returns:



218
219
220
# File 'lib/gitlab/client/groups.rb', line 218

def group_projects(id, options = {})
  get("/groups/#{url_encode id}/projects", query: options)
end

#group_search(search, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Search for groups by name

Examples:

Gitlab.group_search('gitlab')

Parameters:

  • search (String)

    A string to search for in group names and paths.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :per_page (String)

    Number of projects to return per page

  • :page (String)

    The page to retrieve

Returns:



207
208
209
210
# File 'lib/gitlab/client/groups.rb', line 207

def group_search(search, options = {})
  options[:search] = search
  get('/groups', query: options)
end

#group_subgroups(id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Get a list of subgroups under a group

Examples:

Gitlab.group_subgroups(1)

Parameters:

  • id (Integer)

    the ID of a group

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :skip_groups (String)

    Skip the group IDs passed.

  • :all_available (String)

    Show all the groups you have access to (defaults to false for authenticated users).

  • :search (String)

    Return the list of authorized groups matching the search criteria.

  • :order_by (String)

    Order groups by name or path. Default is name.

  • :sort (String)

    Order groups in asc or desc order. Default is asc.

  • :statistics (String)

    Include group statistics (admins only).

  • :owned (String)

    Limit to groups owned by the current user.

Returns:



236
237
238
# File 'lib/gitlab/client/groups.rb', line 236

def group_subgroups(id, options = {})
  get("/groups/#{url_encode id}/subgroups", query: options)
end

#groups(options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of groups.

Examples:

Gitlab.groups
Gitlab.groups({ per_page: 40, page: 2 })

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:



17
18
19
# File 'lib/gitlab/client/groups.rb', line 17

def groups(options = {})
  get('/groups', query: options)
end

#list_group_hooks(group_id) ⇒ Gitlab::PaginatedResponse

List all the specified groups hooks

Examples:

Gitlab.list_group_hooks(3)

Parameters:

  • group_id (Integer)

    The ID of a group.

Returns:



365
366
367
# File 'lib/gitlab/client/groups.rb', line 365

def list_group_hooks(group_id)
  get("/groups/#{group_id}/hooks")
end

#remove_group_member(team_id, user_id) ⇒ Gitlab::ObjectifiedHash

Removes user from user group.

Examples:

Gitlab.remove_group_member(1, 2)

Parameters:

  • team_id (Integer)

    The group ID.

  • user_id (Integer)

    The ID of a user.

Returns:



181
182
183
# File 'lib/gitlab/client/groups.rb', line 181

def remove_group_member(team_id, user_id)
  delete("/groups/#{url_encode team_id}/members/#{user_id}")
end

#sync_ldap_group(id) ⇒ Array<Gitlab::ObjectifiedHash>

Sync group with LDAP

Examples:

Gitlab.sync_ldap_group(1)

Parameters:

  • id (Integer)

    The ID or name of a group.

Returns:



278
279
280
# File 'lib/gitlab/client/groups.rb', line 278

def sync_ldap_group(id)
  post("/groups/#{url_encode id}/ldap_sync")
end

#transfer_project_to_group(id, project_id) ⇒ Object

Transfers a project to a group

Examples:

Gitlab.transfer_project_to_group(3, 50)

Parameters:

  • id (Integer)

    The ID of a group.

  • project_id (Integer)

    The ID of a project.



192
193
194
195
# File 'lib/gitlab/client/groups.rb', line 192

def transfer_project_to_group(id, project_id)
  body = { id: id, project_id: project_id }
  post("/groups/#{url_encode id}/projects/#{project_id}", body: body)
end