gitlab
Module gitlab
![](https://bcentral-packageicons.azureedge.net/images/ballerinax_gitlab_1.2.0.png)
ballerinax/gitlab Ballerina library
Overview
This is a generated connector for GitLab GitLab REST API v4 OpenAPI specification.
Client endpoint for GitLab API currently supports operations related to access requests and access tokens in GitLab.
Prerequisites
- Create a GitLab account
- Obtain tokens
- Use this guide to obtain the PAT tokens related to your account
Quickstart
To use the GitLab connector in your Ballerina application, update the .bal file as follows:
Step 1 - Import connector
First, import the ballerinax/gitlab module into the Ballerina project.
import ballerinax/gitlab;
Step 2 - Create a new connector instance
You can now make the connection configuration using the PAT token
gitlab:ApiKeysConfig apiKeyConfig = { "privateToken": <GITLAB_PAT_TOKEN> }; gitlab:Client baseClient = check new Client(apiKeyConfig);
Step 3 - Invoke connector operation
- Get Version Information
public function main() { gitlab:VersionResponse|error gitVersion = baseClient->getVersion(); if (gitVersion is gitlab:VersionResponse) { log:printInfo("Git version " + gitVersion?.'version.toString()); } }
- Use
bal run
command to compile and run the Ballerina program
Clients![](/images/permalink.svg)
gitlab: Client![](/images/permalink.svg)
This is a generated connector for GitLab GitLab REST API v4 OpenAPI specification.
Client endpoint for GitLab API currently supports operations related to access requests and access tokens in GitLab.
Constructor![](/images/permalink.svg)
Gets invoked to initialize the connector
.
The connector initialization requires setting the API credentials.
Create a GitLab account and obtain tokens following this guide.
init (ApiKeysConfig apiKeyConfig, ClientConfiguration clientConfig, string serviceUrl)
- apiKeyConfig ApiKeysConfig - API keys for authorization
- clientConfig ClientConfiguration {} - The configurations to be used when initializing the
connector
- serviceUrl string "https://gitlab.com/api/" - URL of the target service
getVersion![](/images/permalink.svg)
function getVersion() returns VersionResponse|error
Retrieve version information for this GitLab instance.
Return Type
- VersionResponse|error - Successful
accessrequestsprojectsGet![](/images/permalink.svg)
function accessrequestsprojectsGet(string id) returns ProjectAccessResponse|error
List access requests for a project
Parameters
- id string - The ID or URL-encoded path of the project owned by the authenticated userr.
Return Type
- ProjectAccessResponse|error - Successful
accessrequestsprojectsPost![](/images/permalink.svg)
function accessrequestsprojectsPost(string id) returns ProjectAccessRequest|error
Requests access for the authenticated user to a project
Parameters
- id string - The ID or URL-encoded path of the project owned by the authenticated user.
Return Type
- ProjectAccessRequest|error - Successful
accessrequestsprojectsapprovePut![](/images/permalink.svg)
function accessrequestsprojectsapprovePut(string id, int userId, int accessLevel) returns ProjectAccessApprove|error
Approves access for the authenticated user to a project
Parameters
- id string - The ID or URL-encoded path of the project owned by the authenticated user.
- userId int - The userID of the access requester
- accessLevel int (default 30) - A valid project access level. 0 = no access , 10 = guest, 20 = reporter, 30 = developer, 40 = Maintainer. Default is 30.'
Return Type
- ProjectAccessApprove|error - Successful
accessrequestprojectsdenyDelete![](/images/permalink.svg)
Denies a project access request for the given user
Parameters
- id string - The ID or URL-encoded path of the project owned by the authenticated user.
- userId int - The user ID of the access requester
accessrequestsgroupsGet![](/images/permalink.svg)
function accessrequestsgroupsGet(string id) returns GroupAccessResponse|error
List access requests for a group
Parameters
- id string - The ID or URL-encoded path of the group owned by the authenticated user.
Return Type
- GroupAccessResponse|error - Successful
accessrequestsgroupsPost![](/images/permalink.svg)
function accessrequestsgroupsPost(string id) returns GroupAccessRequest|error
Requests access for the authenticated user to a group
Parameters
- id string - The ID or URL-encoded path of the group owned by the authenticated user.
Return Type
- GroupAccessRequest|error - Successful
accessrequestsgroupsapprovePut![](/images/permalink.svg)
function accessrequestsgroupsapprovePut(string id, int userId, int accessLevel) returns GroupAccessApprove|error
Approves access for the authenticated user to a group
Parameters
- id string - The ID or URL-encoded path of the group owned by the authenticated user.
- userId int - The userID of the access requester
- accessLevel int (default 30) - A valid group access level. 0 = no access , 10 = Guest, 20 = Reporter, 30 = Developer, 40 = Maintainer, 50 = Owner. Default is 30.
Return Type
- GroupAccessApprove|error - Successful
accessrequestsgroupsdenyDelete![](/images/permalink.svg)
Denies a group access request for the given user
Parameters
- id string - The ID or URL-encoded path of the group owned by the authenticated user.
- userId int - The userID of the access requester
accesstokensGet![](/images/permalink.svg)
function accesstokensGet(string id) returns AccessToken|error
List access tokens for a project
Parameters
- id string - The ID or URL-encoded path of the project
Return Type
- AccessToken|error - Successful
accesstokensPost![](/images/permalink.svg)
function accesstokensPost(string id, string name, string[] scopes, string? expiresAt) returns AccessTokenList|error
Creates an access token for a project
Parameters
- id string - The ID or URL-encoded path of the project
- name string - The name of the project access token
- scopes string[] - Defines read and write permissions for the token
- expiresAt string? (default ()) - Date when the token expires. Time of day is Midnight UTC of that date.
Return Type
- AccessTokenList|error - Successful
accesstokensDelete![](/images/permalink.svg)
Revokes an access token
Records![](/images/permalink.svg)
gitlab: AccessToken![](/images/permalink.svg)
Access token info
Fields
- user_id int? - User ID
- name string? - The name of the project access token
- expires_at string? - The token expires at midnight UTC on that date
- id int? - The ID or URL-encoded path of the project
- active boolean? - If token is active or not
- created_at string? - The token creation date/time
- revoked boolean? - Is the token is revoked
gitlab: AccessTokenList![](/images/permalink.svg)
Access token info
Fields
- user_id int? - User ID
- name string? - The name of the project access token
- expires_at string? - The token expires at midnight UTC on that date
- id int? - The ID or URL-encoded path of the project
- active boolean? - If token is active or not
- created_at string? - The token creation date/time
- revoked boolean? - Is the token is revoked
gitlab: ApiKeysConfig![](/images/permalink.svg)
Provides API key configurations needed when communicating with a remote HTTP endpoint.
Fields
- privateToken string - Represents API Key
Private-Token
gitlab: GroupAccessApprove![](/images/permalink.svg)
Access request info
Fields
- id int? - The ID or URL-encoded path of the project owned by the authenticated user
- username string? - Username
- name string? - Actual name
- state string? - If user is active or not
- created_at string? - Created date/time
- access_level int? - A valid access level (defaults: 30, the Developer role)
gitlab: GroupAccessRequest![](/images/permalink.svg)
Access request info
Fields
- id int? - The ID or URL-encoded path of the project owned by the authenticated user
- username string? - Username
- name string? - Actual name
- state string? - If user is active or not
- created_at string? - Created date/time
- requested_at string? - Requested date/time
gitlab: GroupAccessResponse![](/images/permalink.svg)
Access request info
Fields
- id int? - The ID or URL-encoded path of the project owned by the authenticated user
- username string? - Username
- name string? - Actual name
- state string? - If user is active or not
- created_at string? - Created date/time
- requested_at string? - Requested date/time
gitlab: ProjectAccessApprove![](/images/permalink.svg)
Access request info
Fields
- id int? - The ID or URL-encoded path of the project owned by the authenticated user
- username string? - Username
- name string? - Actual name
- state string? - If user is active or not
- created_at string? - Created date/time
- access_level int? - A valid access level (defaults: 30, the Developer role)
gitlab: ProjectAccessRequest![](/images/permalink.svg)
Access request info
Fields
- id int? - The ID or URL-encoded path of the project owned by the authenticated user
- username string? - Username
- name string? - Actual name
- state string? - If user is active or not
- created_at string? - Created date/time
- requested_at string? - Requested date/time
gitlab: ProjectAccessResponse![](/images/permalink.svg)
Access request info
Fields
- id int? - The ID or URL-encoded path of the project owned by the authenticated user
- username string? - Username
- name string? - Actual name
- state string? - If user is active or not
- created_at string? - Created date/time
- requested_at string? - Requested date/time
gitlab: VersionResponse![](/images/permalink.svg)
GitLab version info
Fields
- 'version string? - GitLab version
- revision string? - Revision number
Import
import ballerinax/gitlab;
Metadata
Released date: over 2 years ago
Version: 1.2.0
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: 2201.0.0
GraalVM compatible: Yes
Pull count
Total: 1
Current verison: 0
Weekly downloads
Keywords
IT Operations/Source Control
Cost/Freemium
Contributors
Dependencies