Class GitLabApi
- java.lang.Object
-
- org.gitlab4j.api.GitLabApi
-
public class GitLabApi extends Object
This class is provides a simplified interface to a GitLab API server, and divides the API up into a separate API class for each concern.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GitLabApi.ApiVersion
Specifies the version of the GitLab API to communicate with.
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_PER_PAGE
GitLab4J default per page.
-
Constructor Summary
Constructors Constructor Description GitLabApi(String hostUrl, String privateToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.GitLabApi(String hostUrl, String privateToken, String secretToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.GitLabApi(String hostUrl, String privateToken, String secretToken, Map<String,Object> clientConfigProperties)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.GitLabApi(String hostUrl, Constants.TokenType tokenType, String authToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.GitLabApi(String hostUrl, Constants.TokenType tokenType, String authToken, String secretToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.GitLabApi(String hostUrl, Constants.TokenType tokenType, String authToken, String secretToken, Map<String,Object> clientConfigProperties)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.GitLabApi(String hostUrl, Session session)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, String privateToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, String privateToken, String secretToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, String privateToken, String secretToken, Map<String,Object> clientConfigProperties)
Constructs a GitLabApi instance set up to interact with the GitLab server specified by GitLab API version.GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, Constants.TokenType tokenType, String authToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, Constants.TokenType tokenType, String authToken, String secretToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, Constants.TokenType tokenType, String authToken, String secretToken, Map<String,Object> clientConfigProperties)
Constructs a GitLabApi instance set up to interact with the GitLab server specified by GitLab API version.GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, Session session)
Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.
-
Method Summary
Modifier and Type Method Description protected static <T> Optional<T>
createOptionalFromException(GitLabApiException glae)
Create and return an Optional instance associated with a GitLabApiException.GitLabApi
duplicate()
Create a new GitLabApi instance that is logically a duplicate of this instance, with the exception off sudo state.void
enableRequestResponseLogging()
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance and Level.FINE as the level.void
enableRequestResponseLogging(Level level)
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance.void
enableRequestResponseLogging(Level level, int maxEntitySize)
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance.void
enableRequestResponseLogging(Level level, int maxEntitySize, List<String> maskedHeaderNames)
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance.void
enableRequestResponseLogging(Level level, List<String> maskedHeaderNames)
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance.void
enableRequestResponseLogging(Logger logger, Level level)
Enable the logging of the requests to and the responses from the GitLab server API using the specified logger.void
enableRequestResponseLogging(Logger logger, Level level, int maxEntitySize)
Enable the logging of the requests to and the responses from the GitLab server API using the specified logger.void
enableRequestResponseLogging(Logger logger, Level level, int maxEntitySize, List<String> maskedHeaderNames)
Enable the logging of the requests to and the responses from the GitLab server API using the specified logger.void
enableRequestResponseLogging(Logger logger, Level level, List<String> maskedHeaderNames)
Enable the logging of the requests to and the responses from the GitLab server API using the specified logger.GitLabApi.ApiVersion
getApiVersion()
Return the GitLab API version that this instance is using.ApplicationsApi
getApplicationsApi()
Gets the ApplicationsApi instance owned by this GitLabApi instance.ApplicationSettingsApi
getApplicationSettingsApi()
Gets the ApplicationSettingsApi instance owned by this GitLabApi instance.String
getAuthToken()
Get the auth token being used by this client.AwardEmojiApi
getAwardEmojiApi()
Gets the AwardEmojiApi instance owned by this GitLabApi instance.BoardsApi
getBoardsApi()
Gets the BoardsApi instance owned by this GitLabApi instance.CommitsApi
getCommitsApi()
Gets the CommitsApi instance owned by this GitLabApi instance.ContainerRegistryApi
getContainerRegistryApi()
Gets the ContainerRegistryApi instance owned by this GitLabApi instance.int
getDefaultPerPage()
Get the default number per page for calls that return multiple items.DeployKeysApi
getDeployKeysApi()
Gets the DeployKeysApi instance owned by this GitLabApi instance.DiscussionsApi
getDiscussionsApi()
Gets the DiscussionsApi instance owned by this GitLabApi instance.EpicsApi
getEpicsApi()
Gets the EpicsApi instance owned by this GitLabApi instance.EventsApi
getEventsApi()
Gets the EventsApi instance owned by this GitLabApi instance.String
getGitLabServerUrl()
Get the URL to the GitLab server.GroupApi
getGroupApi()
Gets the GroupApi instance owned by this GitLabApi instance.HealthCheckApi
getHealthCheckApi()
Gets the HealthCheckApi instance owned by this GitLabApi instance.boolean
getIgnoreCertificateErrors()
Returns true if the API is setup to ignore SSL certificate errors, otherwise returns false.ImportExportApi
getImportExportApi()
Gets the ImportExportApi instance owned by this GitLabApi instance.IssuesApi
getIssuesApi()
Gets the IssuesApi instance owned by this GitLabApi instance.JobApi
getJobApi()
Gets the JobApi instance owned by this GitLabApi instance.LabelsApi
getLabelsApi()
LicensesApi
getLicensesApi()
Gets the LicensesApi instance owned by this GitLabApi instance.static Logger
getLogger()
Get the GitLab4J shared Logger instance.MarkdownApi
getMarkdownApi()
Gets the MarkdownApi instance owned by this GitLabApi instance.MergeRequestApi
getMergeRequestApi()
Gets the MergeRequestApi instance owned by this GitLabApi instance.MilestonesApi
getMilestonesApi()
Gets the MilsestonesApi instance owned by this GitLabApi instance.NamespaceApi
getNamespaceApi()
Gets the NamespaceApi instance owned by this GitLabApi instance.NotesApi
getNotesApi()
Gets the NotesApi instance owned by this GitLabApi instance.NotificationSettingsApi
getNotificationSettingsApi()
Gets the NotesApi instance owned by this GitLabApi instance.static GitLabApiException
getOptionalException(Optional<?> optional)
Get the exception associated with the provided Optional instance, or null if no exception is associated with the Optional instance.PackagesApi
getPackagesApi()
Gets the PackagesApi instance owned by this GitLabApi instance.PipelineApi
getPipelineApi()
Gets the PipelineApi instance owned by this GitLabApi instance.ProjectApi
getProjectApi()
Gets the ProjectApi instance owned by this GitLabApi instance.ProtectedBranchesApi
getProtectedBranchesApi()
Gets the ProtectedBranchesApi instance owned by this GitLabApi instance.RepositoryApi
getRepositoryApi()
Gets the RepositoryApi instance owned by this GitLabApi instance.RepositoryFileApi
getRepositoryFileApi()
Gets the RepositoryFileApi instance owned by this GitLabApi instance.RunnersApi
getRunnersApi()
Gets the RunnersApi instance owned by this GitLabApi instance.String
getSecretToken()
Get the secret token.ServicesApi
getServicesApi()
Gets the ServicesApi instance owned by this GitLabApi instance.Session
getSession()
Deprecated.This method will be removed in Release 4.9.0SessionApi
getSessionApi()
Gets the SessionApi instance owned by this GitLabApi instance.SnippetsApi
getSnippetApi()
Gets the SnippetsApi instance owned by this GitLabApi instance.Integer
getSudoAsId()
Get the current sudo as ID, will return null if not in sudo mode.SystemHooksApi
getSystemHooksApi()
Gets the SystemHooksApi instance owned by this GitLabApi instance.TagsApi
getTagsApi()
Gets the TagsApi instance owned by this GitLabApi instance.Constants.TokenType
getTokenType()
Get the TokenType this client is using.UserApi
getUserApi()
Gets the UserApi instance owned by this GitLabApi instance.Version
getVersion()
Get the version info for the GitLab server using the GitLab Version API.WikisApi
getWikisApi()
Gets the WikisApi instance owned by this GitLabApi instance.static GitLabApi
login(String url, String username, String password)
Deprecated.As of release 4.8.7, will be removed in 4.9.0static GitLabApi
login(String url, String username, String password, boolean ignoreCertificateErrors)
Deprecated.As of release 4.8.7, will be removed in 4.9.0static GitLabApi
login(GitLabApi.ApiVersion apiVersion, String url, String username, String password)
Deprecated.As of release 4.8.7, will be removed in 4.9.0static GitLabApi
login(GitLabApi.ApiVersion apiVersion, String url, String username, String password, boolean ignoreCertificateErrors)
Deprecated.As of release 4.8.7, will be removed in 4.9.0static GitLabApi
oauth2Login(String url, String username, char[] password)
Logs into GitLab using OAuth2 with the providedusername
andpassword
, and creates a newGitLabApi
instance using returned access token.static GitLabApi
oauth2Login(String url, String username, char[] password, boolean ignoreCertificateErrors)
Logs into GitLab using OAuth2 with the providedusername
andpassword
, and creates a newGitLabApi
instance using returned access token.static GitLabApi
oauth2Login(String url, String username, char[] password, String secretToken, Map<String,Object> clientConfigProperties, boolean ignoreCertificateErrors)
Logs into GitLab using OAuth2 with the providedusername
andpassword
, and creates a newGitLabApi
instance using returned access token.static GitLabApi
oauth2Login(String url, String username, CharSequence password)
Logs into GitLab using OAuth2 with the providedusername
andpassword
, and creates a newGitLabApi
instance using returned access token.static GitLabApi
oauth2Login(String url, String username, CharSequence password, boolean ignoreCertificateErrors)
Logs into GitLab using OAuth2 with the providedusername
andpassword
, and creates a newGitLabApi
instance using returned access token.static GitLabApi
oauth2Login(String url, String username, CharSequence password, String secretToken, Map<String,Object> clientConfigProperties, boolean ignoreCertificateErrors)
Logs into GitLab using OAuth2 with the providedusername
andpassword
, and creates a newGitLabApi
instance using returned access token.static GitLabApi
oauth2Login(GitLabApi.ApiVersion apiVersion, String url, String username, char[] password, String secretToken, Map<String,Object> clientConfigProperties, boolean ignoreCertificateErrors)
Logs into GitLab using OAuth2 with the providedusername
andpassword
, and creates a newGitLabApi
instance using returned access token.static GitLabApi
oauth2Login(GitLabApi.ApiVersion apiVersion, String url, String username, CharSequence password, String secretToken, Map<String,Object> clientConfigProperties, boolean ignoreCertificateErrors)
Logs into GitLab using OAuth2 with the providedusername
andpassword
, and creates a newGitLabApi
instance using returned access token.static <T> T
orElseThrow(Optional<T> optional)
Return the Optional instances contained value, if present, otherwise throw the exception that is associated with the Optional instance.void
setDefaultPerPage(int defaultPerPage)
Set the default number per page for calls that return multiple items.void
setIgnoreCertificateErrors(boolean ignoreCertificateErrors)
Sets up the Jersey system ignore SSL certificate errors or not.void
setSudoAsId(Integer sudoAsId)
Sets up all future calls to the GitLab API to be done as another user specified by provided user ID.void
sudo(String sudoAsUsername)
Sets up all future calls to the GitLab API to be done as another user specified by sudoAsUsername.void
unsudo()
Turns off the currently configured sudo as ID.GitLabApi
withRequestResponseLogging()
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance and Level.FINE as the level.GitLabApi
withRequestResponseLogging(Level level)
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance.GitLabApi
withRequestResponseLogging(Logger logger, Level level)
Enable the logging of the requests to and the responses from the GitLab server API.
-
-
-
Field Detail
-
DEFAULT_PER_PAGE
public static final int DEFAULT_PER_PAGE
GitLab4J default per page. GitLab will ignore anything over 100.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GitLabApi
public GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, Constants.TokenType tokenType, String authToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.- Parameters:
apiVersion
- the ApiVersion specifying which version of the API to usehostUrl
- the URL of the GitLab servertokenType
- the type of auth the token is for, PRIVATE or ACCESSauthToken
- the token to use for access to the API
-
GitLabApi
public GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, String privateToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.- Parameters:
apiVersion
- the ApiVersion specifying which version of the API to usehostUrl
- the URL of the GitLab serverprivateToken
- to private token to use for access to the API
-
GitLabApi
public GitLabApi(String hostUrl, Constants.TokenType tokenType, String authToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.- Parameters:
hostUrl
- the URL of the GitLab servertokenType
- the type of auth the token is for, PRIVATE or ACCESSauthToken
- the token to use for access to the API
-
GitLabApi
public GitLabApi(String hostUrl, String privateToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.- Parameters:
hostUrl
- the URL of the GitLab serverprivateToken
- to private token to use for access to the API
-
GitLabApi
public GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, Session session)
Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.- Parameters:
apiVersion
- the ApiVersion specifying which version of the API to usehostUrl
- the URL of the GitLab serversession
- the Session instance obtained by logining into the GitLab server
-
GitLabApi
public GitLabApi(String hostUrl, Session session)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.- Parameters:
hostUrl
- the URL of the GitLab serversession
- the Session instance obtained by logining into the GitLab server
-
GitLabApi
public GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, Constants.TokenType tokenType, String authToken, String secretToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.- Parameters:
apiVersion
- the ApiVersion specifying which version of the API to usehostUrl
- the URL of the GitLab servertokenType
- the type of auth the token is for, PRIVATE or ACCESSauthToken
- the token to use for access to the APIsecretToken
- use this token to validate received payloads
-
GitLabApi
public GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, String privateToken, String secretToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using the specified GitLab API version.- Parameters:
apiVersion
- the ApiVersion specifying which version of the API to usehostUrl
- the URL of the GitLab serverprivateToken
- to private token to use for access to the APIsecretToken
- use this token to validate received payloads
-
GitLabApi
public GitLabApi(String hostUrl, Constants.TokenType tokenType, String authToken, String secretToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.- Parameters:
hostUrl
- the URL of the GitLab servertokenType
- the type of auth the token is for, PRIVATE or ACCESSauthToken
- the token to use for access to the APIsecretToken
- use this token to validate received payloads
-
GitLabApi
public GitLabApi(String hostUrl, String privateToken, String secretToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.- Parameters:
hostUrl
- the URL of the GitLab serverprivateToken
- to private token to use for access to the APIsecretToken
- use this token to validate received payloads
-
GitLabApi
public GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, String privateToken, String secretToken, Map<String,Object> clientConfigProperties)
Constructs a GitLabApi instance set up to interact with the GitLab server specified by GitLab API version.- Parameters:
apiVersion
- the ApiVersion specifying which version of the API to usehostUrl
- the URL of the GitLab serverprivateToken
- to private token to use for access to the APIsecretToken
- use this token to validate received payloadsclientConfigProperties
- Map instance with additional properties for the Jersey client connection
-
GitLabApi
public GitLabApi(String hostUrl, Constants.TokenType tokenType, String authToken, String secretToken, Map<String,Object> clientConfigProperties)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.- Parameters:
hostUrl
- the URL of the GitLab servertokenType
- the type of auth the token is for, PRIVATE or ACCESSauthToken
- the token to use for access to the APIsecretToken
- use this token to validate received payloadsclientConfigProperties
- Map instance with additional properties for the Jersey client connection
-
GitLabApi
public GitLabApi(String hostUrl, String privateToken, String secretToken, Map<String,Object> clientConfigProperties)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.- Parameters:
hostUrl
- the URL of the GitLab serverprivateToken
- to private token to use for access to the APIsecretToken
- use this token to validate received payloadsclientConfigProperties
- Map instance with additional properties for the Jersey client connection
-
GitLabApi
public GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, Constants.TokenType tokenType, String authToken, String secretToken, Map<String,Object> clientConfigProperties)
Constructs a GitLabApi instance set up to interact with the GitLab server specified by GitLab API version.- Parameters:
apiVersion
- the ApiVersion specifying which version of the API to usehostUrl
- the URL of the GitLab servertokenType
- the type of auth the token is for, PRIVATE or ACCESSauthToken
- to token to use for access to the APIsecretToken
- use this token to validate received payloadsclientConfigProperties
- Map instance with additional properties for the Jersey client connection
-
-
Method Detail
-
getLogger
public static final Logger getLogger()
Get the GitLab4J shared Logger instance.- Returns:
- the GitLab4J shared Logger instance
-
duplicate
public final GitLabApi duplicate()
Create a new GitLabApi instance that is logically a duplicate of this instance, with the exception off sudo state.- Returns:
- a new GitLabApi instance that is logically a duplicate of this instance, with the exception off sudo state.
-
oauth2Login
public static GitLabApi oauth2Login(String url, String username, CharSequence password) throws GitLabApiException
Logs into GitLab using OAuth2 with the provided
username
andpassword
, and creates a newGitLabApi
instance using returned access token.- Parameters:
url
- GitLab URLusername
- user name for which private token should be obtainedpassword
- a CharSequence containing the password for a givenusername
- Returns:
- new
GitLabApi
instance configured for a user-specific token - Throws:
GitLabApiException
- GitLabApiException if any exception occurs during execution
-
oauth2Login
public static GitLabApi oauth2Login(String url, String username, char[] password) throws GitLabApiException
Logs into GitLab using OAuth2 with the provided
username
andpassword
, and creates a newGitLabApi
instance using returned access token.- Parameters:
url
- GitLab URLusername
- user name for which private token should be obtainedpassword
- a char array holding the password for a givenusername
- Returns:
- new
GitLabApi
instance configured for a user-specific token - Throws:
GitLabApiException
- GitLabApiException if any exception occurs during execution
-
oauth2Login
public static GitLabApi oauth2Login(String url, String username, CharSequence password, boolean ignoreCertificateErrors) throws GitLabApiException
Logs into GitLab using OAuth2 with the provided
username
andpassword
, and creates a newGitLabApi
instance using returned access token.- Parameters:
url
- GitLab URLusername
- user name for which private token should be obtainedpassword
- a CharSequence containing the password for a givenusername
ignoreCertificateErrors
- if true will set up the Jersey system ignore SSL certificate errors- Returns:
- new
GitLabApi
instance configured for a user-specific token - Throws:
GitLabApiException
- GitLabApiException if any exception occurs during execution
-
oauth2Login
public static GitLabApi oauth2Login(String url, String username, char[] password, boolean ignoreCertificateErrors) throws GitLabApiException
Logs into GitLab using OAuth2 with the provided
username
andpassword
, and creates a newGitLabApi
instance using returned access token.- Parameters:
url
- GitLab URLusername
- user name for which private token should be obtainedpassword
- a char array holding the password for a givenusername
ignoreCertificateErrors
- if true will set up the Jersey system ignore SSL certificate errors- Returns:
- new
GitLabApi
instance configured for a user-specific token - Throws:
GitLabApiException
- GitLabApiException if any exception occurs during execution
-
oauth2Login
public static GitLabApi oauth2Login(String url, String username, CharSequence password, String secretToken, Map<String,Object> clientConfigProperties, boolean ignoreCertificateErrors) throws GitLabApiException
Logs into GitLab using OAuth2 with the provided
username
andpassword
, and creates a newGitLabApi
instance using returned access token.- Parameters:
url
- GitLab URLusername
- user name for which private token should be obtainedpassword
- a CharSequence containing the password for a givenusername
secretToken
- use this token to validate received payloadsclientConfigProperties
- Map instance with additional properties for the Jersey client connectionignoreCertificateErrors
- if true will set up the Jersey system ignore SSL certificate errors- Returns:
- new
GitLabApi
instance configured for a user-specific token - Throws:
GitLabApiException
- GitLabApiException if any exception occurs during execution
-
oauth2Login
public static GitLabApi oauth2Login(String url, String username, char[] password, String secretToken, Map<String,Object> clientConfigProperties, boolean ignoreCertificateErrors) throws GitLabApiException
Logs into GitLab using OAuth2 with the provided
username
andpassword
, and creates a newGitLabApi
instance using returned access token.- Parameters:
url
- GitLab URLusername
- user name for which private token should be obtainedpassword
- a char array holding the password for a givenusername
secretToken
- use this token to validate received payloadsclientConfigProperties
- Map instance with additional properties for the Jersey client connectionignoreCertificateErrors
- if true will set up the Jersey system ignore SSL certificate errors- Returns:
- new
GitLabApi
instance configured for a user-specific token - Throws:
GitLabApiException
- GitLabApiException if any exception occurs during execution
-
oauth2Login
public static GitLabApi oauth2Login(GitLabApi.ApiVersion apiVersion, String url, String username, char[] password, String secretToken, Map<String,Object> clientConfigProperties, boolean ignoreCertificateErrors) throws GitLabApiException
Logs into GitLab using OAuth2 with the provided
username
andpassword
, and creates a newGitLabApi
instance using returned access token.- Parameters:
url
- GitLab URLapiVersion
- the ApiVersion specifying which version of the API to useusername
- user name for which private token should be obtainedpassword
- a char array holding the password for a givenusername
secretToken
- use this token to validate received payloadsclientConfigProperties
- Map instance with additional properties for the Jersey client connectionignoreCertificateErrors
- if true will set up the Jersey system ignore SSL certificate errors- Returns:
- new
GitLabApi
instance configured for a user-specific token - Throws:
GitLabApiException
- GitLabApiException if any exception occurs during execution
-
oauth2Login
public static GitLabApi oauth2Login(GitLabApi.ApiVersion apiVersion, String url, String username, CharSequence password, String secretToken, Map<String,Object> clientConfigProperties, boolean ignoreCertificateErrors) throws GitLabApiException
Logs into GitLab using OAuth2 with the provided
username
andpassword
, and creates a newGitLabApi
instance using returned access token.- Parameters:
url
- GitLab URLapiVersion
- the ApiVersion specifying which version of the API to useusername
- user name for which private token should be obtainedpassword
- password for a givenusername
secretToken
- use this token to validate received payloadsclientConfigProperties
- Map instance with additional properties for the Jersey client connectionignoreCertificateErrors
- if true will set up the Jersey system ignore SSL certificate errors- Returns:
- new
GitLabApi
instance configured for a user-specific token - Throws:
GitLabApiException
- GitLabApiException if any exception occurs during execution
-
login
@Deprecated public static GitLabApi login(GitLabApi.ApiVersion apiVersion, String url, String username, String password) throws GitLabApiException
Deprecated.As of release 4.8.7, will be removed in 4.9.0Logs into GitLab using provided
NOTE: For GitLab servers 10.2 and above this will utilize OAUTH2 for login. For GitLab servers prior to 10.2, the Session API login is utilized.username
andpassword
, and creates a newGitLabApi
instance using returned private token and the specified GitLab API version.- Parameters:
apiVersion
- the ApiVersion specifying which version of the API to useurl
- GitLab URLusername
- user name for which private token should be obtainedpassword
- password for a givenusername
- Returns:
- new
GitLabApi
instance configured for a user-specific token - Throws:
GitLabApiException
- GitLabApiException if any exception occurs during execution
-
login
@Deprecated public static GitLabApi login(String url, String username, String password) throws GitLabApiException
Deprecated.As of release 4.8.7, will be removed in 4.9.0Logs into GitLab using provided
NOTE: For GitLab servers 10.2 and above this will utilize OAUTH2 for login. For GitLab servers prior to 10.2, the Session API login is utilized.username
andpassword
, and creates a newGitLabApi
instance using returned private token using GitLab API version 4.- Parameters:
url
- GitLab URLusername
- user name for which private token should be obtainedpassword
- password for a givenusername
- Returns:
- new
GitLabApi
instance configured for a user-specific token - Throws:
GitLabApiException
- GitLabApiException if any exception occurs during execution
-
login
@Deprecated public static GitLabApi login(GitLabApi.ApiVersion apiVersion, String url, String username, String password, boolean ignoreCertificateErrors) throws GitLabApiException
Deprecated.As of release 4.8.7, will be removed in 4.9.0Logs into GitLab using provided
NOTE: For GitLab servers 10.2 and above this will utilize OAUTH2 for login. For GitLab servers prior to 10.2, the Session API login is utilized.username
andpassword
, and creates a newGitLabApi
instance using returned private token and the specified GitLab API version.- Parameters:
apiVersion
- the ApiVersion specifying which version of the API to useurl
- GitLab URLusername
- user name for which private token should be obtainedpassword
- password for a givenusername
ignoreCertificateErrors
- if true will set up the Jersey system ignore SSL certificate errors- Returns:
- new
GitLabApi
instance configured for a user-specific token - Throws:
GitLabApiException
- GitLabApiException if any exception occurs during execution
-
login
@Deprecated public static GitLabApi login(String url, String username, String password, boolean ignoreCertificateErrors) throws GitLabApiException
Deprecated.As of release 4.8.7, will be removed in 4.9.0Logs into GitLab using provided
NOTE: For GitLab servers 10.2 and above this will utilize OAUTH2 for login. For GitLab servers prior to 10.2, the Session API login is utilized.username
andpassword
, and creates a newGitLabApi
instance using returned private token using GitLab API version 4.- Parameters:
url
- GitLab URLusername
- user name for which private token should be obtainedpassword
- password for a givenusername
ignoreCertificateErrors
- if true will set up the Jersey system ignore SSL certificate errors- Returns:
- new
GitLabApi
instance configured for a user-specific token - Throws:
GitLabApiException
- GitLabApiException if any exception occurs during execution
-
getSession
@Deprecated public Session getSession()
Deprecated.This method will be removed in Release 4.9.0If this instance was created with
NOTE: For GitLab servers 10.2 and above this method will always return null.login(String, String, String)
this method will return the Session instance returned by the GitLab API on login, otherwise returns null.- Returns:
- the Session instance
-
withRequestResponseLogging
public GitLabApi withRequestResponseLogging()
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance and Level.FINE as the level.- Returns:
- this GitLabApi instance
-
withRequestResponseLogging
public GitLabApi withRequestResponseLogging(Level level)
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance.- Parameters:
level
- the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)- Returns:
- this GitLabApi instance
-
withRequestResponseLogging
public GitLabApi withRequestResponseLogging(Logger logger, Level level)
Enable the logging of the requests to and the responses from the GitLab server API.- Parameters:
logger
- the Logger instance to log tolevel
- the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)- Returns:
- this GitLabApi instance
-
enableRequestResponseLogging
public void enableRequestResponseLogging()
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance and Level.FINE as the level.
-
enableRequestResponseLogging
public void enableRequestResponseLogging(Level level)
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance. Logging will NOT include entity logging and will mask PRIVATE-TOKEN and Authorization headers.- Parameters:
level
- the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)
-
enableRequestResponseLogging
public void enableRequestResponseLogging(Logger logger, Level level)
Enable the logging of the requests to and the responses from the GitLab server API using the specified logger. Logging will NOT include entity logging and will mask PRIVATE-TOKEN and Authorization headers..- Parameters:
logger
- the Logger instance to log tolevel
- the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)
-
enableRequestResponseLogging
public void enableRequestResponseLogging(Level level, int maxEntitySize)
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance. Logging will mask PRIVATE-TOKEN and Authorization headers.- Parameters:
level
- the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)maxEntitySize
- maximum number of entity bytes to be logged. When logging if the maxEntitySize is reached, the entity logging will be truncated at maxEntitySize and "...more..." will be added at the end of the log entry. If maxEntitySize is <= 0, entity logging will be disabled
-
enableRequestResponseLogging
public void enableRequestResponseLogging(Logger logger, Level level, int maxEntitySize)
Enable the logging of the requests to and the responses from the GitLab server API using the specified logger. Logging will mask PRIVATE-TOKEN and Authorization headers.- Parameters:
logger
- the Logger instance to log tolevel
- the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)maxEntitySize
- maximum number of entity bytes to be logged. When logging if the maxEntitySize is reached, the entity logging will be truncated at maxEntitySize and "...more..." will be added at the end of the log entry. If maxEntitySize is <= 0, entity logging will be disabled
-
enableRequestResponseLogging
public void enableRequestResponseLogging(Level level, List<String> maskedHeaderNames)
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance.- Parameters:
level
- the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)maskedHeaderNames
- a list of header names that should have the values masked
-
enableRequestResponseLogging
public void enableRequestResponseLogging(Logger logger, Level level, List<String> maskedHeaderNames)
Enable the logging of the requests to and the responses from the GitLab server API using the specified logger.- Parameters:
logger
- the Logger instance to log tolevel
- the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)maskedHeaderNames
- a list of header names that should have the values masked
-
enableRequestResponseLogging
public void enableRequestResponseLogging(Level level, int maxEntitySize, List<String> maskedHeaderNames)
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance.- Parameters:
level
- the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)maxEntitySize
- maximum number of entity bytes to be logged. When logging if the maxEntitySize is reached, the entity logging will be truncated at maxEntitySize and "...more..." will be added at the end of the log entry. If maxEntitySize is <= 0, entity logging will be disabledmaskedHeaderNames
- a list of header names that should have the values masked
-
enableRequestResponseLogging
public void enableRequestResponseLogging(Logger logger, Level level, int maxEntitySize, List<String> maskedHeaderNames)
Enable the logging of the requests to and the responses from the GitLab server API using the specified logger.- Parameters:
logger
- the Logger instance to log tolevel
- the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)maxEntitySize
- maximum number of entity bytes to be logged. When logging if the maxEntitySize is reached, the entity logging will be truncated at maxEntitySize and "...more..." will be added at the end of the log entry. If maxEntitySize is <= 0, entity logging will be disabledmaskedHeaderNames
- a list of header names that should have the values masked
-
sudo
public void sudo(String sudoAsUsername) throws GitLabApiException
Sets up all future calls to the GitLab API to be done as another user specified by sudoAsUsername. To revert back to normal non-sudo operation you must call unsudo(), or pass null as the username.- Parameters:
sudoAsUsername
- the username to sudo as, null will turn off sudo- Throws:
GitLabApiException
- if any exception occurs
-
unsudo
public void unsudo()
Turns off the currently configured sudo as ID.
-
setSudoAsId
public void setSudoAsId(Integer sudoAsId) throws GitLabApiException
Sets up all future calls to the GitLab API to be done as another user specified by provided user ID. To revert back to normal non-sudo operation you must call unsudo(), or pass null as the sudoAsId.- Parameters:
sudoAsId
- the ID of the user to sudo as, null will turn off sudo- Throws:
GitLabApiException
- if any exception occurs
-
getSudoAsId
public Integer getSudoAsId()
Get the current sudo as ID, will return null if not in sudo mode.- Returns:
- the current sudo as ID, will return null if not in sudo mode
-
getAuthToken
public String getAuthToken()
Get the auth token being used by this client.- Returns:
- the auth token being used by this client
-
getSecretToken
public String getSecretToken()
Get the secret token.- Returns:
- the secret token
-
getTokenType
public Constants.TokenType getTokenType()
Get the TokenType this client is using.- Returns:
- the TokenType this client is using
-
getApiVersion
public GitLabApi.ApiVersion getApiVersion()
Return the GitLab API version that this instance is using.- Returns:
- the GitLab API version that this instance is using
-
getGitLabServerUrl
public String getGitLabServerUrl()
Get the URL to the GitLab server.- Returns:
- the URL to the GitLab server
-
getDefaultPerPage
public int getDefaultPerPage()
Get the default number per page for calls that return multiple items.- Returns:
- the default number per page for calls that return multiple item
-
setDefaultPerPage
public void setDefaultPerPage(int defaultPerPage)
Set the default number per page for calls that return multiple items.- Parameters:
defaultPerPage
- the new default number per page for calls that return multiple item
-
getIgnoreCertificateErrors
public boolean getIgnoreCertificateErrors()
Returns true if the API is setup to ignore SSL certificate errors, otherwise returns false.- Returns:
- true if the API is setup to ignore SSL certificate errors, otherwise returns false
-
setIgnoreCertificateErrors
public void setIgnoreCertificateErrors(boolean ignoreCertificateErrors)
Sets up the Jersey system ignore SSL certificate errors or not.- Parameters:
ignoreCertificateErrors
- if true will set up the Jersey system ignore SSL certificate errors
-
getVersion
public Version getVersion() throws GitLabApiException
Get the version info for the GitLab server using the GitLab Version API.- Returns:
- the version info for the GitLab server
- Throws:
GitLabApiException
- if any exception occurs
-
getApplicationsApi
public ApplicationsApi getApplicationsApi()
Gets the ApplicationsApi instance owned by this GitLabApi instance. The ApplicationsApi is used to perform all OAUTH application related API calls.- Returns:
- the ApplicationsApi instance owned by this GitLabApi instance
-
getApplicationSettingsApi
public ApplicationSettingsApi getApplicationSettingsApi()
Gets the ApplicationSettingsApi instance owned by this GitLabApi instance. The ApplicationSettingsApi is used to perform all application settingsrelated API calls.- Returns:
- the ApplicationsApi instance owned by this GitLabApi instance
-
getAwardEmojiApi
public AwardEmojiApi getAwardEmojiApi()
Gets the AwardEmojiApi instance owned by this GitLabApi instance. The AwardEmojiApi is used to perform all award emoji related API calls.- Returns:
- the AwardEmojiApi instance owned by this GitLabApi instance
-
getBoardsApi
public BoardsApi getBoardsApi()
Gets the BoardsApi instance owned by this GitLabApi instance. The BoardsApi is used to perform all Issue Boards related API calls.- Returns:
- the BoardsApi instance owned by this GitLabApi instance
-
getCommitsApi
public CommitsApi getCommitsApi()
Gets the CommitsApi instance owned by this GitLabApi instance. The CommitsApi is used to perform all commit related API calls.- Returns:
- the CommitsApi instance owned by this GitLabApi instance
-
getContainerRegistryApi
public ContainerRegistryApi getContainerRegistryApi()
Gets the ContainerRegistryApi instance owned by this GitLabApi instance. The ContainerRegistryApi is used to perform all Docker Registry related API calls.- Returns:
- the ContainerRegistryApi instance owned by this GitLabApi instance
-
getDeployKeysApi
public DeployKeysApi getDeployKeysApi()
Gets the DeployKeysApi instance owned by this GitLabApi instance. The DeployKeysApi is used to perform all deploy key related API calls.- Returns:
- the DeployKeysApi instance owned by this GitLabApi instance
-
getDiscussionsApi
public DiscussionsApi getDiscussionsApi()
Gets the DiscussionsApi instance owned by this GitLabApi instance. The DiscussionsApi is used to perform all discussion related API calls.- Returns:
- the DiscussionsApi instance owned by this GitLabApi instance
-
getEpicsApi
public EpicsApi getEpicsApi()
Gets the EpicsApi instance owned by this GitLabApi instance. The EpicsApi is used to perform all Epics and Epic Issues related API calls.- Returns:
- the EpicsApi instance owned by this GitLabApi instance
-
getEventsApi
public EventsApi getEventsApi()
Gets the EventsApi instance owned by this GitLabApi instance. The EventsApi is used to perform all events related API calls.- Returns:
- the EventsApi instance owned by this GitLabApi instance
-
getGroupApi
public GroupApi getGroupApi()
Gets the GroupApi instance owned by this GitLabApi instance. The GroupApi is used to perform all group related API calls.- Returns:
- the GroupApi instance owned by this GitLabApi instance
-
getHealthCheckApi
public HealthCheckApi getHealthCheckApi()
Gets the HealthCheckApi instance owned by this GitLabApi instance. The HealthCheckApi is used to perform all admin level gitlab health monitoring.- Returns:
- the HealthCheckApi instance owned by this GitLabApi instance
-
getImportExportApi
public ImportExportApi getImportExportApi()
Gets the ImportExportApi instance owned by this GitLabApi instance. The ImportExportApi is used to perform all project import/export related API calls.- Returns:
- the ImportExportApi instance owned by this GitLabApi instance
-
getIssuesApi
public IssuesApi getIssuesApi()
Gets the IssuesApi instance owned by this GitLabApi instance. The IssuesApi is used to perform all issue related API calls.- Returns:
- the IssuesApi instance owned by this GitLabApi instance
-
getJobApi
public JobApi getJobApi()
Gets the JobApi instance owned by this GitLabApi instance. The JobApi is used to perform all jobs related API calls.- Returns:
- the JobsApi instance owned by this GitLabApi instance
-
getLabelsApi
public LabelsApi getLabelsApi()
-
getLicensesApi
public LicensesApi getLicensesApi()
Gets the LicensesApi instance owned by this GitLabApi instance. The LicensesApi is used to perform all license related API calls.- Returns:
- the LicensesApi instance owned by this GitLabApi instance
-
getMarkdownApi
public MarkdownApi getMarkdownApi()
Gets the MarkdownApi instance owned by this GitLabApi instance. The MarkdownApi is used to perform all markdown related API calls.- Returns:
- the MarkdownApi instance owned by this GitLabApi instance
-
getMergeRequestApi
public MergeRequestApi getMergeRequestApi()
Gets the MergeRequestApi instance owned by this GitLabApi instance. The MergeRequestApi is used to perform all merge request related API calls.- Returns:
- the MergeRequestApi instance owned by this GitLabApi instance
-
getMilestonesApi
public MilestonesApi getMilestonesApi()
Gets the MilsestonesApi instance owned by this GitLabApi instance.- Returns:
- the MilsestonesApi instance owned by this GitLabApi instance
-
getNamespaceApi
public NamespaceApi getNamespaceApi()
Gets the NamespaceApi instance owned by this GitLabApi instance. The NamespaceApi is used to perform all namespace related API calls.- Returns:
- the NamespaceApi instance owned by this GitLabApi instance
-
getNotesApi
public NotesApi getNotesApi()
Gets the NotesApi instance owned by this GitLabApi instance. The NotesApi is used to perform all notes related API calls.- Returns:
- the NotesApi instance owned by this GitLabApi instance
-
getNotificationSettingsApi
public NotificationSettingsApi getNotificationSettingsApi()
Gets the NotesApi instance owned by this GitLabApi instance. The NotesApi is used to perform all notes related API calls.- Returns:
- the NotesApi instance owned by this GitLabApi instance
-
getPackagesApi
public PackagesApi getPackagesApi()
Gets the PackagesApi instance owned by this GitLabApi instance. The PackagesApi is used to perform all Package related API calls.- Returns:
- the PackagesApi instance owned by this GitLabApi instance
-
getPipelineApi
public PipelineApi getPipelineApi()
Gets the PipelineApi instance owned by this GitLabApi instance. The PipelineApi is used to perform all pipeline related API calls.- Returns:
- the PipelineApi instance owned by this GitLabApi instance
-
getProjectApi
public ProjectApi getProjectApi()
Gets the ProjectApi instance owned by this GitLabApi instance. The ProjectApi is used to perform all project related API calls.- Returns:
- the ProjectApi instance owned by this GitLabApi instance
-
getProtectedBranchesApi
public ProtectedBranchesApi getProtectedBranchesApi()
Gets the ProtectedBranchesApi instance owned by this GitLabApi instance. The ProtectedBranchesApi is used to perform all protection related actions on a branch of a project.- Returns:
- the ProtectedBranchesApi instance owned by this GitLabApi instance
-
getRepositoryApi
public RepositoryApi getRepositoryApi()
Gets the RepositoryApi instance owned by this GitLabApi instance. The RepositoryApi is used to perform all repository related API calls.- Returns:
- the RepositoryApi instance owned by this GitLabApi instance
-
getRepositoryFileApi
public RepositoryFileApi getRepositoryFileApi()
Gets the RepositoryFileApi instance owned by this GitLabApi instance. The RepositoryFileApi is used to perform all repository files related API calls.- Returns:
- the RepositoryFileApi instance owned by this GitLabApi instance
-
getRunnersApi
public RunnersApi getRunnersApi()
Gets the RunnersApi instance owned by this GitLabApi instance. The RunnersApi is used to perform all Runner related API calls.- Returns:
- the RunnerApi instance owned by this GitLabApi instance
-
getServicesApi
public ServicesApi getServicesApi()
Gets the ServicesApi instance owned by this GitLabApi instance. The ServicesApi is used to perform all services related API calls.- Returns:
- the ServicesApi instance owned by this GitLabApi instance
-
getSessionApi
public SessionApi getSessionApi()
Gets the SessionApi instance owned by this GitLabApi instance. The SessionApi is used to perform a login to the GitLab API.- Returns:
- the SessionApi instance owned by this GitLabApi instance
-
getSystemHooksApi
public SystemHooksApi getSystemHooksApi()
Gets the SystemHooksApi instance owned by this GitLabApi instance. All methods require administrator authorization.- Returns:
- the SystemHooksApi instance owned by this GitLabApi instance
-
getTagsApi
public TagsApi getTagsApi()
Gets the TagsApi instance owned by this GitLabApi instance. The TagsApi is used to perform all tag and release related API calls.- Returns:
- the TagsApi instance owned by this GitLabApi instance
-
getUserApi
public UserApi getUserApi()
Gets the UserApi instance owned by this GitLabApi instance. The UserApi is used to perform all user related API calls.- Returns:
- the UserApi instance owned by this GitLabApi instance
-
createOptionalFromException
protected static final <T> Optional<T> createOptionalFromException(GitLabApiException glae)
Create and return an Optional instance associated with a GitLabApiException.- Type Parameters:
T
- the type of the Optional instance- Parameters:
glae
- the GitLabApiException that was the result of a call to the GitLab API- Returns:
- the created Optional instance
-
getOptionalException
public static final GitLabApiException getOptionalException(Optional<?> optional)
Get the exception associated with the provided Optional instance, or null if no exception is associated with the Optional instance.- Parameters:
optional
- the Optional instance to get the exception for- Returns:
- the exception associated with the provided Optional instance, or null if no exception is associated with the Optional instance
-
orElseThrow
public static final <T> T orElseThrow(Optional<T> optional) throws GitLabApiException
Return the Optional instances contained value, if present, otherwise throw the exception that is associated with the Optional instance.- Type Parameters:
T
- the type for the Optional parameter- Parameters:
optional
- the Optional instance to get the value for- Returns:
- the value of the Optional instance if no exception is associated with it
- Throws:
GitLabApiException
- if there was an exception associated with the Optional instance
-
getSnippetApi
public SnippetsApi getSnippetApi()
Gets the SnippetsApi instance owned by this GitLabApi instance. The SnippetsApi is used to perform all snippet related API calls.- Returns:
- the SnippetsApi instance owned by this GitLabApi instance
-
getWikisApi
public WikisApi getWikisApi()
Gets the WikisApi instance owned by this GitLabApi instance. The WikisApi is used to perform all wiki related API calls.- Returns:
- the WikisApi instance owned by this GitLabApi instance
-
-