15
15
import org .gitlab4j .api .models .ApprovalRuleParams ;
16
16
import org .gitlab4j .api .models .ApprovalState ;
17
17
import org .gitlab4j .api .models .Commit ;
18
+ import org .gitlab4j .api .models .Diff ;
18
19
import org .gitlab4j .api .models .Issue ;
19
20
import org .gitlab4j .api .models .MergeRequest ;
20
21
import org .gitlab4j .api .models .MergeRequestDiff ;
21
22
import org .gitlab4j .api .models .MergeRequestFilter ;
22
23
import org .gitlab4j .api .models .MergeRequestParams ;
24
+ import org .gitlab4j .api .models .MergeRequestVersion ;
23
25
import org .gitlab4j .api .models .Participant ;
24
26
import org .gitlab4j .api .models .Pipeline ;
25
27
@@ -400,7 +402,9 @@ public Stream<Commit> getCommitsStream(Object projectIdOrPath, Long mergeRequest
400
402
* @param mergeRequestIid the internal ID of the merge request
401
403
* @return a List of merge request diff versions for the specified merge request
402
404
* @throws GitLabApiException if any exception occurs
405
+ * @deprecated use {@link #getDiffVersions(Object, Long)} instead
403
406
*/
407
+ @ Deprecated
404
408
public List <MergeRequestDiff > getMergeRequestDiffs (Object projectIdOrPath , Long mergeRequestIid ) throws GitLabApiException {
405
409
return (getMergeRequestDiffs (projectIdOrPath , mergeRequestIid , getDefaultPerPage ()).all ());
406
410
}
@@ -415,7 +419,9 @@ public List<MergeRequestDiff> getMergeRequestDiffs(Object projectIdOrPath, Long
415
419
* @param itemsPerPage the number of MergeRequest instances that will be fetched per page
416
420
* @return a Pager of merge request diff versions for the specified merge request
417
421
* @throws GitLabApiException if any exception occurs
422
+ * @deprecated use {@link #getDiffVersions(Object, Long, int)} instead
418
423
*/
424
+ @ Deprecated
419
425
public Pager <MergeRequestDiff > getMergeRequestDiffs (Object projectIdOrPath , Long mergeRequestIid , int itemsPerPage ) throws GitLabApiException {
420
426
return (new Pager <MergeRequestDiff >(this , MergeRequestDiff .class , itemsPerPage , null ,
421
427
"projects" , getProjectIdOrPath (projectIdOrPath ), "merge_requests" , mergeRequestIid , "versions" ));
@@ -430,7 +436,9 @@ public Pager<MergeRequestDiff> getMergeRequestDiffs(Object projectIdOrPath, Long
430
436
* @param mergeRequestIid the internal ID of the merge request
431
437
* @return a Stream of merge request diff versions for the specified merge request
432
438
* @throws GitLabApiException if any exception occurs
439
+ * @deprecated use {@link #getDiffVersionsStream(Object, Long)} instead
433
440
*/
441
+ @ Deprecated
434
442
public Stream <MergeRequestDiff > getMergeRequestDiffsStream (Object projectIdOrPath , Long mergeRequestIid ) throws GitLabApiException {
435
443
return (getMergeRequestDiffs (projectIdOrPath , mergeRequestIid , getDefaultPerPage ()).stream ());
436
444
}
@@ -445,12 +453,12 @@ public Stream<MergeRequestDiff> getMergeRequestDiffsStream(Object projectIdOrPat
445
453
* @param versionId the ID of the merge request diff version
446
454
* @return a MergeRequestDiff instance for the specified MR diff version
447
455
* @throws GitLabApiException if any exception occurs
456
+ * @deprecated use {@link #getDiffVersion(Object, Long, Long)} instead
448
457
*/
458
+ @ Deprecated
449
459
public MergeRequestDiff getMergeRequestDiff (Object projectIdOrPath ,
450
460
Long mergeRequestIid , Long versionId ) throws GitLabApiException {
451
- Response response = get (Response .Status .OK , null , "projects" , getProjectIdOrPath (projectIdOrPath ),
452
- "merge_requests" , mergeRequestIid , "versions" , versionId );
453
- return (response .readEntity (MergeRequestDiff .class ));
461
+ return getDiffVersion (projectIdOrPath , mergeRequestIid , versionId );
454
462
}
455
463
456
464
/**
@@ -462,7 +470,9 @@ public MergeRequestDiff getMergeRequestDiff(Object projectIdOrPath,
462
470
* @param mergeRequestIid the internal ID of the merge request
463
471
* @param versionId the ID of the merge request diff version
464
472
* @return the specified MergeRequestDiff as an Optional instance instance
473
+ * @deprecated use {@link #getOptionalDiffVersion(Object, Long, Long)} instead
465
474
*/
475
+ @ Deprecated
466
476
public Optional <MergeRequestDiff > getOptionalMergeRequestDiff (
467
477
Object projectIdOrPath , Long mergeRequestIid , Long versionId ) {
468
478
try {
@@ -472,6 +482,129 @@ public Optional<MergeRequestDiff> getOptionalMergeRequestDiff(
472
482
}
473
483
}
474
484
485
+ /**
486
+ * Get a list of merge request diff versions.
487
+ *
488
+ * <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/versions</code></pre>
489
+ *
490
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
491
+ * @param mergeRequestIid the internal ID of the merge request
492
+ * @return a List of merge request diff versions for the specified merge request
493
+ * @throws GitLabApiException if any exception occurs
494
+ */
495
+ public List <MergeRequestVersion > getDiffVersions (Object projectIdOrPath , Long mergeRequestIid ) throws GitLabApiException {
496
+ return (getDiffVersions (projectIdOrPath , mergeRequestIid , getDefaultPerPage ()).all ());
497
+ }
498
+
499
+ /**
500
+ * Get a Pager of merge request diff versions.
501
+ *
502
+ * <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/versions</code></pre>
503
+ *
504
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
505
+ * @param mergeRequestIid the internal ID of the merge request
506
+ * @param itemsPerPage the number of MergeRequest instances that will be fetched per page
507
+ * @return a Pager of merge request diff versions for the specified merge request
508
+ * @throws GitLabApiException if any exception occurs
509
+ */
510
+ public Pager <MergeRequestVersion > getDiffVersions (Object projectIdOrPath , Long mergeRequestIid , int itemsPerPage ) throws GitLabApiException {
511
+ return (new Pager <MergeRequestVersion >(this , MergeRequestVersion .class , itemsPerPage , null ,
512
+ "projects" , getProjectIdOrPath (projectIdOrPath ), "merge_requests" , mergeRequestIid , "versions" ));
513
+ }
514
+
515
+ /**
516
+ * Get a Stream of merge request diff versions.
517
+ *
518
+ * <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/versions</code></pre>
519
+ *
520
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
521
+ * @param mergeRequestIid the internal ID of the merge request
522
+ * @return a Stream of merge request diff versions for the specified merge request
523
+ * @throws GitLabApiException if any exception occurs
524
+ */
525
+ public Stream <MergeRequestVersion > getDiffVersionsStream (Object projectIdOrPath , Long mergeRequestIid ) throws GitLabApiException {
526
+ return (getDiffVersions (projectIdOrPath , mergeRequestIid , getDefaultPerPage ()).stream ());
527
+ }
528
+
529
+ /**
530
+ * Get a single merge request diff version.
531
+ *
532
+ * <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/versions/:version_id</code></pre>
533
+ *
534
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
535
+ * @param mergeRequestIid the internal ID of the merge request
536
+ * @param versionId the ID of the merge request diff version
537
+ * @return a MergeRequestVersion instance for the specified MR diff version
538
+ * @throws GitLabApiException if any exception occurs
539
+ */
540
+ public MergeRequestDiff getDiffVersion (Object projectIdOrPath , Long mergeRequestIid , Long versionId ) throws GitLabApiException {
541
+ Response response = get (Response .Status .OK , null , "projects" , getProjectIdOrPath (projectIdOrPath ),
542
+ "merge_requests" , mergeRequestIid , "versions" , versionId );
543
+ return (response .readEntity (MergeRequestDiff .class ));
544
+ }
545
+
546
+ /**
547
+ * Get a single merge request diff version as an Optional instance.
548
+ *
549
+ * <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/versions/:version_id</code></pre>
550
+ *
551
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
552
+ * @param mergeRequestIid the internal ID of the merge request
553
+ * @param versionId the ID of the merge request diff version
554
+ * @return the specified MergeRequestVersion as an Optional instance instance
555
+ */
556
+ public Optional <MergeRequestDiff > getOptionalDiffVersion (Object projectIdOrPath , Long mergeRequestIid , Long versionId ) {
557
+ try {
558
+ return (Optional .ofNullable (getDiffVersion (projectIdOrPath , mergeRequestIid , versionId )));
559
+ } catch (GitLabApiException glae ) {
560
+ return (GitLabApi .createOptionalFromException (glae ));
561
+ }
562
+ }
563
+
564
+ /**
565
+ * Get a list of merge request diffs.
566
+ *
567
+ * <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/diffs</code></pre>
568
+ *
569
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
570
+ * @param mergeRequestIid the internal ID of the merge request
571
+ * @return a List of merge request diffs for the specified merge request
572
+ * @throws GitLabApiException if any exception occurs
573
+ */
574
+ public List <Diff > getDiffs (Object projectIdOrPath , Long mergeRequestIid ) throws GitLabApiException {
575
+ return (getDiffs (projectIdOrPath , mergeRequestIid , getDefaultPerPage ()).all ());
576
+ }
577
+
578
+ /**
579
+ * Get a Pager of merge request diffs.
580
+ *
581
+ * <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/diffs</code></pre>
582
+ *
583
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
584
+ * @param mergeRequestIid the internal ID of the merge request
585
+ * @param itemsPerPage the number of Diff instances that will be fetched per page
586
+ * @return a Pager of merge request diffs for the specified merge request
587
+ * @throws GitLabApiException if any exception occurs
588
+ */
589
+ public Pager <Diff > getDiffs (Object projectIdOrPath , Long mergeRequestIid , int itemsPerPage ) throws GitLabApiException {
590
+ return (new Pager <>(this , Diff .class , itemsPerPage , null ,
591
+ "projects" , getProjectIdOrPath (projectIdOrPath ), "merge_requests" , mergeRequestIid , "diffs" ));
592
+ }
593
+
594
+ /**
595
+ * Get a Stream of merge request diffs.
596
+ *
597
+ * <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/diffs</code></pre>
598
+ *
599
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
600
+ * @param mergeRequestIid the internal ID of the merge request
601
+ * @return a Stream of merge request diffs for the specified merge request
602
+ * @throws GitLabApiException if any exception occurs
603
+ */
604
+ public Stream <Diff > getDiffsStream (Object projectIdOrPath , Long mergeRequestIid ) throws GitLabApiException {
605
+ return (getDiffs (projectIdOrPath , mergeRequestIid , getDefaultPerPage ()).stream ());
606
+ }
607
+
475
608
/**
476
609
* Creates a merge request.
477
610
*
0 commit comments