module Gitlab::Client::Project

Overview

Defines methods related to project.

Project visibility level

Project in GitLab has be either private, internal or public. You can determine it by visibility_level field in project.

Constants for project visibility levels are next:

See http://docs.gitlab.com/ce/api/projects.html

Direct including types

Defined in:

gitlab/client/project.cr

Instance Method Summary

Instance Method Detail

def add_project_hook(project : Int32 | String, url : String, form : Hash = {} of String => String) : JSON::Any #

Create a web hook of a project.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [String] url The url of a web hook.
  • param [Hash] form A customizable set of options.
  • option form [String] :push_events Trigger hook on push events.
  • option form [String] :issues_events Trigger hook on issues events.
  • option form [String] :merge_requests_events Trigger hook on merge_requests events.
  • option form [String] :tag_push_events Trigger hook on push_tag events.
  • option form [String] :note_events Trigger hook on note events.
  • option form [String] :enable_ssl_verification Do SSL verification when triggering the hook.
  • return [JSON::Any] Information about the created web hook.
client.add_project_hook(42, "https://hooks.slack.com/services/xxx")
client.add_project_hook('gitlab', "https://hooks.slack.com/services/xxx", { "issues_events" => "true" })

[View source]
def add_project_member(project : Int32 | String, user_id : Int32, access_level : Int32) : JSON::Any #

Adds a user to project team.

  • param [Int32, String] project_id The ID or name of a project.
  • param [Int32] user_id The ID of a user.
  • param [Int32] access_level The access level to project.
  • return [JSON::Any] Information about added team member.
client.add_project_member('gitlab', 2, 40)

[View source]
def all_projects(params : Hash = {} of String => String) : JSON::Any #

Gets a list of projects by the authenticated user (admin only).

Alias to #projects({ "scope" => "all" })

client.all_projects
client.all_projects({"order_by" => "last_activity_at", "sort" => "desc"})
client.all_projects({"search" => "keyword"})

[View source]
def archive_project(project : Int32 | String) : JSON::Any #

Archive a project.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • return [JSON::Any] Information about the archive project.
client.archive_project(42)

[View source]
def create_fork_from(project : Int32 | String, forked_from_id : Int32) : JSON::Any #

Create a forked from/to relation between existing projects. Available only for admins.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Hash] branch The name of a branch.
  • return [JSON::Any] Information about the forked project.
client.create_fork_from(1, 21)

[View source]
def create_project(user_id : Int32, name : String, params : Hash = {} of String => String) : JSON::Any #

Creates a new project for a user.

Alias to #create_project(params : Hash = {} of String => String)

client.create_project(1, "gitlab")
client.create_project(1, "gitlab", { "description: => "Awesome project" })

[View source]
def create_project(name : String, form : Hash = {} of String => String) : JSON::Any #

Creates a new project.

  • params [String] name The name of a project.
  • params [Hash] form A customizable set of options.
  • option form [String] :description The description of a project.
  • option form [String] :default_branch The default branch of a project.
  • option form [String] :namespace_id The namespace in which to create a project.
  • option form [String] :wiki_enabled The wiki integration for a project (0 = false, 1 = true).
  • option form [String] :wall_enabled The wall functionality for a project (0 = false, 1 = true).
  • option form [String] :issues_enabled The issues integration for a project (0 = false, 1 = true).
  • option form [String] :snippets_enabled The snippets integration for a project (0 = false, 1 = true).
  • option form [String] :merge_requests_enabled The merge requests functionality for a project (0 = false, 1 = true).
  • option form [String] :public The setting for making a project public (0 = false, 1 = true).
  • option form [String] :user_id The user/owner id of a project.
  • return [JSON::Any] Information about created project.
client.create_project("gitlab")
client.create_project("viking", { "description: => "Awesome project" })
client.create_project("Red", { "wall_enabled" => "false" })

[View source]
def delete_project(project : Int32 | String) : JSON::Any #

Deletes a project.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • return [JSON::Any] Information about the deleted project.
client.delete_project(42)

[View source]
def edit_project(project : Int32 | String, form : Hash = {} of String => String) : JSON::Any #

Updates an existing project.

  • params [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • params [Hash] form A customizable set of options.
  • option form [String] :name The name of a project.
  • option form [String] :path The name of a project.
  • option form [String] :description The name of a project.
  • return [JSON::Any] Information about the edited project.
client.edit_project(42)
client.edit_project(42, {"name" => "project_name"})

[View source]
def edit_project_hook(project : Int32 | String, hook_id : Int32, url : String, form : Hash = {} of String => String) : JSON::Any #

Updates a web hook of a project.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Int32] hook_id The ID of a web hook.
  • param [Int32] url The url of a web hook.
  • param [Hash] form A customizable set of options.
  • option form [String] :push_events Trigger hook on push events.
  • option form [String] :issues_events Trigger hook on issues events.
  • option form [String] :merge_requests_events Trigger hook on merge_requests events.
  • option form [String] :tag_push_events Trigger hook on push_tag events.
  • option form [String] :note_events Trigger hook on note events.
  • option form [String] :enable_ssl_verification Do SSL verification when triggering the hook.
  • return [JSON::Any] Information about updated web hook.
client.edit_project_hook('gitlab', 3, "https://hooks.slack.com/services/xxx")

[View source]
def edit_project_member(project : Int32 | String, user_id, access_level) : JSON::Any #

Updates a team member's project access level.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Int32] user_id The ID of a user.
  • param [Int32] access_level The access level to project.
  • return [JSON::Any] Information about updated team member.
client.edit_project_member('gitlab', 3, 20)

[View source]
def fork_project(project : Int32 | String, form : Hash = {} of String => String) : JSON::Any #

Forks a project into the user namespace.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Hash] form A customizable set of options.
  • option form [String] :sudo The username the project will be forked for.
  • return [JSON::Any] Information about the forked project.
client.create_fork(42)
client.create_fork(42, {"sudo" => "another_username"})

[View source]
def owned_projects(params : Hash | Nil = {} of String => String) : JSON::Any #

Gets a list of projects owned by the authenticated user.

Alias to #projects({ "scope" => "owned" })

client.owned_projects
client.owned_projects({"order_by" => "last_activity_at", "sort" => "desc"})
client.owned_projects({"search" => "keyword"})

[View source]
def project(project : Int32 | String) : JSON::Any #

Gets information about a project.

  • params [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • return [JSON::Any] Information about project.
client.project("gitlab")

[View source]
def project_branch(project : Int32 | String, branch : String) : JSON::Any #

Get a branch of a project.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Int32] branch The name of a branch.
  • return [JSON::Any] Information about the branch under a project.
client.project_branch(42)
client.project_branch('gitlab', "develop")

[View source]
def project_branchs(project : Int32 | String, params : Hash = {} of String => String) : JSON::Any #

Get a list of a project's branches.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Hash] options A customizable set of options.
  • option options [Int32] :page The page number.
  • option options [Int32] :per_page The number of results per page.
  • return [JSON::Any] List of branches under a project.
client.project_branchs(42)
client.project_branchs('gitlab', { "per_page" => "4" })

[View source]
def project_events(project : Int32 | String, params : Hash | Nil = nil) : JSON::Any #

Gets a list of project events.

  • params [Int32, String] project The ID of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • params [Hash] options A customizable set of options.
  • option params [Int32] :page The page number.
  • option params [Int32] :per_page The number of results per page.
  • return [JSON::Any] List of events under a project.
client.project_events(42)

[View source]
def project_hook(project : Int32 | String, hook_id : Int32) : JSON::Any #

Get a web hook of a project.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Int32] hook_id The ID of a web hook.
  • return [JSON::Any] Information about the web hook.
client.project_hook(42)
client.project_hook('gitlab', 1)

[View source]
def project_hooks(project : Int32 | String, params : Hash | Nil = nil) : JSON::Any #

Get a list of a project's web hooks.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Hash] params A customizable set of options.
  • option params [Int32] :page The page number.
  • option params [Int32] :per_page The number of results per page.
  • return [JSON::Any] List of web hooks under a project.
client.project_hooks(42)
client.project_hooks('gitlab', { "per_page" => "4" })

[View source]
def project_member(project : Int32 | String, user_id : Int32) : JSON::Any #

Gets a project team member.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Int32] user_id The ID of a project team member.
  • return [JSON::Any] Information about member under a project.
client.project_member(1, 2)

[View source]
def project_members(project : Int32 | String, params : Hash = {} of String => String) : JSON::Any #

Get a list of a project's team members.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Hash] options A customizable set of options.
  • option options [String] :query The search query.
  • option options [Int32] :page The page number.
  • option options [Int32] :per_page The number of results per page.
  • return [JSON::Any] List of team members under a project.
client.project_members(42)
client.project_members('gitlab')

[View source]
def project_search(query, params : Hash = {} of String => String) : JSON::Any #

Search for project by name

  • param [String] query A string to search for in group names and paths.
  • param [Hash] params A customizable set of params.
  • option params [String] :per_page Number of projects to return per page.
  • option params [String] :page The page to retrieve.
  • option params [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields.
  • option params [String] :sort Return requests sorted in asc or desc order.
  • return [JSON::Any] List of projects under search qyery.
client.project_search("gitlab")
client.project_search("gitlab", {"per_page" => 50})

[View source]
def projects(params : Hash = {} of String => String) : JSON::Any #

Gets single issue in the project.

  • params [Hash] params A customizable set of params.
  • option params [String] :scope Scope of projects. "owned" for list of projects owned by the authenticated user, "starred" for list of projects starred by the authenticated user, "all" to get all projects (admin only)
  • option params [String] :archived if passed, limit by archived status.
  • option params [String] :visibility if passed, limit by visibility public, internal, private.
  • option params [String] :order_by Return requests ordered by id, name, path, created_at, updated_at or last_activity_at fields. Default is created_at.
  • option params [String] :sort Return requests sorted in asc or desc order. Default is desc.
  • option params [String] :search Return list of authorized projects according to a search criteria.
  • option params [Int32] :page The page number.
  • option params [Int32] :per_page The number of results per page.
  • return [JSON::Any] List of projects of the authorized user.
client.projects
client.projects({"order_by" => "last_activity_at", "sort" => "desc"})
client.projects({"scope" => "starred", "search" => "keyword"})

[View source]
def protect_project_branch(project : Int32 | String, branch : String) : JSON::Any #

Protect a branch of a project.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Hash] branch The name of a branch.
  • return [JSON::Any] Information about the protected branch.
client.protect_project_branch(2, "master")
client.protect_project_branch("gitlab", "master")

[View source]
def remove_fork(project : Int32 | String) : JSON::Any #

Delete an existing forked from relationship. Available only for admins.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • return [JSON::Any] Information about the unforked project.
client.remove_fork(1)

[View source]
def remove_project_hook(project : Int32 | String, hook_id : Int32) : JSON::Any | Nil #

Removes a user from project team.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Int32] hook_id The ID of a web hook.
  • return [JSON::Any | Nil] Information about removed web hook.
client.remove_project_hook('gitlab', 2)
client.remove_project_hook(1, 2)

[View source]
def remove_project_member(project : Int32 | String, user_id : Int32) : JSON::Any #

Removes a user from project team.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Int32] user_id The ID of a user.
  • return [JSON::Any] Information about removed team member.
client.remove_project_member('gitlab', 2)

[View source]
def share_project(project : Int32 | String, group_id : Int32, group_access = nil) : JSON::Any #

Share a project with a group.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Hash] options A customizable set of options.
  • option options [String] :sudo The username the project will be forked for.
  • return [JSON::Any] Information about the share project.
client.share_project(2, 1)
client.share_project(2, 1, {"group_access" => "50"})

[View source]
def star_project(project : Int32 | String) : JSON::Any #

Star a project for the authentication user.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • return [JSON::Any] Information about the starred project.
client.star_project(42)

[View source]
def starred_projects(params : Hash = {} of String => String) : JSON::Any #

Gets a list of projects starred by the authenticated user.

Alias to #projects({ "scope" => "starred" })

client.starred_projects
client.starred_projects({"order_by" => "last_activity_at", "sort" => "desc"})
client.starred_projects({"search" => "keyword"})

[View source]
def unarchive_project(project : Int32 | String) : JSON::Any #

Unarchive a project.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • return [JSON::Any] Information about the unarchive project.
client.unarchive_project(42)

[View source]
def unprotect_project_branch(project : Int32 | String, branch : String) : JSON::Any #

Unprotect a branch of a project.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [Hash] branch The name of a branch.
  • return [JSON::Any] Information about the unprotect branch.
client.unprotect_project_branch(2, "master")
client.unprotect_project_branch("gitlab", "master")

[View source]
def unstar_project(project : Int32 | String) : JSON::Any #

Unstar a project.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • return [JSON::Any] Information about the unstar project.
client.unstar_project(42)

[View source]
def upload_file(project : Int32 | String, file : String) : JSON::Any #

Upload a file in a project

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

Note: The returned url is relative to the project path. In Markdown contexts, the link is automatically expanded when the format in markdown is used.

  • param [Int32, String] project The ID or name of a project. If using namespaced projects call make sure that the NAMESPACE/PROJECT_NAME is URL-encoded.
  • param [String] file The path of a file.
  • return [JSON::Any] Information about the uploaded file.
client.upload_file(1, "/Users/icyleaf/Desktop/snippets_ruby.rb")
client.upload_file(1, "/Users/icyleaf/Desktop/screenshot.png")
client.upload_file(1, "/Users/icyleaf/Desktop/archive.zip")

[View source]
def upload_file(project : Int32 | String, file : File) : JSON::Any #

Same as #upload_file


[View source]