diff --git a/src/Api.php b/src/Api.php index 412a8300e74069cd828036ca171fad0deb15a58d..0cd3052265de474fbaa16496eb8004782a3c5bdd 100644 --- a/src/Api.php +++ b/src/Api.php @@ -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. * @@ -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. * @@ -163,11 +156,13 @@ class Api { * * @return array * 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 { $this->init(); - return $this->client->projects() - ->createPipeline($project_id, $commit_ref, $variables); + return $this->client->projects()->createPipeline($project_id, $commit_ref, $variables); } /** @@ -211,7 +206,9 @@ class Api { * * @return array * 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 { $this->init(); return $this->client->namespaces()->all(); @@ -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. * @@ -329,6 +298,9 @@ class Api { * * @return array * 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 { $this->init(); @@ -345,6 +317,9 @@ class Api { * * @return array * 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 { $this->init(); @@ -453,6 +428,9 @@ class Api { * * @return array * 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 { $this->init(); @@ -469,6 +447,9 @@ class Api { * * @return array * 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 { $this->init(); @@ -495,20 +476,6 @@ class Api { 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. * @@ -548,58 +515,6 @@ class Api { 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. * @@ -639,38 +554,4 @@ class Api { 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); - } - }