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:



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

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

Creates a new group.

Parameters:

  • name (String)

    The name of a group.

  • path (String)

    The path of a group.

Returns:



35
36
37
38
# File 'lib/gitlab/client/groups.rb', line 35

def create_group(name, path)
  body = {:name => name, :path => path}
  post("/groups", :body => body)
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:



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

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

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

Gets a list of groups.

Examples:

Gitlab.groups
Gitlab.groups(:per_page => 40)

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:



76
77
78
# File 'lib/gitlab/client/groups.rb', line 76

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

Parameters:

  • id (Integer)

    The ID of a group.

  • project_id (Integer)

    The ID of a project.



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

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