Module: Gitlab::Client::Projects

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

Overview

Defines methods related to projects.

Instance Method Summary collapse

Instance Method Details

#add_project_hook(project, url) ⇒ Gitlab::ObjectifiedHash

Adds a new hook to the project.

Examples:

Gitlab.project_hooks(42, 'https://api.example.net/v1/webhooks/ci')

Parameters:

  • project (Integer, String)

    The ID or code name of a project.

  • url (String)

    The hook URL.

Returns:



139
140
141
# File 'lib/gitlab/client/projects.rb', line 139

def add_project_hook(project, url)
  post("/projects/#{project}/hooks", :body => {:url => url})
end

#add_team_member(project, id, access_level) ⇒ Array<Gitlab::ObjectifiedHash>

Adds a user to project team.

Examples:

Gitlab.add_team_member('gitlab', 2, 40)

Parameters:

  • project (Integer, String)

    The ID or code name of a project.

  • id (Integer)

    The ID of a user.

  • access_level (Integer)

    The access level to project.

Returns:



87
88
89
# File 'lib/gitlab/client/projects.rb', line 87

def add_team_member(project, id, access_level)
  post("/projects/#{project}/members/#{id}", :body => {:access_level => access_level})
end

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

Creates a new project.

Examples:

Gitlab.create_project('gitlab')
Gitlab.create_project('viking', :description => 'Awesome project')
Gitlab.create_project('Red', :wall_enabled => false)

Parameters:

  • name (String)

    The name of a project.

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

    A customizable set of options.

Options Hash (options):

  • :code (String)

    The code name of a project.

  • :path (String)

    The path of a project.

  • :description (String)

    The description of a project.

  • :default_branch (String)

    The default branch of a project.

  • :wiki_enabled (Boolean)

    The wiki integration for a project (0 = false, 1 = true).

  • :wall_enabled (Boolean)

    The wall functionality for a project (0 = false, 1 = true).

  • :issues_enabled (Boolean)

    The issues integration for a project (0 = false, 1 = true).

  • :merge_requests_enabled (Boolean)

    The merge requests functionality for a project (0 = false, 1 = true).

Returns:



47
48
49
# File 'lib/gitlab/client/projects.rb', line 47

def create_project(name, options={})
  post("/projects", :body => {:name => name}.merge(options))
end

#delete_project_hook(project, id) ⇒ Gitlab::ObjectifiedHash

Deletes a hook from project.

Examples:

Gitlab.delete_project_hook('gitlab', 4)

Parameters:

  • project (Integer, String)

    The ID or code name of a project.

  • id (String)

    The ID of the hook.

Returns:



151
152
153
# File 'lib/gitlab/client/projects.rb', line 151

def delete_project_hook(project, id)
  delete("/projects/#{project}/hooks/#{id}")
end

#edit_team_member(project, id, access_level) ⇒ Array<Gitlab::ObjectifiedHash>

Updates a team member’s project access level.

Examples:

Gitlab.team_members('gitlab', 3, 20)

Parameters:

  • project (Integer, String)

    The ID or code name of a project.

  • id (Integer)

    The ID of a user.

  • access_level (Integer)

    The access level to project.

Returns:



100
101
102
# File 'lib/gitlab/client/projects.rb', line 100

def edit_team_member(project, id, access_level)
  put("/projects/#{project}/members/#{id}", :body => {:access_level => access_level})
end

#project(id) ⇒ Gitlab::ObjectifiedHash

Gets information about a project.

Examples:

Gitlab.project(3)
Gitlab.project('gitlab')

Parameters:

  • id (Integer, String)

    The ID or code name of a project.

Returns:



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

def project(id)
  get("/projects/#{id}")
end

#project_hooks(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of project hooks.

Examples:

Gitlab.project_hooks(42)
Gitlab.project_hooks('gitlab')

Parameters:

  • project (Integer, String)

    The ID or code name of a project.

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



127
128
129
# File 'lib/gitlab/client/projects.rb', line 127

def project_hooks(project, options={})
  get("/projects/#{project}/hooks", :query => options)
end

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

Gets a list of projects owned by the authenticated user.

Examples:

Gitlab.projects

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:



13
14
15
# File 'lib/gitlab/client/projects.rb', line 13

def projects(options={})
  get("/projects", :query => options)
end

#remove_team_member(project, id) ⇒ Array<Gitlab::ObjectifiedHash>

Removes a user from project team.

Examples:

Gitlab.remove_team_member('gitlab', 2)

Parameters:

  • project (Integer, String)

    The ID or code name of a project.

  • id (Integer)

    The ID of a user.

Returns:



112
113
114
# File 'lib/gitlab/client/projects.rb', line 112

def remove_team_member(project, id)
  delete("/projects/#{project}/members/#{id}")
end

#team_member(project, id) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a project team member.

Examples:

Gitlab.team_member('gitlab', 2)

Parameters:

  • project (Integer, String)

    The ID or code name of a project.

  • id (Integer)

    The ID of a project team member.

Returns:



74
75
76
# File 'lib/gitlab/client/projects.rb', line 74

def team_member(project, id)
  get("/projects/#{project}/members/#{id}")
end

#team_members(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of project team members.

Examples:

Gitlab.team_members(42)
Gitlab.team_members('gitlab')

Parameters:

  • project (Integer, String)

    The ID or code name of a project.

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



62
63
64
# File 'lib/gitlab/client/projects.rb', line 62

def team_members(project, options={})
  get("/projects/#{project}/members", :query => options)
end