Class GitLabApi
- All Implemented Interfaces:
AutoCloseable
public class GitLabApi extends Object implements AutoCloseable
-
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 personalAccessToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.GitLabApi(String hostUrl, String personalAccessToken, String secretToken)
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.GitLabApi(String hostUrl, String personalAccessToken, 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, String personalAccessToken, 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(GitLabApi.ApiVersion apiVersion, String hostUrl, String personalAccessToken)
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 personalAccessToken, 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 personalAccessToken, 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. -
Method Summary
Modifier and Type Method Description void
close()
Close the underlyingClient
and its associated resources.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 of 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.AuditEventApi
getAuditEventApi()
Gets the AuditEventApi 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.DeploymentsApi
getDeploymentsApi()
Gets the DeployKeysApi instance owned by this GitLabApi instance.DeployTokensApi
getDeployTokensApi()
Gets the DeployTokensApi instance owned by this GitLabApi instance.DiscussionsApi
getDiscussionsApi()
Gets the DiscussionsApi instance owned by this GitLabApi instance.EnvironmentsApi
getEnvironmentsApi()
Gets the EnvironmentsApi 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.KeysApi
getKeysAPI()
Gets the KeysApi instance owned by this GitLabApi instance.LabelsApi
getLabelsApi()
LicenseApi
getLicenseApi()
Gets the LicenseApi instance owned by this GitLabApi instance.LicenseTemplatesApi
getLicenseTemplatesApi()
Gets the LicenseTemplatesApi 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.ReleasesApi
getReleasesApi()
Gets the ReleasesApi 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.ResourceLabelEventsApi
getResourceLabelEventsApi()
Gets the ResourceLabelEventsApi instance owned by this GitLabApi instance.ResourceStateEventsApi
getResourceStateEventsApi()
Gets the ResourceStateEventsApi instance owned by this GitLabApi instance.RunnersApi
getRunnersApi()
Gets the RunnersApi instance owned by this GitLabApi instance.SearchApi
getSearchApi()
Gets the SearchApi instance owned by this GitLabApi instance.String
getSecretToken()
Get the secret token.ServicesApi
getServicesApi()
Gets the ServicesApi instance owned by this GitLabApi instance.SnippetsApi
getSnippetApi()
Gets the SnippetsApi instance owned by this GitLabApi instance.Long
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.TodosApi
getTodosApi()
Gets the TodosApi 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
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
setAuthTokenSupplier(Supplier<String> authTokenSupplier)
Set auth token supplier for gitlab api client.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
setRequestTimeout(Integer connectTimeout, Integer readTimeout)
Sets the per request connect and read timeout.void
setSudoAsId(Long 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.GitLabApi
withRequestTimeout(Integer connectTimeout, Integer readTimeout)
Fluent method that sets the per request connect and read timeout.
-
Field Details
-
DEFAULT_PER_PAGE
public static final int DEFAULT_PER_PAGEGitLab4J default per page. GitLab will ignore anything over 100.- See Also:
- Constant Field Values
-
-
Constructor Details
-
GitLabApi
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4. This is the primary way to authenticate with the GitLab REST API.- Parameters:
hostUrl
- the URL of the GitLab serverpersonalAccessToken
- the private token to use for access to the API
-
GitLabApi
Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4.- Parameters:
hostUrl
- the URL of the GitLab serverpersonalAccessToken
- the private token to use for access to the APIsecretToken
- use this token to validate received payloads
-
GitLabApi
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 serverpersonalAccessToken
- the private token to use for access to the API
-
GitLabApi
public GitLabApi(GitLabApi.ApiVersion apiVersion, String hostUrl, String personalAccessToken, 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 serverpersonalAccessToken
- the private token to use for access to the APIsecretToken
- use this token to validate received payloads
-
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
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(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(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(GitLabApi.ApiVersion apiVersion, String hostUrl, String personalAccessToken, 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 serverpersonalAccessToken
- 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 personalAccessToken, 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 serverpersonalAccessToken
- the 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, String personalAccessToken, 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 serverpersonalAccessToken
- the private token to use for access to the APIclientConfigProperties
- 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 Details
-
getLogger
Get the GitLab4J shared Logger instance.- Returns:
- the GitLab4J shared Logger instance
-
oauth2Login
public static GitLabApi oauth2Login(String url, String username, CharSequence password) throws GitLabApiExceptionLogs 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 GitLabApiExceptionLogs 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 GitLabApiExceptionLogs 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 GitLabApiExceptionLogs 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 GitLabApiExceptionLogs 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 GitLabApiExceptionLogs 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 GitLabApiExceptionLogs 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 GitLabApiExceptionLogs 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
-
duplicate
Create a new GitLabApi instance that is logically a duplicate of this instance, with the exception of sudo state.- Returns:
- a new GitLabApi instance that is logically a duplicate of this instance, with the exception of sudo state.
-
close
public void close()Close the underlyingClient
and its associated resources.- Specified by:
close
in interfaceAutoCloseable
-
setRequestTimeout
Sets the per request connect and read timeout.- Parameters:
connectTimeout
- the per request connect timeout in milliseconds, can be null to use defaultreadTimeout
- the per request read timeout in milliseconds, can be null to use default
-
withRequestTimeout
Fluent method that sets the per request connect and read timeout.- Parameters:
connectTimeout
- the per request connect timeout in milliseconds, can be null to use defaultreadTimeout
- the per request read timeout in milliseconds, can be null to use default- Returns:
- this GitLabApi instance
-
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
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
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
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
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
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
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
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
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
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
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
Get the auth token being used by this client.- Returns:
- the auth token being used by this client
-
setAuthTokenSupplier
Set auth token supplier for gitlab api client.- Parameters:
authTokenSupplier
- - supplier which provide actual auth token
-
getSecretToken
Get the secret token.- Returns:
- the secret token
-
getTokenType
Get the TokenType this client is using.- Returns:
- the TokenType this client is using
-
getApiVersion
Return the GitLab API version that this instance is using.- Returns:
- the GitLab API version that this instance is using
-
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
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
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
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
-
getAuditEventApi
Gets the AuditEventApi instance owned by this GitLabApi instance. The AuditEventApi is used to perform all instance audit event API calls.- Returns:
- the AuditEventApi instance owned by this GitLabApi instance
-
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
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
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
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
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
-
getDeploymentsApi
Gets the DeployKeysApi instance owned by this GitLabApi instance. The DeploymentsApi is used to perform all deployment related API calls.- Returns:
- the DeploymentsApi instance owned by this GitLabApi instance
-
getDeployTokensApi
Gets the DeployTokensApi instance owned by this GitLabApi instance. The DeployTokensApi is used to perform all deploy token related API calls.- Returns:
- the DeployTokensApi instance owned by this GitLabApi instance
-
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
-
getEnvironmentsApi
Gets the EnvironmentsApi instance owned by this GitLabApi instance. The EnvironmentsApi is used to perform all environment related API calls.- Returns:
- the EnvironmentsApi instance owned by this GitLabApi instance
-
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
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
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
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
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
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
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
-
getLicenseApi
Gets the LicenseApi instance owned by this GitLabApi instance. The LicenseApi is used to perform all license related API calls.- Returns:
- the LicenseApi instance owned by this GitLabApi instance
-
getLicenseTemplatesApi
Gets the LicenseTemplatesApi instance owned by this GitLabApi instance. The LicenseTemplatesApi is used to perform all license template related API calls.- Returns:
- the LicenseTemplatesApi instance owned by this GitLabApi instance
-
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
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
Gets the MilsestonesApi instance owned by this GitLabApi instance.- Returns:
- the MilsestonesApi instance owned by this GitLabApi instance
-
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
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
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
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
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
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
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
-
getReleasesApi
Gets the ReleasesApi instance owned by this GitLabApi instance. The ReleasesApi is used to perform all release related API calls.- Returns:
- the ReleasesApi instance owned by this GitLabApi instance
-
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
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
-
getResourceLabelEventsApi
Gets the ResourceLabelEventsApi instance owned by this GitLabApi instance. The ResourceLabelEventsApi is used to perform all Resource Label Events related API calls.- Returns:
- the ResourceLabelEventsApi instance owned by this GitLabApi instance
-
getResourceStateEventsApi
Gets the ResourceStateEventsApi instance owned by this GitLabApi instance. The ResourceStateEventsApi is used to perform all Resource State Events related API calls.- Returns:
- the ResourceStateEventsApi instance owned by this GitLabApi instance
-
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
-
getSearchApi
Gets the SearchApi instance owned by this GitLabApi instance. The SearchApi is used to perform search related API calls.- Returns:
- the SearchApi instance owned by this GitLabApi instance
-
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
-
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
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
-
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
-
getTodosApi
Gets the TodosApi instance owned by this GitLabApi instance. The TodosApi is used to perform all Todo related API calls.- Returns:
- the TodosApi instance owned by this GitLabApi instance
-
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
-
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
-
getKeysAPI
Gets the KeysApi instance owned by this GitLabApi instance. The KeysApi is used to look up users by their ssh key signatures- Returns:
- the KeysApi instance owned by this GitLabApi instance
-
createOptionalFromException
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
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
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
-