idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
34,800
public Milestone createGroupMilestone ( Object groupIdOrPath , String title , String description , Date dueDate , Date startDate ) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "title" , title , true ) . withParam ( "description" , description ) . withParam ( "due_date" , dueDate ) . withParam ( "start_date" , startDate ) ; Response response = post ( Response . Status . CREATED , formData , "groups" , getGroupIdOrPath ( groupIdOrPath ) , "milestones" ) ; return ( response . readEntity ( Milestone . class ) ) ; }
Create a group milestone .
34,801
public Milestone closeGroupMilestone ( Object groupIdOrPath , Integer milestoneId ) throws GitLabApiException { if ( milestoneId == null ) { throw new RuntimeException ( "milestoneId cannot be null" ) ; } GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "state_event" , MilestoneState . CLOSE ) ; Response response = put ( Response . Status . OK , formData . asMap ( ) , "groups" , getGroupIdOrPath ( groupIdOrPath ) , "milestones" , milestoneId ) ; return ( response . readEntity ( Milestone . class ) ) ; }
Close a group milestone .
34,802
public Pager < Milestone > getMilestones ( Object projectIdOrPath , int itemsPerPage ) throws GitLabApiException { return ( new Pager < Milestone > ( this , Milestone . class , itemsPerPage , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "milestones" ) ) ; }
Get a Page of project milestones .
34,803
public Stream < Milestone > getMilestonesStream ( Object projectIdOrPath ) throws GitLabApiException { return ( getMilestones ( projectIdOrPath , getDefaultPerPage ( ) ) . stream ( ) ) ; }
Get a Stream of project milestones .
34,804
public List < Milestone > getMilestones ( Object projectIdOrPath , MilestoneState state ) throws GitLabApiException { Form formData = new GitLabApiForm ( ) . withParam ( "state" , state ) . withParam ( PER_PAGE_PARAM , getDefaultPerPage ( ) ) ; Response response = get ( Response . Status . OK , formData . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "milestones" ) ; return ( response . readEntity ( new GenericType < List < Milestone > > ( ) { } ) ) ; }
Get a list of project milestones that have the specified state .
34,805
public Milestone getMilestone ( Object projectIdOrPath , Integer milestoneId ) throws GitLabApiException { Response response = get ( Response . Status . OK , getDefaultPerPageParam ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "milestones" , milestoneId ) ; return ( response . readEntity ( Milestone . class ) ) ; }
Get the specified milestone .
34,806
public List < Issue > getIssues ( Object projectIdOrPath , Integer milestoneId ) throws GitLabApiException { Response response = get ( Response . Status . OK , getDefaultPerPageParam ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "milestones" , milestoneId , "issues" ) ; return ( response . readEntity ( new GenericType < List < Issue > > ( ) { } ) ) ; }
Get the list of issues associated with the specified milestone .
34,807
public List < MergeRequest > getMergeRequest ( Object projectIdOrPath , Integer milestoneId ) throws GitLabApiException { Response response = get ( Response . Status . OK , getDefaultPerPageParam ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "milestones" , milestoneId , "merge_requests" ) ; return ( response . readEntity ( new GenericType < List < MergeRequest > > ( ) { } ) ) ; }
Get the list of merge requests associated with the specified milestone .
34,808
public Milestone createMilestone ( Object projectIdOrPath , String title , String description , Date dueDate , Date startDate ) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "title" , title , true ) . withParam ( "description" , description ) . withParam ( "due_date" , dueDate ) . withParam ( "start_date" , startDate ) ; Response response = post ( Response . Status . CREATED , formData , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "milestones" ) ; return ( response . readEntity ( Milestone . class ) ) ; }
Create a milestone .
34,809
public Milestone activateMilestone ( Object projectIdOrPath , Integer milestoneId ) throws GitLabApiException { if ( milestoneId == null ) { throw new RuntimeException ( "milestoneId cannot be null" ) ; } GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "state_event" , MilestoneState . ACTIVATE ) ; Response response = put ( Response . Status . OK , formData . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "milestones" , milestoneId ) ; return ( response . readEntity ( Milestone . class ) ) ; }
Activate a milestone .
34,810
public Milestone updateMilestone ( Object projectIdOrPath , Integer milestoneId , String title , String description , Date dueDate , Date startDate , MilestoneState milestoneState ) throws GitLabApiException { if ( milestoneId == null ) { throw new RuntimeException ( "milestoneId cannot be null" ) ; } GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "title" , title , true ) . withParam ( "description" , description ) . withParam ( "due_date" , dueDate ) . withParam ( "start_date" , startDate ) . withParam ( "state_event" , milestoneState ) ; Response response = put ( Response . Status . OK , formData . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "milestones" , milestoneId ) ; return ( response . readEntity ( Milestone . class ) ) ; }
Update the specified milestone .
34,811
public List < Issue > getIssues ( int page , int perPage ) throws GitLabApiException { Response response = get ( Response . Status . OK , getPageQueryParams ( page , perPage ) , "issues" ) ; return ( response . readEntity ( new GenericType < List < Issue > > ( ) { } ) ) ; }
Get all issues the authenticated user has access to using the specified page and per page setting . Only returns issues created by the current user .
34,812
public Pager < Issue > getIssues ( int itemsPerPage ) throws GitLabApiException { return ( new Pager < Issue > ( this , Issue . class , itemsPerPage , null , "issues" ) ) ; }
Get a Pager of all issues the authenticated user has access to . Only returns issues created by the current user .
34,813
public Pager < Issue > getIssues ( Object projectIdOrPath , int itemsPerPage ) throws GitLabApiException { return ( new Pager < Issue > ( this , Issue . class , itemsPerPage , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "issues" ) ) ; }
Get a Pager of project s issues .
34,814
public Pager < Issue > getIssues ( IssueFilter filter , int itemsPerPage ) throws GitLabApiException { GitLabApiForm formData = filter . getQueryParams ( ) ; return ( new Pager < Issue > ( this , Issue . class , itemsPerPage , formData . asMap ( ) , "issues" ) ) ; }
Get all issues the authenticated user has access to . By default it returns only issues created by the current user .
34,815
public Issue getIssue ( Object projectIdOrPath , Integer issueIid ) throws GitLabApiException { Response response = get ( Response . Status . OK , getDefaultPerPageParam ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "issues" , issueIid ) ; return ( response . readEntity ( Issue . class ) ) ; }
Get a single project issue .
34,816
public Optional < Issue > getOptionalIssue ( Object projectIdOrPath , Integer issueIid ) { try { return ( Optional . ofNullable ( getIssue ( projectIdOrPath , issueIid ) ) ) ; } catch ( GitLabApiException glae ) { return ( GitLabApi . createOptionalFromException ( glae ) ) ; } }
Get a single project issue as an Optional instance .
34,817
public Issue closeIssue ( Object projectIdOrPath , Integer issueIid ) throws GitLabApiException { if ( issueIid == null ) { throw new RuntimeException ( "issue IID cannot be null" ) ; } GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "state_event" , StateEvent . CLOSE ) ; Response response = put ( Response . Status . OK , formData . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "issues" , issueIid ) ; return ( response . readEntity ( Issue . class ) ) ; }
Closes an existing project issue .
34,818
public Issue updateIssue ( Object projectIdOrPath , Integer issueIid , String title , String description , Boolean confidential , List < Integer > assigneeIds , Integer milestoneId , String labels , StateEvent stateEvent , Date updatedAt , Date dueDate ) throws GitLabApiException { if ( issueIid == null ) { throw new RuntimeException ( "issue IID cannot be null" ) ; } GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "title" , title ) . withParam ( "description" , description ) . withParam ( "confidential" , confidential ) . withParam ( "assignee_ids" , assigneeIds ) . withParam ( "milestone_id" , milestoneId ) . withParam ( "labels" , labels ) . withParam ( "state_event" , stateEvent ) . withParam ( "updated_at" , updatedAt ) . withParam ( "due_date" , dueDate ) ; Response response = put ( Response . Status . OK , formData . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "issues" , issueIid ) ; return ( response . readEntity ( Issue . class ) ) ; }
Updates an existing project issue . This call can also be used to mark an issue as closed .
34,819
public void deleteIssue ( Object projectIdOrPath , Integer issueIid ) throws GitLabApiException { if ( issueIid == null ) { throw new RuntimeException ( "issue IID cannot be null" ) ; } Response . Status expectedStatus = ( isApiVersion ( ApiVersion . V3 ) ? Response . Status . OK : Response . Status . NO_CONTENT ) ; delete ( expectedStatus , getDefaultPerPageParam ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "issues" , issueIid ) ; }
Delete an issue .
34,820
public TimeStats resetSpentTime ( Object projectIdOrPath , Integer issueIid ) throws GitLabApiException { if ( issueIid == null ) { throw new RuntimeException ( "issue IID cannot be null" ) ; } Response response = post ( Response . Status . OK , new GitLabApiForm ( ) . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "issues" , issueIid , "reset_spent_time" ) ; return ( response . readEntity ( TimeStats . class ) ) ; }
Resets the total spent time for this issue to 0 seconds .
34,821
public Optional < TimeStats > getOptionalTimeTrackingStats ( Object projectIdOrPath , Integer issueIid ) { try { return ( Optional . ofNullable ( getTimeTrackingStats ( projectIdOrPath , issueIid ) ) ) ; } catch ( GitLabApiException glae ) { return ( GitLabApi . createOptionalFromException ( glae ) ) ; } }
Get time tracking stats as an Optional instance
34,822
public Pager < MergeRequest > getClosedByMergeRequests ( Object projectIdOrPath , Integer issueIid , int itemsPerPage ) throws GitLabApiException { return new Pager < MergeRequest > ( this , MergeRequest . class , itemsPerPage , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "issues" , issueIid , "closed_by" ) ; }
Get a Pager containing all the merge requests that will close issue when merged .
34,823
public final GitLabApi duplicate ( ) { Integer sudoUserId = this . getSudoAsId ( ) ; GitLabApi gitLabApi = new GitLabApi ( apiVersion , gitLabServerUrl , getTokenType ( ) , getAuthToken ( ) , getSecretToken ( ) , clientConfigProperties ) ; if ( sudoUserId != null ) { gitLabApi . apiClient . setSudoAsId ( sudoUserId ) ; } if ( getIgnoreCertificateErrors ( ) ) { gitLabApi . setIgnoreCertificateErrors ( true ) ; } gitLabApi . defaultPerPage = this . defaultPerPage ; return ( gitLabApi ) ; }
Create a new GitLabApi instance that is logically a duplicate of this instance with the exception off sudo state .
34,824
public void enableRequestResponseLogging ( Logger logger , Level level , int maxEntitySize ) { enableRequestResponseLogging ( logger , level , maxEntitySize , MaskingLoggingFilter . DEFAULT_MASKED_HEADER_NAMES ) ; }
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 .
34,825
public void enableRequestResponseLogging ( Level level , int maxEntitySize , List < String > maskedHeaderNames ) { apiClient . enableRequestResponseLogging ( LOGGER , level , maxEntitySize , maskedHeaderNames ) ; }
Enable the logging of the requests to and the responses from the GitLab server API using the GitLab4J shared Logger instance .
34,826
public void enableRequestResponseLogging ( Logger logger , Level level , int maxEntitySize , List < String > maskedHeaderNames ) { apiClient . enableRequestResponseLogging ( logger , level , maxEntitySize , maskedHeaderNames ) ; }
Enable the logging of the requests to and the responses from the GitLab server API using the specified logger .
34,827
public Version getVersion ( ) throws GitLabApiException { class VersionApi extends AbstractApi { VersionApi ( GitLabApi gitlabApi ) { super ( gitlabApi ) ; } } Response response = new VersionApi ( this ) . get ( Response . Status . OK , null , "version" ) ; return ( response . readEntity ( Version . class ) ) ; }
Get the version info for the GitLab server using the GitLab Version API .
34,828
protected static final < T > Optional < T > createOptionalFromException ( GitLabApiException glae ) { Optional < T > optional = Optional . empty ( ) ; optionalExceptionMap . put ( System . identityHashCode ( optional ) , glae ) ; return ( optional ) ; }
Create and return an Optional instance associated with a GitLabApiException .
34,829
public static final < T > T orElseThrow ( Optional < T > optional ) throws GitLabApiException { GitLabApiException glea = getOptionalException ( optional ) ; if ( glea != null ) { throw ( glea ) ; } return ( optional . get ( ) ) ; }
Return the Optional instances contained value if present otherwise throw the exception that is associated with the Optional instance .
34,830
public List < AwardEmoji > getNoteAwardEmojis ( Object projectIdOrPath , Integer issueIid , Integer noteId ) throws GitLabApiException { Response response = get ( Response . Status . OK , getPageQueryParams ( 1 , getDefaultPerPage ( ) ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "issues" , issueIid , "notes" , noteId , "award_emoji" ) ; return response . readEntity ( new GenericType < List < AwardEmoji > > ( ) { } ) ; }
Get a list of award emoji for the specified note .
34,831
public AwardEmoji getIssueAwardEmoji ( Object projectIdOrPath , Integer issueIid , Integer awardId ) throws GitLabApiException { Response response = get ( Response . Status . OK , getPageQueryParams ( 1 , getDefaultPerPage ( ) ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "issues" , issueIid , "award_emoji" , awardId ) ; return ( response . readEntity ( AwardEmoji . class ) ) ; }
Get the specified award emoji for the specified issue .
34,832
public AwardEmoji getMergeRequestAwardEmoji ( Object projectIdOrPath , Integer mergeRequestIid , Integer awardId ) throws GitLabApiException { Response response = get ( Response . Status . OK , getPageQueryParams ( 1 , getDefaultPerPage ( ) ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "merge_requests" , mergeRequestIid , "award_emoji" , awardId ) ; return ( response . readEntity ( AwardEmoji . class ) ) ; }
Get the specified award emoji for the specified merge request .
34,833
public AwardEmoji getSnippetAwardEmoji ( Object projectIdOrPath , Integer snippetId , Integer awardId ) throws GitLabApiException { Response response = get ( Response . Status . OK , getPageQueryParams ( 1 , getDefaultPerPage ( ) ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "snippets" , snippetId , "award_emoji" , awardId ) ; return ( response . readEntity ( AwardEmoji . class ) ) ; }
Get the specified award emoji for the specified snippet .
34,834
public AwardEmoji addNoteAwardEmoji ( Object projectIdOrPath , Integer issueIid , Integer noteId , String name ) throws GitLabApiException { GitLabApiForm form = new GitLabApiForm ( ) . withParam ( "name" , name , true ) ; Response response = post ( Response . Status . CREATED , form . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "issues" , issueIid , "notes" , noteId , "award_emoji" ) ; return ( response . readEntity ( AwardEmoji . class ) ) ; }
Add an award emoji for the specified note .
34,835
public void deleteIssueAwardEmoji ( Object projectIdOrPath , Integer issueIid , Integer awardId ) throws GitLabApiException { delete ( Response . Status . NO_CONTENT , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "issues" , issueIid , "award_emoji" , awardId ) ; }
Delete an award emoji from the specified issue .
34,836
public void deleteMergeRequestAwardEmoji ( Object projectIdOrPath , Integer mergeRequestIid , Integer awardId ) throws GitLabApiException { delete ( Response . Status . NO_CONTENT , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "merge_requests" , mergeRequestIid , "award_emoji" , awardId ) ; }
Delete an award emoji from the specified merge request .
34,837
public void deleteSnippetAwardEmoji ( Object projectIdOrPath , Integer snippetId , Integer awardId ) throws GitLabApiException { delete ( Response . Status . NO_CONTENT , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "snippets" , snippetId , "award_emoji" , awardId ) ; }
Delete an award emoji from the specified snippet .
34,838
public Pager < Branch > getBranches ( Object projectIdOrPath , int itemsPerPage ) throws GitLabApiException { return ( new Pager < Branch > ( this , Branch . class , itemsPerPage , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "repository" , "branches" ) ) ; }
Get a Pager of repository branches from a project sorted by name alphabetically .
34,839
public Stream < Branch > getBranchesStream ( Object projectIdOrPath ) throws GitLabApiException { return ( getBranches ( projectIdOrPath , getDefaultPerPage ( ) ) . stream ( ) ) ; }
Get a Stream of repository branches from a project sorted by name alphabetically .
34,840
public Branch getBranch ( Object projectIdOrPath , String branchName ) throws GitLabApiException { Response response = get ( Response . Status . OK , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "repository" , "branches" , urlEncode ( branchName ) ) ; return ( response . readEntity ( Branch . class ) ) ; }
Get a single project repository branch .
34,841
public Optional < Branch > getOptionalBranch ( Object projectIdOrPath , String branchName ) throws GitLabApiException { try { return ( Optional . ofNullable ( getBranch ( projectIdOrPath , branchName ) ) ) ; } catch ( GitLabApiException glae ) { return ( GitLabApi . createOptionalFromException ( glae ) ) ; } }
Get an Optional instance with the value for the specific repository branch .
34,842
public Branch createBranch ( Object projectIdOrPath , String branchName , String ref ) throws GitLabApiException { Form formData = new GitLabApiForm ( ) . withParam ( isApiVersion ( ApiVersion . V3 ) ? "branch_name" : "branch" , branchName , true ) . withParam ( "ref" , ref , true ) ; Response response = post ( Response . Status . CREATED , formData . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "repository" , "branches" ) ; return ( response . readEntity ( Branch . class ) ) ; }
Creates a branch for the project . Support as of version 6 . 8 . x
34,843
public void deleteBranch ( Object projectIdOrPath , String branchName ) throws GitLabApiException { Response . Status expectedStatus = ( isApiVersion ( ApiVersion . V3 ) ? Response . Status . OK : Response . Status . NO_CONTENT ) ; delete ( expectedStatus , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "repository" , "branches" , urlEncode ( branchName ) ) ; }
Delete a single project repository branch .
34,844
public Branch protectBranch ( Object projectIdOrPath , String branchName ) throws GitLabApiException { Response response = put ( Response . Status . OK , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "repository" , "branches" , urlEncode ( branchName ) , "protect" ) ; return ( response . readEntity ( Branch . class ) ) ; }
Protects a single project repository branch . This is an idempotent function protecting an already protected repository branch will not produce an error .
34,845
public Tag createTag ( Object projectIdOrPath , String tagName , String ref , String message , String releaseNotes ) throws GitLabApiException { Form formData = new GitLabApiForm ( ) . withParam ( "tag_name" , tagName , true ) . withParam ( "ref" , ref , true ) . withParam ( "message" , message , false ) . withParam ( "release_description" , releaseNotes , false ) ; Response response = post ( Response . Status . CREATED , formData . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "repository" , "tags" ) ; return ( response . readEntity ( Tag . class ) ) ; }
Creates a tag on a particular ref of the given project . A message and release notes are optional .
34,846
public void deleteTag ( Object projectIdOrPath , String tagName ) throws GitLabApiException { Response . Status expectedStatus = ( isApiVersion ( ApiVersion . V3 ) ? Response . Status . OK : Response . Status . NO_CONTENT ) ; delete ( expectedStatus , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "repository" , "tags" , tagName ) ; }
Deletes the tag from a project with the specified tag name .
34,847
public List < Contributor > getContributors ( Object projectIdOrPath , int page , int perPage ) throws GitLabApiException { Response response = get ( Response . Status . OK , getPageQueryParams ( page , perPage ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "repository" , "contributors" ) ; return ( response . readEntity ( new GenericType < List < Contributor > > ( ) { } ) ) ; }
Get a list of contributors from a project and in the specified page range .
34,848
public Pager < Contributor > getContributors ( Object projectIdOrPath , int itemsPerPage ) throws GitLabApiException { return new Pager < Contributor > ( this , Contributor . class , itemsPerPage , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "repository" , "contributors" ) ; }
Get a Pager of contributors from a project .
34,849
public Object getProjectIdOrPath ( Object obj ) throws GitLabApiException { if ( obj == null ) { throw ( new RuntimeException ( "Cannot determine ID or path from null object" ) ) ; } else if ( obj instanceof Integer ) { return ( obj ) ; } else if ( obj instanceof String ) { return ( urlEncode ( ( ( String ) obj ) . trim ( ) ) ) ; } else if ( obj instanceof Project ) { Integer id = ( ( Project ) obj ) . getId ( ) ; if ( id != null && id . intValue ( ) > 0 ) { return ( id ) ; } String path = ( ( Project ) obj ) . getPathWithNamespace ( ) ; if ( path != null && path . trim ( ) . length ( ) > 0 ) { return ( urlEncode ( path . trim ( ) ) ) ; } throw ( new RuntimeException ( "Cannot determine ID or path from provided Project instance" ) ) ; } else { throw ( new RuntimeException ( "Cannot determine ID or path from provided " + obj . getClass ( ) . getSimpleName ( ) + " instance, must be Integer, String, or a Project instance" ) ) ; } }
Returns the project ID or path from the provided Integer String or Project instance .
34,850
public Object getGroupIdOrPath ( Object obj ) throws GitLabApiException { if ( obj == null ) { throw ( new RuntimeException ( "Cannot determine ID or path from null object" ) ) ; } else if ( obj instanceof Integer ) { return ( obj ) ; } else if ( obj instanceof String ) { return ( urlEncode ( ( ( String ) obj ) . trim ( ) ) ) ; } else if ( obj instanceof Group ) { Integer id = ( ( Group ) obj ) . getId ( ) ; if ( id != null && id . intValue ( ) > 0 ) { return ( id ) ; } String path = ( ( Group ) obj ) . getFullPath ( ) ; if ( path != null && path . trim ( ) . length ( ) > 0 ) { return ( urlEncode ( path . trim ( ) ) ) ; } throw ( new RuntimeException ( "Cannot determine ID or path from provided Group instance" ) ) ; } else { throw ( new RuntimeException ( "Cannot determine ID or path from provided " + obj . getClass ( ) . getSimpleName ( ) + " instance, must be Integer, String, or a Group instance" ) ) ; } }
Returns the group ID or path from the provided Integer String or Group instance .
34,851
public Object getUserIdOrUsername ( Object obj ) throws GitLabApiException { if ( obj == null ) { throw ( new RuntimeException ( "Cannot determine ID or username from null object" ) ) ; } else if ( obj instanceof Integer ) { return ( obj ) ; } else if ( obj instanceof String ) { return ( urlEncode ( ( ( String ) obj ) . trim ( ) ) ) ; } else if ( obj instanceof User ) { Integer id = ( ( User ) obj ) . getId ( ) ; if ( id != null && id . intValue ( ) > 0 ) { return ( id ) ; } String username = ( ( User ) obj ) . getUsername ( ) ; if ( username != null && username . trim ( ) . length ( ) > 0 ) { return ( urlEncode ( username . trim ( ) ) ) ; } throw ( new RuntimeException ( "Cannot determine ID or username from provided User instance" ) ) ; } else { throw ( new RuntimeException ( "Cannot determine ID or username from provided " + obj . getClass ( ) . getSimpleName ( ) + " instance, must be Integer, String, or a User instance" ) ) ; } }
Returns the user ID or path from the provided Integer String or User instance .
34,852
protected String urlEncode ( String s ) throws GitLabApiException { try { String encoded = URLEncoder . encode ( s , "UTF-8" ) ; encoded = encoded . replace ( "+" , "%20" ) ; encoded = encoded . replace ( "." , "%2E" ) ; encoded = encoded . replace ( "-" , "%2D" ) ; encoded = encoded . replace ( "_" , "%5F" ) ; return ( encoded ) ; } catch ( Exception e ) { throw new GitLabApiException ( e ) ; } }
Encode a string to be used as in - path argument for a gitlab api request .
34,853
protected Response post ( Response . Status expectedStatus , StreamingOutput stream , String mediaType , Object ... pathArgs ) throws GitLabApiException { try { return validate ( getApiClient ( ) . post ( stream , mediaType , pathArgs ) , expectedStatus ) ; } catch ( Exception e ) { throw handle ( e ) ; } }
Perform an HTTP POST call with the specified payload object and path objects returning a ClientResponse instance with the data returned from the endpoint .
34,854
protected Response upload ( Response . Status expectedStatus , String name , File fileToUpload , String mediaType , URL url ) throws GitLabApiException { try { return validate ( getApiClient ( ) . upload ( name , fileToUpload , mediaType , url ) , expectedStatus ) ; } catch ( Exception e ) { throw handle ( e ) ; } }
Perform a file upload with the specified File instance and path objects returning a ClientResponse instance with the data returned from the endpoint .
34,855
protected Response put ( Response . Status expectedStatus , MultivaluedMap < String , String > queryParams , Object ... pathArgs ) throws GitLabApiException { try { return validate ( getApiClient ( ) . put ( queryParams , pathArgs ) , expectedStatus ) ; } catch ( Exception e ) { throw handle ( e ) ; } }
Perform an HTTP PUT call with the specified form data and path objects returning a ClientResponse instance with the data returned from the endpoint .
34,856
protected Response putUpload ( Response . Status expectedStatus , String name , File fileToUpload , Object ... pathArgs ) throws GitLabApiException { try { return validate ( getApiClient ( ) . putUpload ( name , fileToUpload , pathArgs ) , expectedStatus ) ; } catch ( Exception e ) { throw handle ( e ) ; } }
Perform a file upload using the HTTP PUT method with the specified File instance and path objects returning a ClientResponse instance with the data returned from the endpoint .
34,857
protected Response validate ( Response response , Response . Status expected ) throws GitLabApiException { int responseCode = response . getStatus ( ) ; int expectedResponseCode = expected . getStatusCode ( ) ; if ( responseCode != expectedResponseCode ) { if ( expectedResponseCode > 204 || responseCode > 204 || expectedResponseCode < 200 || responseCode < 200 ) throw new GitLabApiException ( response ) ; } if ( ! getApiClient ( ) . validateSecretToken ( response ) ) { throw new GitLabApiException ( new NotAuthorizedException ( "Invalid secret token in response." ) ) ; } return ( response ) ; }
Validates response the response from the server against the expected HTTP status and the returned secret token if either is not correct will throw a GitLabApiException .
34,858
protected GitLabApiException handle ( Exception thrown ) { if ( thrown instanceof GitLabApiException ) { return ( ( GitLabApiException ) thrown ) ; } return ( new GitLabApiException ( thrown ) ) ; }
Wraps an exception in a GitLabApiException if needed .
34,859
protected MultivaluedMap < String , String > getPerPageQueryParam ( int perPage ) { return ( new GitLabApiForm ( ) . withParam ( PER_PAGE_PARAM , perPage ) . asMap ( ) ) ; }
Creates a MultivaluedMap instance containing the per_page param .
34,860
protected MultivaluedMap < String , String > getDefaultPerPageParam ( boolean customAttributesEnabled ) { GitLabApiForm form = new GitLabApiForm ( ) . withParam ( PER_PAGE_PARAM , getDefaultPerPage ( ) ) ; if ( customAttributesEnabled ) return ( form . withParam ( "with_custom_attributes" , true ) . asMap ( ) ) ; return ( form . asMap ( ) ) ; }
Creates a MultivaluedMap instance containing the per_page param with the default value .
34,861
void enableRequestResponseLogging ( Logger logger , Level level , int maxEntityLength , List < String > maskedHeaderNames ) { MaskingLoggingFilter loggingFilter = new MaskingLoggingFilter ( logger , level , maxEntityLength , maskedHeaderNames ) ; clientConfig . register ( loggingFilter ) ; if ( apiClient != null ) { createApiClient ( ) ; } }
Enable the logging of the requests to and the responses from the GitLab server API .
34,862
protected URL getApiUrl ( Object ... pathArgs ) throws IOException { String url = appendPathArgs ( this . hostUrl , pathArgs ) ; return ( new URL ( url ) ) ; }
Construct a REST URL with the specified path arguments .
34,863
protected URL getUrlWithBase ( Object ... pathArgs ) throws IOException { String url = appendPathArgs ( this . baseUrl , pathArgs ) ; return ( new URL ( url ) ) ; }
Construct a REST URL with the specified path arguments using Gitlab base url .
34,864
protected Response getWithAccepts ( MultivaluedMap < String , String > queryParams , String accepts , Object ... pathArgs ) throws IOException { URL url = getApiUrl ( pathArgs ) ; return ( getWithAccepts ( queryParams , url , accepts ) ) ; }
Perform an HTTP GET call with the specified query parameters and path objects returning a ClientResponse instance with the data returned from the endpoint .
34,865
protected Response head ( MultivaluedMap < String , String > queryParams , Object ... pathArgs ) throws IOException { URL url = getApiUrl ( pathArgs ) ; return ( head ( queryParams , url ) ) ; }
Perform an HTTP HEAD call with the specified query parameters and path objects returning a ClientResponse instance with the data returned from the endpoint .
34,866
protected Response head ( MultivaluedMap < String , String > queryParams , URL url ) { return ( invocation ( url , queryParams ) . head ( ) ) ; }
Perform an HTTP HEAD call with the specified query parameters and URL returning a ClientResponse instance with the data returned from the endpoint .
34,867
protected Response post ( Object payload , Object ... pathArgs ) throws IOException { URL url = getApiUrl ( pathArgs ) ; Entity < ? > entity = Entity . entity ( payload , MediaType . APPLICATION_JSON ) ; return ( invocation ( url , null ) . post ( entity ) ) ; }
Perform an HTTP POST call with the specified payload object and URL returning a ClientResponse instance with the data returned from the endpoint .
34,868
protected Response post ( StreamingOutput stream , String mediaType , Object ... pathArgs ) throws IOException { URL url = getApiUrl ( pathArgs ) ; return ( invocation ( url , null ) . post ( Entity . entity ( stream , mediaType ) ) ) ; }
Perform an HTTP POST call with the specified StreamingOutput MediaType and path objects returning a ClientResponse instance with the data returned from the endpoint .
34,869
protected Response upload ( String name , File fileToUpload , String mediaTypeString , Object ... pathArgs ) throws IOException { URL url = getApiUrl ( pathArgs ) ; return ( upload ( name , fileToUpload , mediaTypeString , null , url ) ) ; }
Perform a file upload using the specified media type returning a ClientResponse instance with the data returned from the endpoint .
34,870
protected Response delete ( MultivaluedMap < String , String > queryParams , Object ... pathArgs ) throws IOException { return ( delete ( queryParams , getApiUrl ( pathArgs ) ) ) ; }
Perform an HTTP DELETE call with the specified form data and path objects returning a Response instance with the data returned from the endpoint .
34,871
protected Response delete ( MultivaluedMap < String , String > queryParams , URL url ) { return ( invocation ( url , queryParams ) . delete ( ) ) ; }
Perform an HTTP DELETE call with the specified form data and URL returning a Response instance with the data returned from the endpoint .
34,872
public void setIgnoreCertificateErrors ( boolean ignoreCertificateErrors ) { if ( this . ignoreCertificateErrors == ignoreCertificateErrors ) { return ; } if ( ! ignoreCertificateErrors ) { this . ignoreCertificateErrors = false ; openSslContext = null ; openHostnameVerifier = null ; apiClient = null ; } else { if ( setupIgnoreCertificateErrors ( ) ) { this . ignoreCertificateErrors = true ; apiClient = null ; } else { this . ignoreCertificateErrors = false ; apiClient = null ; throw new RuntimeException ( "Unable to ignore certificate errors." ) ; } } }
Sets up the Jersey system ignore SSL certificate errors or not .
34,873
private boolean setupIgnoreCertificateErrors ( ) { TrustManager [ ] trustAllCerts = new TrustManager [ ] { new X509ExtendedTrustManager ( ) { public X509Certificate [ ] getAcceptedIssuers ( ) { return null ; } public void checkServerTrusted ( X509Certificate [ ] chain , String authType ) throws CertificateException { } public void checkClientTrusted ( X509Certificate [ ] chain , String authType ) throws CertificateException { } public void checkClientTrusted ( X509Certificate [ ] chain , String authType , Socket socket ) throws CertificateException { } public void checkClientTrusted ( X509Certificate [ ] chain , String authType , SSLEngine engine ) throws CertificateException { } public void checkServerTrusted ( X509Certificate [ ] chain , String authType , Socket socket ) throws CertificateException { } public void checkServerTrusted ( X509Certificate [ ] chain , String authType , SSLEngine engine ) throws CertificateException { } } } ; HostnameVerifier hostnameVerifier = new HostnameVerifier ( ) { public boolean verify ( String hostname , SSLSession session ) { return true ; } } ; try { SSLContext sslContext = SSLContext . getInstance ( "TLS" ) ; sslContext . init ( null , trustAllCerts , new SecureRandom ( ) ) ; openSslContext = sslContext ; openHostnameVerifier = hostnameVerifier ; } catch ( GeneralSecurityException ex ) { openSslContext = null ; openHostnameVerifier = null ; return ( false ) ; } return ( true ) ; }
Sets up Jersey client to ignore certificate errors .
34,874
public List < Job > getJobs ( Object projectIdOrPath , int page , int perPage ) throws GitLabApiException { Response response = get ( Response . Status . OK , getPageQueryParams ( page , perPage ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "jobs" ) ; return ( response . readEntity ( new GenericType < List < Job > > ( ) { } ) ) ; }
Get a list of jobs in a project in the specified page range .
34,875
public Pager < Job > getJobs ( Object projectIdOrPath , int itemsPerPage ) throws GitLabApiException { return ( new Pager < Job > ( this , Job . class , itemsPerPage , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "jobs" ) ) ; }
Get a Pager of jobs in a project .
34,876
public Stream < Job > getJobsStream ( Object projectIdOrPath ) throws GitLabApiException { return ( getJobs ( projectIdOrPath , getDefaultPerPage ( ) ) . stream ( ) ) ; }
Get a Stream of jobs in a project .
34,877
public Job getJob ( Object projectIdOrPath , int jobId ) throws GitLabApiException { Response response = get ( Response . Status . OK , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "jobs" , jobId ) ; return ( response . readEntity ( Job . class ) ) ; }
Get single job in a project .
34,878
public Optional < Job > getOptionalJob ( Object projectIdOrPath , int jobId ) { try { return ( Optional . ofNullable ( getJob ( projectIdOrPath , jobId ) ) ) ; } catch ( GitLabApiException glae ) { return ( GitLabApi . createOptionalFromException ( glae ) ) ; } }
Get single job in a project as an Optional instance .
34,879
public InputStream downloadArtifactsFile ( Object projectIdOrPath , String ref , String jobName ) throws GitLabApiException { Form formData = new GitLabApiForm ( ) . withParam ( "job" , jobName , true ) ; Response response = getWithAccepts ( Response . Status . OK , formData . asMap ( ) , MediaType . MEDIA_TYPE_WILDCARD , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "jobs" , "artifacts" , ref , "download" ) ; return ( response . readEntity ( InputStream . class ) ) ; }
Get an InputStream pointing to the artifacts file from the given reference name and job provided the job finished successfully . The file will be saved to the specified directory . If the file already exists in the directory it will be overwritten .
34,880
public InputStream downloadArtifactsFile ( Object projectIdOrPath , Integer jobId ) throws GitLabApiException { Response response = getWithAccepts ( Response . Status . OK , null , MediaType . MEDIA_TYPE_WILDCARD , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "jobs" , jobId , "artifacts" ) ; return ( response . readEntity ( InputStream . class ) ) ; }
Get an InputStream pointing to the job artifacts file for the specified job ID .
34,881
public String getTrace ( Object projectIdOrPath , int jobId ) throws GitLabApiException { Response response = get ( Response . Status . OK , getDefaultPerPageParam ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "jobs" , jobId , "trace" ) ; return ( response . readEntity ( String . class ) ) ; }
Get a trace of a specific job of a project
34,882
public Job playJob ( Object projectIdOrPath , int jobId ) throws GitLabApiException { GitLabApiForm formData = null ; Response response = post ( Status . CREATED , formData , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "jobs" , jobId , "play" ) ; return ( response . readEntity ( Job . class ) ) ; }
Play specified job in a project .
34,883
public JsonNode readTree ( String postData ) throws JsonParseException , JsonMappingException , IOException { return ( objectMapper . readTree ( postData ) ) ; }
Reads and parses the String containing JSON data and returns a JsonNode tree representation .
34,884
public JsonNode readTree ( Reader reader ) throws JsonParseException , JsonMappingException , IOException { return ( objectMapper . readTree ( reader ) ) ; }
Reads and parses the JSON data on the specified Reader instance to a JsonNode tree representation .
34,885
public < T > T unmarshal ( Class < T > returnType , Reader reader ) throws JsonParseException , JsonMappingException , IOException { ObjectMapper objectMapper = getContext ( returnType ) ; return ( objectMapper . readValue ( reader , returnType ) ) ; }
Unmarshal the JSON data on the specified Reader instance to an instance of the provided class .
34,886
public < T > T unmarshal ( Class < T > returnType , String postData ) throws JsonParseException , JsonMappingException , IOException { ObjectMapper objectMapper = getContext ( returnType ) ; return ( objectMapper . readValue ( postData , returnType ) ) ; }
Unmarshal the JSON data contained by the string and populate an instance of the provided returnType class .
34,887
public < T > List < T > unmarshalList ( Class < T > returnType , Reader reader ) throws JsonParseException , JsonMappingException , IOException { ObjectMapper objectMapper = getContext ( null ) ; CollectionType javaType = objectMapper . getTypeFactory ( ) . constructCollectionType ( List . class , returnType ) ; return ( objectMapper . readValue ( reader , javaType ) ) ; }
Unmarshal the JSON data on the specified Reader instance and populate a List of instances of the provided returnType class .
34,888
public < T > Map < String , T > unmarshalMap ( Class < T > returnType , Reader reader ) throws JsonParseException , JsonMappingException , IOException { ObjectMapper objectMapper = getContext ( null ) ; return ( objectMapper . readValue ( reader , new TypeReference < Map < String , T > > ( ) { } ) ) ; }
Unmarshal the JSON data on the specified Reader instance and populate a Map of String keys and values of the provided returnType class .
34,889
public < T > String marshal ( final T object ) { if ( object == null ) { throw new IllegalArgumentException ( "object parameter is null" ) ; } ObjectWriter writer = objectMapper . writer ( ) . withDefaultPrettyPrinter ( ) ; String results = null ; try { results = writer . writeValueAsString ( object ) ; } catch ( JsonGenerationException e ) { System . err . println ( "JsonGenerationException, message=" + e . getMessage ( ) ) ; } catch ( JsonMappingException e ) { e . printStackTrace ( ) ; System . err . println ( "JsonMappingException, message=" + e . getMessage ( ) ) ; } catch ( IOException e ) { System . err . println ( "IOException, message=" + e . getMessage ( ) ) ; } return ( results ) ; }
Marshals the supplied object out as a formatted JSON string .
34,890
public static JsonNode toJsonNode ( String jsonString ) throws IOException { return ( JacksonJsonSingletonHelper . JACKSON_JSON . objectMapper . readTree ( jsonString ) ) ; }
Parse the provided String into a JsonNode instance .
34,891
public List < LicenseTemplate > getAllLicenseTemplates ( ) throws GitLabApiException { Response response = get ( Response . Status . OK , null , "licenses" ) ; return ( response . readEntity ( new GenericType < List < LicenseTemplate > > ( ) { } ) ) ; }
Get all license templates .
34,892
public List < LicenseTemplate > getPopularLicenseTemplates ( ) throws GitLabApiException { Form formData = new GitLabApiForm ( ) . withParam ( "popular" , true , true ) ; Response response = get ( Response . Status . OK , formData . asMap ( ) , "licenses" ) ; return ( response . readEntity ( new GenericType < List < LicenseTemplate > > ( ) { } ) ) ; }
Get popular license templates .
34,893
public LicenseTemplate getSingleLicenseTemplate ( String key ) throws GitLabApiException { Response response = get ( Response . Status . OK , null , "licenses" , key ) ; return ( response . readEntity ( LicenseTemplate . class ) ) ; }
Get a single license template .
34,894
public HealthCheckInfo getLiveness ( String token ) throws GitLabApiException { try { URL livenessUrl = getApiClient ( ) . getUrlWithBase ( "-" , "liveness" ) ; GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "token" , token , false ) ; Response response = get ( Response . Status . OK , formData . asMap ( ) , livenessUrl ) ; return ( response . readEntity ( HealthCheckInfo . class ) ) ; } catch ( IOException ioe ) { throw ( new GitLabApiException ( ioe ) ) ; } }
Get Health Checks from the liveness endpoint .
34,895
public void setGitLabCI ( Object projectIdOrPath , String token , String projectCIUrl ) throws GitLabApiException { final Form formData = new Form ( ) ; formData . param ( "token" , token ) ; formData . param ( "project_url" , projectCIUrl ) ; put ( Response . Status . OK , formData . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "services" , "gitlab-ci" ) ; }
Activates the gitlab - ci service for a project .
34,896
public void deleteGitLabCI ( Object projectIdOrPath ) throws GitLabApiException { Response . Status expectedStatus = ( isApiVersion ( ApiVersion . V3 ) ? Response . Status . OK : Response . Status . NO_CONTENT ) ; delete ( expectedStatus , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "services" , "gitlab-ci" ) ; }
Deletes the gitlab - ci service for a project .
34,897
public HipChatService getHipChatService ( Object projectIdOrPath ) throws GitLabApiException { Response response = get ( Response . Status . OK , null , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "services" , "hipchat" ) ; return ( response . readEntity ( HipChatService . class ) ) ; }
Get the HipChatService notification configuration for a project .
34,898
public HipChatService updateHipChatService ( Object projectIdOrPath , HipChatService hipChat ) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "push_events" , hipChat . getPushEvents ( ) ) . withParam ( "issues_events" , hipChat . getIssuesEvents ( ) ) . withParam ( "confidential_issues_events" , hipChat . getConfidentialIssuesEvents ( ) ) . withParam ( "merge_requests_events" , hipChat . getMergeRequestsEvents ( ) ) . withParam ( "tag_push_events" , hipChat . getTagPushEvents ( ) ) . withParam ( "note_events" , hipChat . getNoteEvents ( ) ) . withParam ( "confidential_note_events" , hipChat . getConfidentialNoteEvents ( ) ) . withParam ( "pipeline_events" , hipChat . getPipelineEvents ( ) ) . withParam ( "token" , hipChat . getToken ( ) , true ) . withParam ( "color" , hipChat . getColor ( ) ) . withParam ( "notify" , hipChat . getNotify ( ) ) . withParam ( "room" , hipChat . getRoom ( ) ) . withParam ( "api_version" , hipChat . getApiVersion ( ) ) . withParam ( "server" , hipChat . getServer ( ) ) . withParam ( "notify_only_broken_pipelines" , hipChat . getNotifyOnlyBrokenPipelines ( ) ) ; Response response = put ( Response . Status . OK , formData . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "services" , "hipchat" ) ; return ( response . readEntity ( HipChatService . class ) ) ; }
Updates the HipChatService notification settings for a project .
34,899
public void setHipChat ( Object projectIdOrPath , String token , String room , String server ) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "token" , token ) . withParam ( "room" , room ) . withParam ( "server" , server ) ; put ( Response . Status . OK , formData . asMap ( ) , "projects" , getProjectIdOrPath ( projectIdOrPath ) , "services" , "hipchat" ) ; }
Activates HipChatService notifications .