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:



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

def add_group_member(team_id, user_id, access_level)
  post("/groups/#{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:



39
40
41
42
# File 'lib/gitlab/client/groups.rb', line 39

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:



50
51
52
# File 'lib/gitlab/client/groups.rb', line 50

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



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

def edit_group_member(team_id, user_id, access_level)
  put("/groups/#{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:



26
27
28
# File 'lib/gitlab/client/groups.rb', line 26

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



65
66
67
# File 'lib/gitlab/client/groups.rb', line 65

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



140
141
142
# File 'lib/gitlab/client/groups.rb', line 140

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



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

def group_search(search, options={})
  options[:search] = search
  get("/groups", 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:



15
16
17
# File 'lib/gitlab/client/groups.rb', line 15

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:



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

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



114
115
116
117
# File 'lib/gitlab/client/groups.rb', line 114

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