Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NodeSharedCode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
Shared
NodeSharedCode
Commits
3af7942b
Commit
3af7942b
authored
1 year ago
by
michael.minelli
Committed by
michael.minelli
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
SharedGitlabManager => Add getUserById and ByUsername functions
parent
cb2f81e5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
managers/SharedGitlabManager.ts
+36
-7
36 additions, 7 deletions
managers/SharedGitlabManager.ts
with
36 additions
and
7 deletions
managers/SharedGitlabManager.ts
+
36
−
7
View file @
3af7942b
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
SharedConfig
from
'
../config/SharedConfig
'
;
import
SharedConfig
from
'
../config/SharedConfig
'
;
import
*
as
GitlabCore
from
'
@gitbeaker/core
'
;
import
*
as
GitlabCore
from
'
@gitbeaker/core
'
;
import
{
GitbeakerRequestError
}
from
'
@gitbeaker/requester-utils
'
;
import
{
GitbeakerRequestError
}
from
'
@gitbeaker/requester-utils
'
;
import
{
Gitlab
,
PipelineSchema
}
from
'
@gitbeaker/rest
'
;
import
{
Gitlab
,
PipelineSchema
,
UserSchema
}
from
'
@gitbeaker/rest
'
;
import
GitlabToken
from
'
../types/Gitlab/GitlabToken
'
;
import
GitlabToken
from
'
../types/Gitlab/GitlabToken
'
;
import
{
StatusCodes
}
from
'
http-status-codes
'
;
import
{
StatusCodes
}
from
'
http-status-codes
'
;
class
SharedGitlabManager
{
class
SharedGitlabManager
{
...
@@ -50,6 +50,35 @@ class SharedGitlabManager {
...
@@ -50,6 +50,35 @@ class SharedGitlabManager {
return
response
.
data
;
return
response
.
data
;
}
}
public
async
getUserById
(
id
:
number
):
Promise
<
UserSchema
|
undefined
>
{
try
{
return
await
this
.
executeGitlabRequest
(
async
()
=>
{
const
user
=
await
this
.
api
.
Users
.
show
(
id
);
return
user
.
id
===
id
?
user
:
undefined
;
});
}
catch
(
e
)
{
return
undefined
;
}
}
public
async
getUserByUsername
(
username
:
string
):
Promise
<
UserSchema
|
undefined
>
{
try
{
return
await
this
.
executeGitlabRequest
(
async
()
=>
{
const
user
=
await
this
.
api
.
Users
.
all
({
username
:
username
,
maxPages
:
1
,
perPage
:
1
});
return
user
.
length
>
0
&&
user
[
0
].
username
===
username
?
user
[
0
]
:
undefined
;
});
}
catch
(
e
)
{
return
undefined
;
}
}
async
getRepositoryPipelines
(
repoId
:
number
,
branch
:
string
=
'
main
'
):
Promise
<
Array
<
PipelineSchema
>>
{
async
getRepositoryPipelines
(
repoId
:
number
,
branch
:
string
=
'
main
'
):
Promise
<
Array
<
PipelineSchema
>>
{
return
await
this
.
executeGitlabRequest
(
async
()
=>
{
return
await
this
.
executeGitlabRequest
(
async
()
=>
{
return
await
this
.
api
.
Pipelines
.
all
(
repoId
,
{
return
await
this
.
api
.
Pipelines
.
all
(
repoId
,
{
...
...
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