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_custom_attribute(key, value, project_id) ⇒ Gitlab::ObjectifiedHash

Creates a new custom_attribute

Examples:

Gitlab.add_custom_attribute('some_new_key', 'some_new_value', 2)

Parameters:

  • key (String)

    The custom_attributes key

  • value (String)

    The custom_attributes value

  • project_id (Integer)

    The ID of a project.

Returns:

 683 684 685 686
# File 'lib/gitlab/client/projects.rb', line 683 def add_project_custom_attribute(key, value, project_id) url = "/projects/#{project_id}/custom_attributes/#{key}" put(url, body: { value: value }) end

#add_project_hook(project, url, options = {}) ⇒ Gitlab::ObjectifiedHash

Adds a new hook to the project.

Examples:

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

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • url (String)

    The hook URL.

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

    A customizable set of options.

  • option (Boolean)

    :push_events Trigger hook on push events (0 = false, 1 = true)

  • option (Boolean)

    :issues_events Trigger hook on issues events (0 = false, 1 = true)

  • option (Boolean)

    :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)

  • option (Boolean)

    :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)

Returns:

 228 229 230 231
# File 'lib/gitlab/client/projects.rb', line 228 def add_project_hook(project, url, options = {}) body = { url: url }.merge(options) post("/projects/#{url_encode project}/hooks", body: body) end

#add_push_rule(id, options = {}) ⇒ Gitlab::ObjectifiedHash

Adds a project push rule.

Examples:

Gitlab.add_push_rule(42, { deny_delete_tag: false, commit_message_regex: '\\b[A-Z]{3}-[0-9]+\\b' })

Parameters:

  • id (Integer)

    The ID of a project.

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

    A customizable set of options.

  • option (Boolean)

    :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)

  • option (String)

    :commit_message_regex Commit message regex

Returns:

See Also:

 287 288 289
# File 'lib/gitlab/client/projects.rb', line 287 def add_push_rule(id, options = {}) post("/projects/#{url_encode id}/push_rule", body: options) end

#add_team_member(project, id, access_level, options = {}) ⇒ Gitlab::ObjectifiedHash

Adds a user to project team.

Examples:

Gitlab.add_team_member('gitlab', 2, 40) Gitlab.add_team_member('gitlab', 2, 40, { expires_at: "2018-12-31"}) Gitlab.add_team_member('gitlab', 2, 40, { member_role_id: 5 })

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • id (Integer)

    The ID of a user.

  • access_level (Integer)

    The access level to project.

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

    A customizable set of options.

Options Hash (options):

  • :expires_at (String)

    A date string in the format YEAR-MONTH-DAY.

  • :member_role_id (Integer)

    The id of a custom member role.

Returns:

 150 151 152 153
# File 'lib/gitlab/client/projects.rb', line 150 def add_team_member(project, id, access_level, options = {}) body = { user_id: id, access_level: access_level }.merge(options) post("/projects/#{url_encode project}/members", body: body) end

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

Gets a list of all project team members including inherited members.

Examples:

Gitlab.all_members(42) Gitlab.all_members('gitlab')

Parameters:

  • project (Integer, String)

    The ID or path of a project.

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

    A customizable set of options.

Options Hash (options):

  • :query (String)

    The search query.

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:

 120 121 122
# File 'lib/gitlab/client/projects.rb', line 120 def all_members(project, options = {}) get("/projects/#{url_encode project}/members/all", query: options) end

#archive_project(id) ⇒ Gitlab::ObjectifiedHash

Archives a project.

Examples:

Gitlab.archive_project(4)

Parameters:

  • id (Integer, String)

    The ID or path of a project.

Returns:

 636 637 638
# File 'lib/gitlab/client/projects.rb', line 636 def archive_project(id) post("/projects/#{url_encode id}/archive") end

#create_deploy_key(project, title, key, options = {}) ⇒ Gitlab::ObjectifiedHash

Creates a new deploy key.

Examples:

Gitlab.create_deploy_key(42, 'My Key', 'Key contents', can_push: true)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • title (String)

    The title of a deploy key.

  • key (String)

    The content of a deploy key.

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

    A customizable set of options.

Returns:

 378 379 380
# File 'lib/gitlab/client/projects.rb', line 378 def create_deploy_key(project, title, key, options = {}) post("/projects/#{url_encode project}/deploy_keys", body: { title: title, key: key }.merge(options)) end

#create_fork(id, options = {}) ⇒ Gitlab::ObjectifiedHash

Forks a project into the user namespace.

Examples:

Gitlab.create_fork(42) Gitlab.create_fork(42, { sudo: 'another_username' })

Parameters:

  • project (Integer, String)

    The ID or path of a project.

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

    A customizable set of options.

Options Hash (options):

  • :sudo (String)

    The username the project will be forked for

Returns:

 442 443 444
# File 'lib/gitlab/client/projects.rb', line 442 def create_fork(id, options = {}) post("/projects/#{url_encode id}/fork", body: options) 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):

  • :description (String)

    The description of a project.

  • :default_branch (String)

    The default branch of a project.

  • :path (String)

    Repository name for new project. (Default is lowercase name with dashes)

  • :namespace_id (String)

    The namespace in which to create 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).

  • :snippets_enabled (Boolean)

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

  • :merge_requests_enabled (Boolean)

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

  • :visibility (String)

    The setting for making a project public (‘private’, ‘internal’, ‘public’).

  • :user_id (Integer)

    The user/owner id of a project.

Returns:

 76 77 78 79
# File 'lib/gitlab/client/projects.rb', line 76 def create_project(name, options = {}) url = options[:user_id] ? "/projects/user/#{options[:user_id]}" : '/projects' post(url, body: { name: name }.merge(options)) end

#create_project_access_token(project, name, scopes, expires_at, options = {}) ⇒ Gitlab::ObjectifiedHash

Creates a new project access token.

Examples:

Gitlab.create_project_access_token(42, 'My Token', ['api'], '2024-12-12', access_level: 40)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • name (String)

    The name of the project access token.

  • scopes (Array)

    List of scopes of the project access token.

  • expires_at (String)

    A date string in the format YYYY-MM-DD.

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

    a customizable set of options

Options Hash (options):

  • :access_level (Integer)

    Access level. Optional. Defaults to 40.

Returns:

 761 762 763
# File 'lib/gitlab/client/projects.rb', line 761 def create_project_access_token(project, name, scopes, expires_at, options = {}) post("/projects/#{url_encode project}/access_tokens", body: { name: name, scopes: scopes, expires_at: expires_at }.merge(options)) end

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

Deletes a deploy key from project.

Examples:

Gitlab.delete_deploy_key(42, 1)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • id (Integer)

    The ID of a deploy key.

Returns:

 428 429 430
# File 'lib/gitlab/client/projects.rb', line 428 def delete_deploy_key(project, id) delete("/projects/#{url_encode project}/deploy_keys/#{id}") end

#delete_project(id) ⇒ Gitlab::ObjectifiedHash

Deletes a project.

Examples:

Gitlab.delete_project(4)

Parameters:

  • id (Integer, String)

    The ID or path of a project.

Returns:

 88 89 90
# File 'lib/gitlab/client/projects.rb', line 88 def delete_project(id) delete("/projects/#{url_encode id}") end

#delete_project_custom_attribute(key, project_id = nil) ⇒ Boolean

Delete custom_attribute Will delete a custom_attribute

Examples:

Gitlab.delete_project_custom_attribute('somekey', 2)

Parameters:

  • key (String)

    The custom_attribute key to delete

  • project_id (Integer) (defaults to: nil)

    The ID of a project.

Returns:

  • (Boolean)
 697 698 699
# File 'lib/gitlab/client/projects.rb', line 697 def delete_project_custom_attribute(key, project_id = nil) delete("/projects/#{project_id}/custom_attributes/#{key}") 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 path of a project.

  • id (String)

    The ID of the hook.

Returns:

 260 261 262
# File 'lib/gitlab/client/projects.rb', line 260 def delete_project_hook(project, id) delete("/projects/#{url_encode project}/hooks/#{id}") end

#delete_push_rule(id) ⇒ Gitlab::ObjectifiedHash

Deletes a push rule from a project.

Examples:

Gitlab.delete_push_rule(42)

Parameters:

  • id (Integer)

    The ID of a project.

Returns:

See Also:

 314 315 316
# File 'lib/gitlab/client/projects.rb', line 314 def delete_push_rule(id) delete("/projects/#{url_encode id}/push_rule") end

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

Gets a single project deploy key.

Examples:

Gitlab.deploy_key(42, 1)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • id (Integer)

    The ID of a deploy key.

Returns:

 364 365 366
# File 'lib/gitlab/client/projects.rb', line 364 def deploy_key(project, id) get("/projects/#{url_encode project}/deploy_keys/#{id}") end

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

Gets a project deploy keys.

Examples:

Gitlab.deploy_keys(42)

Parameters:

  • project (Integer, String)

    The ID or path 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:

 352 353 354
# File 'lib/gitlab/client/projects.rb', line 352 def deploy_keys(project, options = {}) get("/projects/#{url_encode project}/deploy_keys", query: options) end

#disable_deploy_key(project, key) ⇒ Gitlab::ObjectifiedHash

Disables a deploy key at the project.

Examples:

Gitlab.disable_deploy_key(42, 66)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • key (Integer)

    The ID of a deploy key.

Returns:

 402 403 404
# File 'lib/gitlab/client/projects.rb', line 402 def disable_deploy_key(project, key) post("/projects/#{url_encode project}/deploy_keys/#{key}/disable", body: { id: project, key_id: key }) end

#edit_deploy_key(project, id, title, options = {}) ⇒ Gitlab::ObjectifiedHash

Updates an existing deploy key.

Examples:

Gitlab.edit_deploy_key(42, 66, 'New key name', can_push: false)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • id (Integer)

    The ID of a deploy key.

  • title (String)

    The title of a deploy key.

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

    A customizable set of options.

Returns:

 416 417 418
# File 'lib/gitlab/client/projects.rb', line 416 def edit_deploy_key(project, id, title, options = {}) put("/projects/#{url_encode project}/deploy_keys/#{id}", body: { title: title }.merge(options)) end

#edit_project(id, options = {}) ⇒ Gitlab::ObjectifiedHash

Updates an existing project.

(Any provided options will be passed to Gitlab. See Gitlab docs for all valid options)

Examples:

Gitlab.edit_project(42) Gitlab.edit_project(42, { name: 'Project Name' }) Gitlab.edit_project('project-name', { name: 'New Project Name', path: 'new-project-patth' })

Parameters:

  • project (Integer, String)

    The ID or path of a project.

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

    A customizable set of options

Options Hash (options):

  • :name (String)

    The name of a project

  • :path (String)

    The project’s repository name, also used in Gitlab’s URLs

  • :description (String)

    The description to show in Gitlab

Returns:

 479 480 481
# File 'lib/gitlab/client/projects.rb', line 479 def edit_project(id, options = {}) put("/projects/#{url_encode id}", body: options) end

#edit_project_hook(project, id, url, options = {}) ⇒ Gitlab::ObjectifiedHash

Updates a project hook URL.

Examples:

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

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • id (Integer)

    The ID of the hook.

  • url (String)

    The hook URL.

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

    A customizable set of options.

  • option (Boolean)

    :push_events Trigger hook on push events (0 = false, 1 = true)

  • option (Boolean)

    :issues_events Trigger hook on issues events (0 = false, 1 = true)

  • option (Boolean)

    :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)

  • option (Boolean)

    :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)

Returns:

 247 248 249 250
# File 'lib/gitlab/client/projects.rb', line 247 def edit_project_hook(project, id, url, options = {}) body = { url: url }.merge(options) put("/projects/#{url_encode project}/hooks/#{id}", body: body) end

#edit_push_rule(id, options = {}) ⇒ Gitlab::ObjectifiedHash

Updates a project push rule.

Examples:

Gitlab.edit_push_rule(42, { deny_delete_tag: false, commit_message_regex: '\\b[A-Z]{3}-[0-9]+\\b' })

Parameters:

  • id (Integer)

    The ID of a project.

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

    A customizable set of options.

  • option (Boolean)

    :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)

  • option (String)

    :commit_message_regex Commit message regex

Returns:

See Also:

 302 303 304
# File 'lib/gitlab/client/projects.rb', line 302 def edit_push_rule(id, options = {}) put("/projects/#{url_encode id}/push_rule", body: options) end

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

Updates a team member’s project access level.

Examples:

Gitlab.edit_team_member('gitlab', 3, 20) Gitlab.edit_team_member('gitlab', 3, 20, { expires_at: "2018-12-31"}) Gitlab.edit_team_member('gitlab', 3, 20, { member_role_id: 5 })

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • id (Integer)

    The ID of a user.

  • access_level (Integer)

    The access level to project.

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

    A customizable set of options.

Options Hash (options):

  • :expires_at (String)

    A date string in the format YEAR-MONTH-DAY.

  • :member_role_id (Integer)

    The id of a custom member role.

Returns:

 169 170 171 172
# File 'lib/gitlab/client/projects.rb', line 169 def edit_team_member(project, id, access_level, options = {}) body = { access_level: access_level }.merge(options) put("/projects/#{url_encode project}/members/#{id}", body: body) end

#enable_deploy_key(project, key) ⇒ Gitlab::ObjectifiedHash

Enables a deploy key at the project.

Examples:

Gitlab.enable_deploy_key(42, 66)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • key (Integer)

    The ID of a deploy key.

Returns:

 390 391 392
# File 'lib/gitlab/client/projects.rb', line 390 def enable_deploy_key(project, key) post("/projects/#{url_encode project}/deploy_keys/#{key}/enable", body: { id: project, key_id: key }) end

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

Mark this project as forked from the other

Examples:

Gitlab.make_forked(42, 24)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • id (Integer)

    The ID of the project it is forked from.

Returns:

 326 327 328
# File 'lib/gitlab/client/projects.rb', line 326 def make_forked_from(project, id) post("/projects/#{url_encode project}/fork/#{id}") end

#project(id, options = {}) ⇒ Gitlab::ObjectifiedHash

Gets information about a project.

Examples:

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

Parameters:

  • id (Integer, String)

    The ID or path of a project.

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

    :license Include project license data

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

    :statistics Include project statistics.

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

    :with_custom_attributes Include custom attributes in response. (admins only)

Returns:

 51 52 53
# File 'lib/gitlab/client/projects.rb', line 51 def project(id, options = {}) get("/projects/#{url_encode id}", query: options) end

#project_access_token(project, token_id) ⇒ Gitlab::ObjectifiedHash

Get a specific project access token.

Examples:

Gitlab.project_access_token(42, 1234)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • token_id (Integer)

    The ID of the project access token.

Returns:

 745 746 747
# File 'lib/gitlab/client/projects.rb', line 745 def project_access_token(project, token_id) get("/projects/#{url_encode project}/access_tokens/#{token_id}") end

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

List all project access tokens.

Examples:

Gitlab.project_access_tokens(42)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

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

    a customizable set of options

Options Hash (options):

  • :state (String)

    Limit by active/inactive state. Optional.

Returns:

 732 733 734
# File 'lib/gitlab/client/projects.rb', line 732 def project_access_tokens(project, options = {}) get("/projects/#{url_encode project}/access_tokens", query: options) end

#project_custom_attribute(key, project_id) ⇒ Gitlab::ObjectifiedHash

Gets single project custom_attribute.

Examples:

Gitlab.project_custom_attribute(key, 2)

Parameters:

  • key (String)

    The custom_attributes key

  • project_id (Integer)

    The ID of a project.

Returns:

 670 671 672
# File 'lib/gitlab/client/projects.rb', line 670 def project_custom_attribute(key, project_id) get("/projects/#{project_id}/custom_attributes/#{key}") end

#project_custom_attributes(project_id) ⇒ Gitlab::ObjectifiedHash

Gets project custom_attributes.

Examples:

Gitlab.project_custom_attributes(2)

Parameters:

  • project_id (Integer)

    The ID of a project.

Returns:

 658 659 660
# File 'lib/gitlab/client/projects.rb', line 658 def project_custom_attributes(project_id) get("/projects/#{project_id}/custom_attributes") end

#project_deploy_tokens(project, options = {}) ⇒ Object

List project deploy tokens

Examples:

Gitlab.project_deploy_tokens(42)

Parameters:

  • id (Integer, String)

    The ID or path of a project.

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

    a customizable set of options

Options Hash (options):

  • :active (Boolean)

    Limit by active status. Optional.

 708 709 710
# File 'lib/gitlab/client/projects.rb', line 708 def project_deploy_tokens(project, options = {}) get("/projects/#{url_encode project}/deploy_tokens", query: options) end

#project_forks(id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Get a list of all visible projects across GitLab for the authenticated user. When accessed without authentication, only public projects are returned.

Note: This feature was introduced in GitLab 10.1

Examples:

Gitlab.project_forks(42)

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.

  • :order_by (String)

    Return requests ordered by id, name, created_at or last_activity_at fields

  • :sort (String)

    Return requests sorted in asc or desc order

Returns:

 460 461 462
# File 'lib/gitlab/client/projects.rb', line 460 def project_forks(id, options = {}) get("/projects/#{url_encode id}/forks", query: options) end

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

Gets a project hook.

Examples:

Gitlab.project_hook(42, 5) Gitlab.project_hook('gitlab', 5)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • id (Integer)

    The ID of a hook.

Returns:

 211 212 213
# File 'lib/gitlab/client/projects.rb', line 211 def project_hook(project, id) get("/projects/#{url_encode project}/hooks/#{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 path 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:

 198 199 200
# File 'lib/gitlab/client/projects.rb', line 198 def project_hooks(project, options = {}) get("/projects/#{url_encode project}/hooks", query: options) end

#project_languages(project) ⇒ Gitlab::ObjectifiedHash

Get languages used with percentage value

Examples:

Gitlab.project_languages(42)

Parameters:

  • id (Integer, String)

    The ID or path of a project.

Returns:

 719 720 721
# File 'lib/gitlab/client/projects.rb', line 719 def project_languages(project) get("/projects/#{url_encode project}/languages") end

#project_search(query, options = {}) ⇒ Array<Gitlab::ObjectifiedHash> Also known as: search_projects

Search for projects by name.

Examples:

Gitlab.project_search('gitlab') Gitlab.project_search('gitlab', { order_by: 'last_activity_at' }) Gitlab.search_projects('gitlab', { order_by: 'name', sort: 'asc' })

Parameters:

  • 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

  • :order_by (String)

    Return requests ordered by id, name, created_at or last_activity_at fields

  • :sort (String)

    Return requests sorted in asc or desc order

Returns:

 35 36 37
# File 'lib/gitlab/client/projects.rb', line 35 def project_search(query, options = {}) get('/projects', query: options.merge(search: query)) end

#project_template(project, type, key, options = {}) ⇒ Gitlab::ObjectifiedHash

Get one project template of a particular type

Examples:

Gitlab.project_template(1, 'dockerfiles', 'dockey') Gitlab.project_template(1, 'licenses', 'gpl', { project: 'some project', fullname: 'Holder Holding' })

Parameters:

  • project (Integer, String)

    The ID or URL-encoded path of the project.

  • type (String)

    The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template

  • key (String)

    The key of the template, as obtained from the collection endpoint

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

    A customizable set of options.

Options Hash (options):

  • project(optional) (String)

    The project name to use when expanding placeholders in the template. Only affects licenses

  • fullname(optional) (String)

    The full name of the copyright holder to use when expanding placeholders in the template. Only affects licenses

Returns:

See Also:

 625 626 627
# File 'lib/gitlab/client/projects.rb', line 625 def project_template(project, type, key, options = {}) get("/projects/#{url_encode project}/templates/#{type}/#{key}", query: options) end

#project_templates(project, type) ⇒ Array<Gitlab::ObjectifiedHash>

Get all project templates of a particular type

Examples:

Gitlab.project_templates(1, 'dockerfiles') Gitlab.project_templates(1, 'licenses')

Parameters:

  • id (Integer, String)

    The ID or URL-encoded path of the project.

  • type (String)

    The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template

Returns:

See Also:

 607 608 609
# File 'lib/gitlab/client/projects.rb', line 607 def project_templates(project, type) get("/projects/#{url_encode project}/templates/#{type}") end

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

Gets a list of projects owned by the authenticated user.

(Any provided options will be passed to Gitlab. See Gitlab docs for all valid options)

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:

 18 19 20
# File 'lib/gitlab/client/projects.rb', line 18 def projects(options = {}) get('/projects', query: options) end

#push_rule(id) ⇒ Gitlab::ObjectifiedHash

Gets a project push rule.

Examples:

Gitlab.push_rule(42)

Parameters:

  • id (Integer)

    The ID of a project.

Returns:

See Also:

 272 273 274
# File 'lib/gitlab/client/projects.rb', line 272 def push_rule(id) get("/projects/#{url_encode id}/push_rule") end

#remove_forked(project) ⇒ Gitlab::ObjectifiedHash

Remove a forked_from relationship for a project.

Examples:

Gitlab.remove_forked(42)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • project (Integer)

    The ID of the project it is forked from

Returns:

 338 339 340
# File 'lib/gitlab/client/projects.rb', line 338 def remove_forked(project) delete("/projects/#{url_encode project}/fork") end

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

Removes a user from project team.

Examples:

Gitlab.remove_team_member('gitlab', 2)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • id (Integer)

    The ID of a user.

  • options (Hash)

    A customizable set of options.

Returns:

 183 184 185
# File 'lib/gitlab/client/projects.rb', line 183 def remove_team_member(project, id) delete("/projects/#{url_encode project}/members/#{id}") end

#revoke_project_access_token(project, token_id) ⇒ Gitlab::ObjectifiedHash

Revoke a project access token.

Examples:

Gitlab.revoke_project_access_token(42, 1234)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • token_id (Integer)

    The ID of the project access token.

Returns:

 788 789 790
# File 'lib/gitlab/client/projects.rb', line 788 def revoke_project_access_token(project, token_id) delete("/projects/#{url_encode project}/access_tokens/#{token_id}") end

#rotate_project_access_token(project, token_id, options = {}) ⇒ Gitlab::ObjectifiedHash

Rotate a project access token.

Examples:

Gitlab.rotate_project_access_token(42, 1234)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • token_id (Integer)

    The ID of the project access token.

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

    a customizable set of options

Options Hash (options):

  • :expires_at (String)

    A date string in the format YEAR-MONTH-DAY.

Returns:

 775 776 777
# File 'lib/gitlab/client/projects.rb', line 775 def rotate_project_access_token(project, token_id, options = {}) post("/projects/#{url_encode project}/access_tokens/#{token_id}/rotate", query: options) end

#share_project_with_group(project, id, group_access) ⇒ Object

Share project with group.

Examples:

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

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • id (Integer)

    The ID of a group.

  • group_access (Integer)

    The access level to project.

 491 492 493
# File 'lib/gitlab/client/projects.rb', line 491 def share_project_with_group(project, id, group_access) post("/projects/#{url_encode project}/share", body: { group_id: id, group_access: group_access }) end

#star_project(id) ⇒ Gitlab::ObjectifiedHash

Stars a project.

Examples:

Gitlab.star_project(42) Gitlab.star_project('gitlab-org/gitlab-ce')

Parameters:

  • id (Integer, String)

    The ID or path of a project.

Returns:

See Also:

 528 529 530
# File 'lib/gitlab/client/projects.rb', line 528 def star_project(id) post("/projects/#{url_encode id}/star") end

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

Gets a project team member.

Examples:

Gitlab.team_member('gitlab', 2)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • id (Integer)

    The ID of a project team member.

Returns:

 132 133 134
# File 'lib/gitlab/client/projects.rb', line 132 def team_member(project, id) get("/projects/#{url_encode 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 path of a project.

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

    A customizable set of options.

Options Hash (options):

  • :query (String)

    The search query.

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:

 104 105 106
# File 'lib/gitlab/client/projects.rb', line 104 def team_members(project, options = {}) get("/projects/#{url_encode project}/members", query: options) end

#transfer_project(project, namespace) ⇒ Gitlab::ObjectifiedHash

Transfer a project to a new namespace.

Examples:

Gitlab.transfer_project(42, 'yolo')

Parameters:

  • project (Integer, String)

    The ID or path of a project

  • namespace (Integer, String)

    The ID or path of the namespace to transfer to project to

Returns:

 515 516 517
# File 'lib/gitlab/client/projects.rb', line 515 def transfer_project(project, namespace) put("/projects/#{url_encode project}/transfer", body: { namespace: namespace }) end

#unarchive_project(id) ⇒ Gitlab::ObjectifiedHash

Unarchives a project.

Examples:

Gitlab.unarchive_project(4)

Parameters:

  • id (Integer, String)

    The ID or path of a project.

Returns:

 647 648 649
# File 'lib/gitlab/client/projects.rb', line 647 def unarchive_project(id) post("/projects/#{url_encode id}/unarchive") end

#unshare_project_with_group(project, id) ⇒ void

This method returns an undefined value.

Unshare project with group.

Examples:

Gitlab.unshare_project_with_group('gitlab', 2)

Parameters:

  • project (Integer, String)

    The ID or path of a project.

  • id (Integer)

    The ID of a group.

 503 504 505
# File 'lib/gitlab/client/projects.rb', line 503 def unshare_project_with_group(project, id) delete("/projects/#{url_encode project}/share/#{id}") end

#unstar_project(id) ⇒ Gitlab::ObjectifiedHash

Unstars a project.

Examples:

Gitlab.unstar_project(42) Gitlab.unstar_project('gitlab-org/gitlab-ce')

Parameters:

  • id (Integer, String)

    The ID or path of a project.

Returns:

See Also:

 541 542 543
# File 'lib/gitlab/client/projects.rb', line 541 def unstar_project(id) delete("/projects/#{url_encode id}/star") end

#upload_file(id, file_fullpath) ⇒ Gitlab::ObjectifiedHash

Uploads a file to the specified project to be used in an issue or merge request description, or a comment.

Examples:

Gitlab.upload_file(1, '/full/path/to/avatar.jpg')

Parameters:

  • id (Integer, String)

    The ID or path of a project.

  • file_fullpath (String)

    The fullpath of the file you are interested to upload.

Returns:

See Also:

 593 594 595
# File 'lib/gitlab/client/projects.rb', line 593 def upload_file(id, file_fullpath) post("/projects/#{url_encode id}/uploads", body: { file: File.open(file_fullpath, 'r') }) end

#user_projects(user_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Get a list of visible projects for the given user.

Examples:

Gitlab.user_projects(1) Gitlab.user_projects(1, { order_by: 'last_activity_at' }) Gitlab.user_projects('username', { order_by: 'name', sort: 'asc' })

Parameters:

  • user_id (Integer, String)

    The ID or username of the user.

  • 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

  • :order_by (String)

    Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.

  • :sort (String)

    Return projects sorted in asc or desc order.

Returns:

See Also:

 579 580 581
# File 'lib/gitlab/client/projects.rb', line 579 def user_projects(user_id, options = {}) get("/users/#{url_encode user_id}/projects", query: options) end

#user_starred_projects(user_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Get a list of visible projects that the given user has starred.

Examples:

Gitlab.user_starred_projects(1) Gitlab.user_starred_projects(1, { order_by: 'last_activity_at' }) Gitlab.user_starred_projects('username', { order_by: 'name', sort: 'asc' })

Parameters:

  • user_id (Integer, String)

    The ID or username of the user.

  • 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

  • :order_by (String)

    Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.

  • :sort (String)

    Return projects sorted in asc or desc order.

Returns:

See Also:

 560 561 562
# File 'lib/gitlab/client/projects.rb', line 560 def user_starred_projects(user_id, options = {}) get("/users/#{url_encode user_id}/starred_projects", query: options) end