Struct gitlab_api::gitlab::GitLab
[−]
[src]
pub struct GitLab { /* fields omitted */ }
Methods
impl GitLab
[src]
fn _new(scheme: &str,
domain: &str,
port: u16,
private_token: &str)
-> Result<GitLab>
domain: &str,
port: u16,
private_token: &str)
-> Result<GitLab>
fn new_insecure(domain: &str, private_token: &str) -> Result<GitLab>
fn new(domain: &str, private_token: &str) -> Result<GitLab>
fn port(self, port: u16) -> Self
fn scheme(self, scheme: &str) -> Self
fn build_url(&self, query: &str) -> Result<String>
Build a URL used to access GitLab instance, including some parameters.
Examples
Example from GitLab: https://docs.gitlab.com/ce/api/#basic-usage
use gitlab_api::GitLab; let expected_url = "https://gitlab.example.com\ /api/v3/groups?order_by=path&private_token=XXXXXXXXXXXXXXXXXXXX"; let gl = GitLab::new("gitlab.example.com", "XXXXXXXXXXXXXXXXXXXX").unwrap(); assert_eq!(gl.build_url("groups?order_by=path").unwrap(), expected_url);
fn get<T, U>(&self, query: &str, page: U, per_page: U) -> Result<T> where T: Deserialize, U: Into<Option<u16>>
Perform an HTTP GET to the GitLab server from a specific query.
The query
is simply the string part appearing in the GET URL.
For example, for a GET https://www.example.com/projects/:id/merge_requests?iid=42
, the
query
is projects/:id/merge_requests?iid=42
.
The method can be paginated if page
and per_page
is provided.
Notes:
- This method is meant to be used internally;
- Until all
BuildQuery::build_query()
s useserde_urlencoded
, thequery
paramter will have to remain a string.
Returns a specific GitLab type, wrapped in a Result
.
fn version(&self) -> Result<Version>
fn groups(&self) -> GroupsLister
fn projects(&self) -> ProjectsLister
fn issues(&self) -> IssuesLister
fn merge_requests(&self, project_id: i64) -> MergeRequestsLister
fn get_project(&self, namespace: &str, name: &str) -> Result<Project>
Get a specific "namespace/name" project. NOTE: We can't search for "namespace/name", so we search for "name", and refine the match on the namespace. This means the operation could be slow as multiple query to the GitLab server might be required to find the right item.
fn get_issue(&self, namespace: &str, name: &str, iid: i64) -> Result<Issue>
Get a project issue from a its project's namespace
and name
and the issue's iid
.
Since GitLab uses unique id
s in its API and not iid
s, we will need to list issues
(grouped by pages of 20) until we find the proper issue matching the id
requested.
Note: A iid
is the issue number as seen by normal user, for example appearing on
a GitLab URL. This iid
can be used to reference an issue (in other issues, in commit
messages, etc.) by prepending a pound sign to it, for example #3
. An id
, instead, is
GitLab's internal and unique id associated with the issue.
Because we need to search (and thus query the GitLab server possibly multiple times), this can be a slow operation if there is many issues in the project.
fn get_merge_request(&self,
namespace: &str,
name: &str,
iid: i64)
-> Result<MergeRequest>
namespace: &str,
name: &str,
iid: i64)
-> Result<MergeRequest>
Get a project merge request from a its project's namespace
and name
and
the issue's iid
.
Since GitLab uses unique id
s in its API and not iid
s, we will need to
list issues (grouped by pages of 20) until we find the proper issue matching
the id
requested.
Note: A iid
is the issue number as seen by normal user, for example appearing on
a GitLab URL. This iid
can be used to reference an issue (in other issues, in commit
messages, etc.) by prepending a pound sign to it, for example #3
. An id
, instead, is
GitLab's internal and unique id associated with the issue.
Because we need to search (and thus query the GitLab server possibly multiple times), this can be a slow operation if there is many issues in the project.