Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab_api
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
gitlab_api
Commits
5370e91d
Commit
5370e91d
authored
1 year ago
by
Jürgen Haas
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Api.php
+30
-149
30 additions, 149 deletions
src/Api.php
with
30 additions
and
149 deletions
src/Api.php
+
30
−
149
View file @
5370e91d
...
@@ -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
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment