Skip to content
Snippets Groups Projects
Commit 5370e91d authored by Jürgen Haas's avatar Jürgen Haas
Browse files

Issue #3384270 by jurgenhaas: Provide access to all methods of the GitLab client

parent 7f266f93
No related branches found
No related tags found
No related merge requests found
...@@ -62,6 +62,17 @@ class Api { ...@@ -62,6 +62,17 @@ class Api {
} }
} }
/**
* Return the initialized client for the current server.
*
* @return \Gitlab\Client
* The initialized client.
*/
public function getClient(): Client {
$this->init();
return $this->client;
}
/** /**
* Allow to switch between gitlab server. * Allow to switch between gitlab server.
* *
...@@ -105,24 +116,6 @@ class Api { ...@@ -105,24 +116,6 @@ class Api {
]); ]);
} }
/**
* Create a new project branch.
*
* @param int $project_id
* The project ID.
* @param string $branch
* The new branch.
* @param string $ref
* The optional branch from which the new one should be created.
*
* @return array
* The new branch.
*/
public function createBranch(int $project_id, string $branch, string $ref = 'main'): array {
$this->init();
return $this->client->repositories()->createBranch($project_id, $branch, 'main');
}
/** /**
* Creates a commit to CRUD file(s) in the repository. * Creates a commit to CRUD file(s) in the repository.
* *
...@@ -163,11 +156,13 @@ class Api { ...@@ -163,11 +156,13 @@ class Api {
* *
* @return array * @return array
* The created pipeline. * The created pipeline.
*
* @deprecated in gitlab_api:2.1.2 and is removed from gitlab_apit:2.2.0.
* Use ::getClient()->createPipeline() instead.
*/ */
public function createPipeline(int $project_id, string $commit_ref, array $variables = []): array { public function createPipeline(int $project_id, string $commit_ref, array $variables = []): array {
$this->init(); $this->init();
return $this->client->projects() return $this->client->projects()->createPipeline($project_id, $commit_ref, $variables);
->createPipeline($project_id, $commit_ref, $variables);
} }
/** /**
...@@ -211,7 +206,9 @@ class Api { ...@@ -211,7 +206,9 @@ class Api {
* *
* @return array * @return array
* The list of namespaces. * The list of namespaces.
*/ *
* @deprecated in gitlab_api:2.1.2 and is removed from gitlab_apit:2.2.0.
* Use ::getClient()->namespaces()->all() instead. */
public function namespaces(): array { public function namespaces(): array {
$this->init(); $this->init();
return $this->client->namespaces()->all(); return $this->client->namespaces()->all();
...@@ -249,34 +246,6 @@ class Api { ...@@ -249,34 +246,6 @@ class Api {
} }
} }
/**
* Gets a list of projects from a given group.
*
* @param int $group_id
* The ID of the group.
* @param bool $simple
* If TRUE, only limited number of fields for each projects get returned.
* @param bool $includeArchived
* If TRUE, also archived projects will be returned.
* @param array $additionalParams
* Optional extra arguments.
*
* @return array
* The list of projects.
*/
public function groupProjects(int $group_id, bool $simple = TRUE, bool $includeArchived = FALSE, array $additionalParams = []): array {
$this->init();
$params = [
'simple' => $simple,
'archived' => FALSE,
];
if ($includeArchived) {
unset($params['archived']);
}
$params += $additionalParams;
return $this->client->groups()->projects($group_id, $params);
}
/** /**
* Gets a project. * Gets a project.
* *
...@@ -329,6 +298,9 @@ class Api { ...@@ -329,6 +298,9 @@ class Api {
* *
* @return array * @return array
* The project pipeline. * The project pipeline.
*
* @deprecated in gitlab_api:2.1.2 and is removed from gitlab_apit:2.2.0.
* Use ::getClient()->projects()->pipeline() instead.
*/ */
public function pipeline(int $project_id, int $pipeline_id): array { public function pipeline(int $project_id, int $pipeline_id): array {
$this->init(); $this->init();
...@@ -345,6 +317,9 @@ class Api { ...@@ -345,6 +317,9 @@ class Api {
* *
* @return array * @return array
* The list of pipeline jobs. * The list of pipeline jobs.
*
* @deprecated in gitlab_api:2.1.2 and is removed from gitlab_apit:2.2.0.
* Use ::getClient()->pipelineJobs() instead.
*/ */
public function jobs(int $project_id, int $pipeline_id): array { public function jobs(int $project_id, int $pipeline_id): array {
$this->init(); $this->init();
...@@ -453,6 +428,9 @@ class Api { ...@@ -453,6 +428,9 @@ class Api {
* *
* @return array * @return array
* The list of branches. * The list of branches.
*
* @deprecated in gitlab_api:2.1.2 and is removed from gitlab_apit:2.2.0.
* Use ::getClient()->repositories()->branches() instead.
*/ */
public function branches(int $project_id): array { public function branches(int $project_id): array {
$this->init(); $this->init();
...@@ -469,6 +447,9 @@ class Api { ...@@ -469,6 +447,9 @@ class Api {
* *
* @return array * @return array
* The branch. * The branch.
*
* @deprecated in gitlab_api:2.1.2 and is removed from gitlab_apit:2.2.0.
* Use ::getClient()->repositories()->branch instead.
*/ */
public function branch(int $project_id, string $branch): array { public function branch(int $project_id, string $branch): array {
$this->init(); $this->init();
...@@ -495,20 +476,6 @@ class Api { ...@@ -495,20 +476,6 @@ class Api {
return $topics; return $topics;
} }
/**
* Receives all variables of the project.
*
* @param int $project_id
* The project ID.
*
* @return array
* The list of variables.
*/
public function projectVariables(int $project_id): array {
$this->init();
return $this->client->projects()->variables($project_id);
}
/** /**
* Receives a project variable. * Receives a project variable.
* *
...@@ -548,58 +515,6 @@ class Api { ...@@ -548,58 +515,6 @@ class Api {
return NULL; return NULL;
} }
/**
* Adds a new project variable.
*
* @param int $project_id
* The project ID.
* @param string $key
* The variable key.
* @param string $value
* The variable value.
* @param bool|null $protected
* Whether the variable should be protected.
* @param string|null $environment_scope
* The environment scope.
*/
public function addProjectVariable(int $project_id, string $key, string $value, ?bool $protected = null, ?string $environment_scope = null): void {
$this->init();
$this->client->projects()->addVariable($project_id, $key, $value, $protected, $environment_scope);
}
/**
* Update an existing project variable.
*
* @param int $project_id
* The project ID.
* @param string $key
* The variable key.
* @param string $value
* The variable value.
* @param bool|null $protected
* Whether the variable should be protected.
* @param string|null $environment_scope
* The environment scope.
*/
public function updateProjectVariable(int $project_id, string $key, string $value, ?bool $protected = null, ?string $environment_scope = null): void {
$this->init();
$this->client->projects()->updateVariable($project_id, $key, $value, $protected, $environment_scope);
}
/**
* Receives all variables of the group.
*
* @param int $group_id
* The group ID.
*
* @return array
* The list of variables.
*/
public function groupVariables(int $group_id): array {
$this->init();
return $this->client->groups()->variables($group_id);
}
/** /**
* Receives a group variable. * Receives a group variable.
* *
...@@ -639,38 +554,4 @@ class Api { ...@@ -639,38 +554,4 @@ class Api {
return NULL; return NULL;
} }
/**
* Adds a new group variable.
*
* @param int $group_id
* The group ID.
* @param string $key
* The variable key.
* @param string $value
* The variable value.
* @param bool|null $protected
* Whether the variable should be protected.
*/
public function addGroupVariable(int $group_id, string $key, string $value, ?bool $protected = null): void {
$this->init();
$this->client->groups()->addVariable($group_id, $key, $value, $protected);
}
/**
* Update an existing group variable.
*
* @param int $group_id
* The group ID.
* @param string $key
* The variable key.
* @param string $value
* The variable value.
* @param bool|null $protected
* Whether the variable should be protected.
*/
public function updateGroupVariable(int $group_id, string $key, string $value, ?bool $protected = null): void {
$this->init();
$this->client->groups()->updateVariable($group_id, $key, $value, $protected);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment