Package org.gitlab4j.api
Class SnippetsApi
java.lang.Object
org.gitlab4j.api.AbstractApi
org.gitlab4j.api.SnippetsApi
- All Implemented Interfaces:
Constants
public class SnippetsApi extends AbstractApi
This class provides an entry point to all the GitLab Snippets API project calls.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.gitlab4j.api.Constants
Constants.ActionType, Constants.ApplicationScope, Constants.ArchiveFormat, Constants.AutoDevopsDeployStrategy, Constants.BuildGitStrategy, Constants.CommitBuildState, Constants.ContributorOrderBy, Constants.DeploymentOrderBy, Constants.DeploymentStatus, Constants.DeployTokenScope, Constants.Encoding, Constants.EpicOrderBy, Constants.EventScope, Constants.GroupOrderBy, Constants.GroupSearchScope, Constants.ImpersonationState, Constants.IssueOrderBy, Constants.IssueScope, Constants.IssueState, Constants.JobScope, Constants.LineType, Constants.MergeRequestOrderBy, Constants.MergeRequestScope, Constants.MergeRequestSearchIn, Constants.MergeRequestState, Constants.MilestoneState, Constants.PackageOrderBy, Constants.PackageStatus, Constants.PipelineOrderBy, Constants.PipelineScope, Constants.ProjectOrderBy, Constants.ProjectSearchScope, Constants.SearchScope, Constants.SortOrder, Constants.SquashOption, Constants.StateEvent, Constants.TagOrderBy, Constants.TargetType, Constants.TodoAction, Constants.TodoState, Constants.TodoType, Constants.TokenType
-
Field Summary
Fields inherited from class org.gitlab4j.api.AbstractApi
gitLabApi
Fields inherited from interface org.gitlab4j.api.Constants
NEXT_PAGE_HEADER, PAGE_HEADER, PAGE_PARAM, PER_PAGE, PER_PAGE_PARAM, PREV_PAGE_HEADER, TOTAL_HEADER, TOTAL_PAGES_HEADER
-
Constructor Summary
Constructors Constructor Description SnippetsApi(GitLabApi gitLabApi)
-
Method Summary
Modifier and Type Method Description Snippet
createSnippet(String title, String fileName, String content)
Create a new Snippet.Snippet
createSnippet(String title, String fileName, String content, Visibility visibility, String description)
Create a new Snippet.void
deleteSnippet(Long snippetId)
Removes Snippet.Optional<Snippet>
getOptionalSnippet(Long snippetId)
Get a specific snippet as an Optional instance.Optional<Snippet>
getOptionalSnippet(Long snippetId, boolean downloadContent)
Get a specific snippet as an Optional instance.Snippet
getSnippet(Long snippetId)
Get a specific Snippet.Snippet
getSnippet(Long snippetId, boolean downloadContent)
Get a specific Snippet.String
getSnippetContent(Long snippetId)
Get the content of a Snippet.List<Snippet>
getSnippets()
Get a list of the authenticated user's snippets.List<Snippet>
getSnippets(boolean downloadContent)
Get a list of the authenticated user's snippets.Pager<Snippet>
getSnippets(int itemsPerPage)
Get a Pager of the authenticated user's snippets.Stream<Snippet>
getSnippetsStream()
Get a Stream of the authenticated user's snippets.Methods inherited from class org.gitlab4j.api.AbstractApi
addFormParam, addFormParam, delete, delete, get, get, getApiClient, getApiVersion, getDefaultPerPage, getDefaultPerPageParam, getDefaultPerPageParam, getGroupIdOrPath, getLabelIdOrName, getPageQueryParams, getPageQueryParams, getPerPageQueryParam, getProjectIdOrPath, getUserIdOrUsername, getWithAccepts, handle, head, isApiVersion, post, post, post, post, post, put, put, put, putUpload, putUpload, putWithFormData, upload, upload, upload, upload, urlEncode, validate
-
Constructor Details
-
SnippetsApi
-
-
Method Details
-
getSnippets
Get a list of the authenticated user's snippets.GitLab Endpoint: GET /snippets
- Parameters:
downloadContent
- indicating whether to download the snippet content- Returns:
- a list of authenticated user's snippets
- Throws:
GitLabApiException
- if any exception occurs
-
getSnippets
Get a list of the authenticated user's snippets.GitLab Endpoint: GET /snippets
- Returns:
- a list of authenticated user's snippets
- Throws:
GitLabApiException
- if any exception occurs
-
getSnippets
Get a Pager of the authenticated user's snippets.GitLab Endpoint: GET /snippets
- Parameters:
itemsPerPage
- the number of snippets per page- Returns:
- the Pager of snippets
- Throws:
GitLabApiException
- if any exception occurs
-
getSnippetsStream
Get a Stream of the authenticated user's snippets.GitLab Endpoint: GET /snippets
- Returns:
- a Stream of authenticated user's snippets
- Throws:
GitLabApiException
- if any exception occurs
-
getSnippetContent
Get the content of a Snippet.GitLab Endpoint: GET /snippets/:id/raw
- Parameters:
snippetId
- the snippet ID to remove- Returns:
- the content of snippet
- Throws:
GitLabApiException
- if any exception occurs
-
getSnippet
Get a specific Snippet.- Parameters:
snippetId
- the snippet ID to getdownloadContent
- indicating whether to download the snippet content- Returns:
- the snippet with the given id
- Throws:
GitLabApiException
- if any exception occurs
-
getSnippet
Get a specific Snippet.- Parameters:
snippetId
- the snippet ID to get- Returns:
- the snippet with the given id
- Throws:
GitLabApiException
- if any exception occurs
-
getOptionalSnippet
Get a specific snippet as an Optional instance.GitLab Endpoint: GET /snippets/:snippet_id
- Parameters:
snippetId
- the ID of the snippet to get the Optional instance for- Returns:
- the specified Snippet as an Optional instance
-
getOptionalSnippet
Get a specific snippet as an Optional instance.GitLab Endpoint: GET /snippets/:snippet_id
- Parameters:
snippetId
- the ID of the snippet to get the Optional instance fordownloadContent
- indicating whether to download the snippet content- Returns:
- the specified Snippet as an Optional instance
-
createSnippet
public Snippet createSnippet(String title, String fileName, String content) throws GitLabApiExceptionCreate a new Snippet.- Parameters:
title
- the title of the snippetfileName
- the file name of the snippetcontent
- the content of the snippet- Returns:
- the created Snippet
- Throws:
GitLabApiException
- if any exception occurs
-
createSnippet
public Snippet createSnippet(String title, String fileName, String content, Visibility visibility, String description) throws GitLabApiExceptionCreate a new Snippet.- Parameters:
title
- the title of the snippetfileName
- the file name of the snippetcontent
- the content of the snippetvisibility
- the visibility (Public, Internal, Private) of the snippetdescription
- the description of the snippet- Returns:
- the created Snippet
- Throws:
GitLabApiException
- if any exception occurs
-
deleteSnippet
Removes Snippet.GitLab Endpoint: DELETE /snippets/:id
- Parameters:
snippetId
- the snippet ID to remove- Throws:
GitLabApiException
- if any exception occurs
-