Class GitLab
java.lang.Object
com.mooltiverse.oss.nyx.services.gitlab.GitLab
- All Implemented Interfaces:
GitHostingService,ReleaseService,Service,UserService
The entry point to the GitLab remote service.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.mooltiverse.oss.nyx.services.Service
Service.Feature -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the option used to pass the authentication token (Personal Access Token, OAuth) to this object instance.static final StringThe name of the option used to pass the base URI to this object instance.static final StringThe name of the option used to pass the list of supported remotes to this object instance.static final StringThe name of the option used to pass the name of the Git repository to this object instance.static final StringThe name of the option used to pass the owner of the Git repository to this object instance.Fields inherited from interface com.mooltiverse.oss.nyx.services.ReleaseService
RELEASE_OPTION_DRAFT, RELEASE_OPTION_PRE_RELEASE -
Method Summary
Modifier and TypeMethodDescriptioncreateGitRepository(String name, String description, boolean restricted, boolean initialize) Creates a new Git repository for the currently authenticated user.voiddeleteGitRepository(String name) Deletes a Git repository for the currently authenticated user.Retrieves informations about the currently authenticated user.getReleaseByTag(String owner, String repository, String tag) Finds the release in the given repository by the release tag.static GitLabReturns an instance using the given options.publishRelease(String owner, String repository, String title, String tag, String description, Map<String, Object> options) Publishes a new release.publishReleaseAssets(String owner, String repository, Release release, Set<Attachment> assets) Publishes a set of assets for a release.booleansupports(Service.Feature feature) Safely checks if the underlying implementation supports the given operation.
-
Field Details
-
BASE_URI_OPTION_NAME
The name of the option used to pass the base URI to this object instance. This is the value of the key inside the options passed to get a new instance of this class. If this option is not passed the default URI is used. Value: "BASE_URI"- See Also:
-
AUTHENTICATION_TOKEN_OPTION_NAME
The name of the option used to pass the authentication token (Personal Access Token, OAuth) to this object instance. This is the value of the key inside the options passed to get a new instance of this class. If this option is not passed the service will not be able to authenticate and perform any of the authentication protected operations. Value: "AUTHENTICATION_TOKEN"- See Also:
-
REMOTES_OPTION_NAME
The name of the option used to pass the list of supported remotes to this object instance. This is the value of the key inside the options passed to get a new instance of this class. If this option is not passed the service will not be able to perform some of its operations. Value: "REMOTES"- See Also:
-
REPOSITORY_NAME_OPTION_NAME
The name of the option used to pass the name of the Git repository to this object instance. If the repository ishttps://gitlab.com/jdoe/project, the value to pass for this option isproject, while if it's a hierarchical project likehttps://gitlab.com/acme/project/at/some/depth, the value to pass for this option isproject/at/some/depth. Leading and trailing slashes must be omitted, if any. This is the value of the key inside the options passed to get a new instance of this class. If this option is not passed the service will not be able to perform some of its operations. Value: "REPOSITORY_NAME"- See Also:
-
REPOSITORY_OWNER_OPTION_NAME
The name of the option used to pass the owner of the Git repository to this object instance. If the repository ishttps://gitlab.com/jdoe/project, the value to pass for this option isjdoe, and if it's a hierarchical project likehttps://gitlab.com/acme/project/at/some/depth, the value to pass for this option isacme. Leading and trailing slashes must be omitted, if any. This is the value of the key inside the options passed to get a new instance of this class. If this option is not passed the service will not be able to perform some of its operations. Value: "REPOSITORY_OWNER"- See Also:
-
-
Method Details
-
instance
Returns an instance using the given options.- Parameters:
options- the map of options for the requested service. It can't benull. Valid options are documented as constants on this class.- Returns:
- an instance using the given options.
- Throws:
NullPointerException- if the given options map isnullIllegalArgumentException- if some entries in the given options map are missing or illegal for some reason
-
createGitRepository
public GitLabRepository createGitRepository(String name, String description, boolean restricted, boolean initialize) throws SecurityException, TransportException Creates a new Git repository for the currently authenticated user.
Please note that if the service has been configured with repository owner and name those attributes are ignored by this method as the owner is always the authenticated user (the one owning the configured credentials) and the name is always thenameattribute.- Specified by:
createGitRepositoryin interfaceGitHostingService- Parameters:
name- the repository name. Cannot benulldescription- the repository description. It may benullrestricted- whentruethe repository will have private visibility, otherwise it will be publicinitialize- whentruethe repository is also initialized (usually with a default README file)- Returns:
- the object representing the newly created repository
- Throws:
SecurityException- if authentication or authorization fails or there is no currently authenticated userTransportException- if communication to the remote endpoint fails
-
deleteGitRepository
Deletes a Git repository for the currently authenticated user.
Please note that if the service has been configured with repository owner and name those attributes are ignored by this method as the owner is always the authenticated user (the one owning the configured credentials) and the name is always thenameattribute.- Specified by:
deleteGitRepositoryin interfaceGitHostingService- Parameters:
name- the repository name. Cannot benull- Throws:
SecurityException- if authentication or authorization fails or there is no currently authenticated userTransportException- if communication to the remote endpoint fails
-
getAuthenticatedUser
Retrieves informations about the currently authenticated user. The authenticated user is the one owning the configured credentials.- Specified by:
getAuthenticatedUserin interfaceUserService- Returns:
- the authenticated user
- Throws:
TransportException- if communication to the remote endpoint failsSecurityException- if authentication or authorization fails or there is no currently authenticated user
-
getReleaseByTag
public GitLabRelease getReleaseByTag(String owner, String repository, String tag) throws SecurityException, TransportException Finds the release in the given repository by the release tag.- Specified by:
getReleaseByTagin interfaceReleaseService- Parameters:
owner- the name of the repository owner to get the release for. It may benull, in which case, the repository owner must be passed as a service option (see services implementing this interface for more details on the options they accept). If notnullthis value overrides the option passed to the service.repository- the name of the repository to get the release for. It may benull, in which case, the repository name must be passed as a service option (see services implementing this interface for more details on the options they accept). If notnullthis value overrides the option passed to the service.tag- the tag the release refers to (i.e.1.2.3,v4.5.6). It can't benull- Returns:
- the release for the given tag, or
nullif there is no such release - Throws:
SecurityException- if authentication or authorization failsTransportException- if communication to the remote endpoint fails
-
publishRelease
public GitLabRelease publishRelease(String owner, String repository, String title, String tag, String description, Map<String, Object> options) throws SecurityException, TransportExceptionPublishes a new release.- Specified by:
publishReleasein interfaceReleaseService- Parameters:
owner- the name of the repository owner to create the release for. It may benull, in which case, the repository owner must be passed as a service option (see services implementing this interface for more details on the options they accept). If notnullthis value overrides the option passed to the service.repository- the name of the repository to create the release for. It may benull, in which case, the repository name must be passed as a service option (see services implementing this interface for more details on the options they accept). If notnullthis value overrides the option passed to the service.title- the release title, it may be the same oftagbut not necessarily. It may benulltag- tag to publish the release for (i.e.1.2.3,v4.5.6). It can't benulldescription- the release description. This is usually a Markdown text containing release notes or a changelog or something like that giving an overall description of the releaseoptions- the optional map of release options (ReleaseService.RELEASE_OPTION_DRAFT,ReleaseService.RELEASE_OPTION_PRE_RELEASE). Whennullno options are evaluated.- Returns:
- the newly created release
- Throws:
SecurityException- if authentication or authorization failsTransportException- if communication to the remote endpoint fails
-
publishReleaseAssets
public GitLabRelease publishReleaseAssets(String owner, String repository, Release release, Set<Attachment> assets) throws SecurityException, TransportException Publishes a set of assets for a release. Even when the service supports theService.Feature.RELEASE_ASSETSfeature not all types of assets may be supported. Please check the implementation class for any restrictions on the supported assets.- Specified by:
publishReleaseAssetsin interfaceReleaseService- Parameters:
owner- the name of the repository owner to create the assets for. It may benull, in which case, the repository owner must be passed as a service option (see services implementing this interface for more details on the options they accept). If notnullthis value overrides the option passed to the service.repository- the name of the repository to create the assets for. It may benull, in which case, the repository name must be passed as a service option (see services implementing this interface for more details on the options they accept). If notnullthis value overrides the option passed to the service.release- the release to publish the assets for. It must be an object created by the same service implementationassets- the set of assets to publish. Assets may be interpreted differently depending on theirpathandtype. Please check the implementation class for restrictions on the supported assets- Returns:
- the given release with also the links to the uploaded assets. The returned object represents the same release provided as parameter but may be a different instance. Only the assets that were actually published are returned while those not supported by the implementing service are not within the list of assets referred by the returned object
- Throws:
SecurityException- if authentication or authorization failsTransportException- if communication to the remote endpoint fails
-
supports
Safely checks if the underlying implementation supports the given operation. If this method returnstruethen the underlying class will not raise anyUnsupportedOperationExceptionwhen invoking the specific methods.
-