module Gitlab::Client::Projects

def add_project_custom_attribute(key, value, project_id)

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • project_id (Integer) -- The ID of a project.
  • value (String) -- The custom_attributes value
  • key (String) -- The custom_attributes key
def add_project_custom_attribute(key, value, project_id)
  url = "/projects/#{project_id}/custom_attributes/#{key}"
  put(url, body: { value: value })
end

def add_project_hook(project, url, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Information about added hook.

Parameters:
  • option (Boolean) -- :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
  • option (Boolean) -- :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
  • option (Boolean) -- :issues_events Trigger hook on issues events (0 = false, 1 = true)
  • option (Boolean) -- :push_events Trigger hook on push events (0 = false, 1 = true)
  • options (Hash) -- A customizable set of options.
  • url (String) -- The hook URL.
  • project (Integer, String) -- The ID or path of a project.
def add_project_hook(project, url, options = {})
  body = { url: url }.merge(options)
  post("/projects/#{url_encode project}/hooks", body: body)
end

def add_push_rule(id, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Information about added push rule.

Parameters:
  • option (String) -- :commit_message_regex Commit message regex
  • option (Boolean) -- :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
  • options (Hash) -- A customizable set of options.
  • id (Integer) -- The ID of a project.

Other tags:
    See: https://docs.gitlab.com/ee/api/projects.html#add-project-push-rule -
def add_push_rule(id, options = {})
  post("/projects/#{url_encode id}/push_rule", body: options)
end

def add_team_member(project, id, access_level, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Information about added team member.

Options Hash: (**options)
  • :expires_at (String) -- A date string in the format YEAR-MONTH-DAY.

Parameters:
  • options (Hash) -- A customizable set of options.
  • access_level (Integer) -- The access level to project.
  • id (Integer) -- The ID of a user.
  • project (Integer, String) -- The ID or path of a project.
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

def all_members(project, options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :per_page (Integer) -- The number of results per page.
  • :page (Integer) -- The page number.
  • :query (String) -- The search query.

Parameters:
  • options (Hash) -- A customizable set of options.
  • project (Integer, String) -- The ID or path of a project.
def all_members(project, options = {})
  get("/projects/#{url_encode project}/members/all", query: options)
end

def archive_project(id)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about archived project.

Parameters:
  • id (Integer, String) -- The ID or path of a project.
def archive_project(id)
  post("/projects/#{url_encode id}/archive")
end

def create_deploy_key(project, title, key, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Information about created deploy key.

Parameters:
  • options (Hash) -- A customizable set of options.
  • key (String) -- The content of a deploy key.
  • title (String) -- The title of a deploy key.
  • project (Integer, String) -- The ID or path of a project.
def create_deploy_key(project, title, key, options = {})
  post("/projects/#{url_encode project}/deploy_keys", body: { title: title, key: key }.merge(options))
end

def create_fork(id, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Information about the forked project.

Options Hash: (**options)
  • :sudo (String) -- The username the project will be forked for

Parameters:
  • options (Hash) -- A customizable set of options.
  • project (Integer, String) -- The ID or path of a project.
def create_fork(id, options = {})
  post("/projects/#{url_encode id}/fork", body: options)
end

def create_project(name, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Information about created project.

Options Hash: (**options)
  • :user_id (Integer) -- The user/owner id of a project.
  • :visibility (String) -- The setting for making a project public ('private', 'internal', 'public').
  • :merge_requests_enabled (Boolean) -- The merge requests functionality for a project (0 = false, 1 = true).
  • :snippets_enabled (Boolean) -- The snippets integration for a project (0 = false, 1 = true).
  • :issues_enabled (Boolean) -- The issues integration for a project (0 = false, 1 = true).
  • :wall_enabled (Boolean) -- The wall functionality for a project (0 = false, 1 = true).
  • :wiki_enabled (Boolean) -- The wiki integration for a project (0 = false, 1 = true).
  • :namespace_id (String) -- The namespace in which to create a project.
  • :path (String) -- Repository name for new project. (Default is lowercase name with dashes)
  • :default_branch (String) -- The default branch of a project.
  • :description (String) -- The description of a project.

Parameters:
  • options (Hash) -- A customizable set of options.
  • name (String) -- The name of a project.
def create_project(name, options = {})
  url = options[:user_id] ? "/projects/user/#{options[:user_id]}" : '/projects'
  post(url, body: { name: name }.merge(options))
end

def delete_deploy_key(project, id)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about deleted deploy key.

Parameters:
  • id (Integer) -- The ID of a deploy key.
  • project (Integer, String) -- The ID or path of a project.
def delete_deploy_key(project, id)
  delete("/projects/#{url_encode project}/deploy_keys/#{id}")
end

def delete_project(id)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about deleted project.

Parameters:
  • id (Integer, String) -- The ID or path of a project.
def delete_project(id)
  delete("/projects/#{url_encode id}")
end

def delete_project_custom_attribute(key, project_id = nil)

Returns:
  • (Boolean) -

Parameters:
  • project_id (Integer) -- The ID of a project.
  • key (String) -- The custom_attribute key to delete
def delete_project_custom_attribute(key, project_id = nil)
  delete("/projects/#{project_id}/custom_attributes/#{key}")
end

def delete_project_hook(project, id)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about deleted hook.

Parameters:
  • id (String) -- The ID of the hook.
  • project (Integer, String) -- The ID or path of a project.
def delete_project_hook(project, id)
  delete("/projects/#{url_encode project}/hooks/#{id}")
end

def delete_push_rule(id)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about deleted push rule.

Parameters:
  • id (Integer) -- The ID of a project.

Other tags:
    See: https://docs.gitlab.com/ee/api/projects.html#delete-project-push-rule -
def delete_push_rule(id)
  delete("/projects/#{url_encode id}/push_rule")
end

def deploy_key(project, id)

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • id (Integer) -- The ID of a deploy key.
  • project (Integer, String) -- The ID or path of a project.
def deploy_key(project, id)
  get("/projects/#{url_encode project}/deploy_keys/#{id}")
end

def deploy_keys(project, options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :per_page (Integer) -- The number of results per page.
  • :page (Integer) -- The page number.

Parameters:
  • options (Hash) -- A customizable set of options.
  • project (Integer, String) -- The ID or path of a project.
def deploy_keys(project, options = {})
  get("/projects/#{url_encode project}/deploy_keys", query: options)
end

def disable_deploy_key(project, key)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about the disabled deploy key.

Parameters:
  • key (Integer) -- The ID of a deploy key.
  • project (Integer, String) -- The ID or path of a project.
def disable_deploy_key(project, key)
  post("/projects/#{url_encode project}/deploy_keys/#{key}/disable", body: { id: project, key_id: key })
end

def edit_deploy_key(project, id, title, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Information about created deploy key.

Parameters:
  • options (Hash) -- A customizable set of options.
  • title (String) -- The title of a deploy key.
  • id (Integer) -- The ID of a deploy key.
  • project (Integer, String) -- The ID or path of a project.
def edit_deploy_key(project, id, title, options = {})
  put("/projects/#{url_encode project}/deploy_keys/#{id}", body: { title: title }.merge(options))
end

def edit_project(id, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Information about the edited project.

Options Hash: (**options)
  • :description (String) -- The description to show in Gitlab
  • :path (String) -- The project's repository name, also used in Gitlab's URLs
  • :name (String) -- The name of a project

Parameters:
  • options (Hash) -- A customizable set of options
  • project (Integer, String) -- The ID or path of a project.
def edit_project(id, options = {})
  put("/projects/#{url_encode id}", body: options)
end

def edit_project_hook(project, id, url, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Information about updated hook.

Parameters:
  • option (Boolean) -- :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
  • option (Boolean) -- :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
  • option (Boolean) -- :issues_events Trigger hook on issues events (0 = false, 1 = true)
  • option (Boolean) -- :push_events Trigger hook on push events (0 = false, 1 = true)
  • options (Hash) -- A customizable set of options.
  • url (String) -- The hook URL.
  • id (Integer) -- The ID of the hook.
  • project (Integer, String) -- The ID or path of a project.
def edit_project_hook(project, id, url, options = {})
  body = { url: url }.merge(options)
  put("/projects/#{url_encode project}/hooks/#{id}", body: body)
end

def edit_push_rule(id, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Information about updated push rule.

Parameters:
  • option (String) -- :commit_message_regex Commit message regex
  • option (Boolean) -- :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
  • options (Hash) -- A customizable set of options.
  • id (Integer) -- The ID of a project.

Other tags:
    See: https://docs.gitlab.com/ee/api/projects.html#edit-project-push-rule -
def edit_push_rule(id, options = {})
  put("/projects/#{url_encode id}/push_rule", body: options)
end

def edit_team_member(project, id, access_level, options = {})

Returns:
  • (Array) - Information about updated team member.

Options Hash: (**options)
  • :expires_at (String) -- A date string in the format YEAR-MONTH-DAY.

Parameters:
  • options (Hash) -- A customizable set of options.
  • access_level (Integer) -- The access level to project.
  • id (Integer) -- The ID of a user.
  • project (Integer, String) -- The ID or path of a project.
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

def enable_deploy_key(project, key)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about the enabled deploy key.

Parameters:
  • key (Integer) -- The ID of a deploy key.
  • project (Integer, String) -- The ID or path of a project.
def enable_deploy_key(project, key)
  post("/projects/#{url_encode project}/deploy_keys/#{key}/enable", body: { id: project, key_id: key })
end

def make_forked_from(project, id)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about the forked project.

Parameters:
  • id (Integer) -- The ID of the project it is forked from.
  • project (Integer, String) -- The ID or path of a project.
def make_forked_from(project, id)
  post("/projects/#{url_encode project}/fork/#{id}")
end

def project(id, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • options (string) -- :with_custom_attributes Include custom attributes in response. (admins only)
  • options (string) -- :statistics Include project statistics.
  • options (string) -- :license Include project license data
  • id (Integer, String) -- The ID or path of a project.
def project(id, options = {})
  get("/projects/#{url_encode id}", query: options)
end

def project_custom_attribute(key, project_id)

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • project_id (Integer) -- The ID of a project.
  • key (String) -- The custom_attributes key
def project_custom_attribute(key, project_id)
  get("/projects/#{project_id}/custom_attributes/#{key}")
end

def project_custom_attributes(project_id)

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • project_id (Integer) -- The ID of a project.
def project_custom_attributes(project_id)
  get("/projects/#{project_id}/custom_attributes")
end

def project_deploy_tokens(project, options = {})

Options Hash: (**options)
  • :active (Boolean) -- Limit by active status. Optional.

Parameters:
  • id (Integer, String) -- The ID or path of a project.
def project_deploy_tokens(project, options = {})
  get("/projects/#{url_encode project}/deploy_tokens", query: options)
end

def project_forks(id, options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :sort (String) -- Return requests sorted in asc or desc order
  • :order_by (String) -- Return requests ordered by id, name, created_at or last_activity_at fields
  • :per_page (Integer) -- The number of results per page.
  • :page (Integer) -- The page number.

Parameters:
  • options (Hash) -- A customizable set of options.
def project_forks(id, options = {})
  get("/projects/#{url_encode id}/forks", query: options)
end

def project_hook(project, id)

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • id (Integer) -- The ID of a hook.
  • project (Integer, String) -- The ID or path of a project.
def project_hook(project, id)
  get("/projects/#{url_encode project}/hooks/#{id}")
end

def project_hooks(project, options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :per_page (Integer) -- The number of results per page.
  • :page (Integer) -- The page number.

Parameters:
  • options (Hash) -- A customizable set of options.
  • project (Integer, String) -- The ID or path of a project.
def project_hooks(project, options = {})
  get("/projects/#{url_encode project}/hooks", query: options)
end

def project_search(query, options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :sort (String) -- Return requests sorted in asc or desc order
  • :order_by (String) -- Return requests ordered by id, name, created_at or last_activity_at fields
  • :page (String) -- The page to retrieve
  • :per_page (String) -- Number of projects to return per page

Parameters:
  • options (Hash) -- A customizable set of options.
def project_search(query, options = {})
  get('/projects', query: options.merge(search: query))
end

def project_template(project, type, key, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) -

Options Hash: (**options)
  • fullname(optional) (String) -- The full name of the copyright holder to use when expanding placeholders in the template. Only affects licenses
  • project(optional) (String) -- The project name to use when expanding placeholders in the template. Only affects licenses

Parameters:
  • options (Hash) -- A customizable set of options.
  • key (String) -- The key of the template, as obtained from the collection endpoint
  • type (String) -- The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template
  • project (Integer, String) -- The ID or URL-encoded path of the project.

Other tags:
    See: https://docs.gitlab.com/ce/api/project_templates.html -
def project_template(project, type, key, options = {})
  get("/projects/#{url_encode project}/templates/#{type}/#{key}", query: options)
end

def project_templates(project, type)

Returns:
  • (Array) -

Parameters:
  • type (String) -- The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template
  • id (Integer, String) -- The ID or URL-encoded path of the project.

Other tags:
    See: https://docs.gitlab.com/ce/api/project_templates.html -
def project_templates(project, type)
  get("/projects/#{url_encode project}/templates/#{type}")
end

def projects(options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :per_page (Integer) -- The number of results per page.
  • :page (Integer) -- The page number.

Parameters:
  • options (Hash) -- A customizable set of options.
def projects(options = {})
  get('/projects', query: options)
end

def push_rule(id)

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • id (Integer) -- The ID of a project.

Other tags:
    See: https://docs.gitlab.com/ee/api/projects.html#show-project-push-rules -
def push_rule(id)
  get("/projects/#{url_encode id}/push_rule")
end

def remove_forked(project)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about the forked project.

Parameters:
  • project (Integer) -- The ID of the project it is forked from
  • project (Integer, String) -- The ID or path of a project.
def remove_forked(project)
  delete("/projects/#{url_encode project}/fork")
end

def remove_team_member(project, id)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about removed team member.

Parameters:
  • options (Hash) -- A customizable set of options.
  • id (Integer) -- The ID of a user.
  • project (Integer, String) -- The ID or path of a project.
def remove_team_member(project, id)
  delete("/projects/#{url_encode project}/members/#{id}")
end

def share_project_with_group(project, id, group_access)

Parameters:
  • group_access (Integer) -- The access level to project.
  • id (Integer) -- The ID of a group.
  • project (Integer, String) -- The ID or path of a project.
def share_project_with_group(project, id, group_access)
  post("/projects/#{url_encode project}/share", body: { group_id: id, group_access: group_access })
end

def star_project(id)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about starred project.

Parameters:
  • id (Integer, String) -- The ID or path of a project.

Other tags:
    See: https://docs.gitlab.com/ce/api/projects.html#star-a-project -
def star_project(id)
  post("/projects/#{url_encode id}/star")
end

def team_member(project, id)

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • id (Integer) -- The ID of a project team member.
  • project (Integer, String) -- The ID or path of a project.
def team_member(project, id)
  get("/projects/#{url_encode project}/members/#{id}")
end

def team_members(project, options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :per_page (Integer) -- The number of results per page.
  • :page (Integer) -- The page number.
  • :query (String) -- The search query.

Parameters:
  • options (Hash) -- A customizable set of options.
  • project (Integer, String) -- The ID or path of a project.
def team_members(project, options = {})
  get("/projects/#{url_encode project}/members", query: options)
end

def transfer_project(project, namespace)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about transfered project.

Parameters:
  • namespace (Integer, String) -- The ID or path of the namespace to transfer to project to
  • project (Integer, String) -- The ID or path of a project
def transfer_project(project, namespace)
  put("/projects/#{url_encode project}/transfer", body: { namespace: namespace })
end

def unarchive_project(id)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about unarchived project.

Parameters:
  • id (Integer, String) -- The ID or path of a project.
def unarchive_project(id)
  post("/projects/#{url_encode id}/unarchive")
end

def unshare_project_with_group(project, id)

Returns:
  • (void) - This API call returns an empty response body.

Parameters:
  • id (Integer) -- The ID of a group.
  • project (Integer, String) -- The ID or path of a project.
def unshare_project_with_group(project, id)
  delete("/projects/#{url_encode project}/share/#{id}")
end

def unstar_project(id)

Returns:
  • (Gitlab::ObjectifiedHash) - Information about unstarred project.

Parameters:
  • id (Integer, String) -- The ID or path of a project.

Other tags:
    See: https://docs.gitlab.com/ce/api/projects.html#unstar-a-project -
def unstar_project(id)
  delete("/projects/#{url_encode id}/star")
end

def upload_file(id, file_fullpath)

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • file_fullpath (String) -- The fullpath of the file you are interested to upload.
  • id (Integer, String) -- The ID or path of a project.

Other tags:
    See: https://docs.gitlab.com/ee/api/projects.html#upload-a-file -
def upload_file(id, file_fullpath)
  post("/projects/#{url_encode id}/uploads", body: { file: File.open(file_fullpath, 'r') })
end

def user_projects(user_id, options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :sort (String) -- Return projects sorted in asc or desc order.
  • :order_by (String) -- Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.
  • :page (String) -- The page to retrieve
  • :per_page (String) -- Number of projects to return per page

Parameters:
  • options (Hash) -- A customizable set of options.
  • user_id (Integer, String) -- The ID or username of the user.

Other tags:
    See: https://docs.gitlab.com/ee/api/projects.html#list-user-projects -
def user_projects(user_id, options = {})
  get("/users/#{url_encode user_id}/projects", query: options)
end

def user_starred_projects(user_id, options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :sort (String) -- Return projects sorted in asc or desc order.
  • :order_by (String) -- Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.
  • :page (String) -- The page to retrieve
  • :per_page (String) -- Number of projects to return per page

Parameters:
  • options (Hash) -- A customizable set of options.
  • user_id (Integer, String) -- The ID or username of the user.

Other tags:
    See: https://docs.gitlab.com/ee/api/projects.html#list-projects-starred-by-a-user -
def user_starred_projects(user_id, options = {})
  get("/users/#{url_encode user_id}/starred_projects", query: options)
end