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


92
93
94
# File 'lib/gitlab/client/groups.rb', line 92

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

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


41
42
43
44
# File 'lib/gitlab/client/groups.rb', line 41

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:


52
53
54
# File 'lib/gitlab/client/groups.rb', line 52

def delete_group(id)
  delete("/groups/#{url_encode id}")
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:


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

def edit_group(id, options = {})
  put("/groups/#{url_encode id}", body: options)
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:


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

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) ⇒ Gitlab::ObjectifiedHash

Gets a single group.

Examples:

Gitlab.group(42)

Parameters:

  • id (Integer)

    The ID of a group.

Returns:


28
29
30
# File 'lib/gitlab/client/groups.rb', line 28

def group(id)
  get("/groups/#{url_encode 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:


203
204
205
# File 'lib/gitlab/client/groups.rb', line 203

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:


79
80
81
# File 'lib/gitlab/client/groups.rb', line 79

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:


67
68
69
# File 'lib/gitlab/client/groups.rb', line 67

def group_members(id, options = {})
  get("/groups/#{url_encode id}/members", 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:


154
155
156
# File 'lib/gitlab/client/groups.rb', line 154

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:


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

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:


172
173
174
# File 'lib/gitlab/client/groups.rb', line 172

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

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


117
118
119
# File 'lib/gitlab/client/groups.rb', line 117

def remove_group_member(team_id, user_id)
  delete("/groups/#{url_encode team_id}/members/#{user_id}")
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.


128
129
130
131
# File 'lib/gitlab/client/groups.rb', line 128

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