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:



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

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:



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

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:



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

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:



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

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:



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

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:



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

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.



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

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