From 6e5e2e689f2929b037cf6b1996282084e6d0f919 Mon Sep 17 00:00:00 2001 From: Jeremie Bresson Date: Sun, 13 Oct 2024 11:08:28 +0200 Subject: [PATCH] Apply and enforce code formatter --- build.gradle | 9 + .../java/org/gitlab4j/api/AbstractApi.java | 133 +- .../gitlab4j/api/ApplicationSettingsApi.java | 74 +- .../org/gitlab4j/api/ApplicationsApi.java | 8 +- .../java/org/gitlab4j/api/AuditEventApi.java | 13 +- .../java/org/gitlab4j/api/AwardEmojiApi.java | 298 +- src/main/java/org/gitlab4j/api/BoardsApi.java | 114 +- .../java/org/gitlab4j/api/CommitsApi.java | 347 +- src/main/java/org/gitlab4j/api/Constants.java | 2405 +++++---- .../gitlab4j/api/ContainerRegistryApi.java | 112 +- .../java/org/gitlab4j/api/DeployKeysApi.java | 55 +- .../org/gitlab4j/api/DeployTokensApi.java | 67 +- .../java/org/gitlab4j/api/DeploymentsApi.java | 74 +- .../java/org/gitlab4j/api/DiscussionsApi.java | 508 +- .../org/gitlab4j/api/EnvironmentsApi.java | 107 +- src/main/java/org/gitlab4j/api/EpicsApi.java | 319 +- src/main/java/org/gitlab4j/api/EventsApi.java | 227 +- .../gitlab4j/api/ExternalStatusCheckApi.java | 134 +- src/main/java/org/gitlab4j/api/GitLabApi.java | 163 +- .../org/gitlab4j/api/GitLabApiClient.java | 139 +- .../org/gitlab4j/api/GitLabApiException.java | 27 +- .../java/org/gitlab4j/api/GitLabApiForm.java | 439 +- .../org/gitlab4j/api/GitLabCiYamlApi.java | 2 +- src/main/java/org/gitlab4j/api/GroupApi.java | 585 ++- .../java/org/gitlab4j/api/HealthCheckApi.java | 7 +- .../java/org/gitlab4j/api/HookManager.java | 131 +- .../org/gitlab4j/api/ImportExportApi.java | 86 +- src/main/java/org/gitlab4j/api/IssuesApi.java | 390 +- src/main/java/org/gitlab4j/api/JobApi.java | 260 +- src/main/java/org/gitlab4j/api/KeysApi.java | 5 +- src/main/java/org/gitlab4j/api/LabelsApi.java | 153 +- .../java/org/gitlab4j/api/LicenseApi.java | 4 +- .../org/gitlab4j/api/LicenseTemplatesApi.java | 5 +- .../java/org/gitlab4j/api/MarkdownApi.java | 6 +- .../org/gitlab4j/api/MergeRequestApi.java | 730 ++- .../java/org/gitlab4j/api/MetadataApi.java | 2 +- .../java/org/gitlab4j/api/MilestonesApi.java | 245 +- .../java/org/gitlab4j/api/NamespaceApi.java | 8 +- src/main/java/org/gitlab4j/api/NotesApi.java | 207 +- .../gitlab4j/api/NotificationSettingsApi.java | 96 +- .../java/org/gitlab4j/api/PackagesApi.java | 67 +- src/main/java/org/gitlab4j/api/Pager.java | 846 +-- .../org/gitlab4j/api/PagerSpliterator.java | 90 +- .../gitlab4j/api/PersonalAccessTokenApi.java | 12 +- .../java/org/gitlab4j/api/PipelineApi.java | 419 +- .../java/org/gitlab4j/api/ProjectApi.java | 1357 +++-- .../java/org/gitlab4j/api/ProjectLicense.java | 114 +- .../gitlab4j/api/ProtectedBranchesApi.java | 210 +- .../org/gitlab4j/api/ProxyClientConfig.java | 155 +- .../org/gitlab4j/api/ReleaseLinksApi.java | 68 +- .../java/org/gitlab4j/api/ReleasesApi.java | 43 +- .../java/org/gitlab4j/api/RepositoryApi.java | 346 +- .../org/gitlab4j/api/RepositoryFileApi.java | 157 +- .../gitlab4j/api/RepositorySubmodulesApi.java | 15 +- .../gitlab4j/api/ResourceLabelEventsApi.java | 118 +- .../gitlab4j/api/ResourceStateEventsApi.java | 22 +- .../java/org/gitlab4j/api/RunnersApi.java | 63 +- src/main/java/org/gitlab4j/api/SearchApi.java | 227 +- .../java/org/gitlab4j/api/ServicesApi.java | 174 +- .../java/org/gitlab4j/api/SnippetsApi.java | 6 +- .../java/org/gitlab4j/api/SystemHooksApi.java | 15 +- src/main/java/org/gitlab4j/api/TagsApi.java | 177 +- src/main/java/org/gitlab4j/api/TodosApi.java | 27 +- src/main/java/org/gitlab4j/api/TopicsApi.java | 31 +- src/main/java/org/gitlab4j/api/UserApi.java | 116 +- src/main/java/org/gitlab4j/api/WikisApi.java | 52 +- .../org/gitlab4j/api/models/AbstractEpic.java | 56 +- .../gitlab4j/api/models/AbstractGroup.java | 18 +- .../gitlab4j/api/models/AbstractIssue.java | 40 +- .../api/models/AbstractMinimalEpic.java | 4 +- .../org/gitlab4j/api/models/AbstractUser.java | 23 +- .../api/models/AcceptMergeRequestParams.java | 194 +- .../org/gitlab4j/api/models/AccessLevel.java | 111 +- .../gitlab4j/api/models/AccessRequest.java | 52 +- .../org/gitlab4j/api/models/AllowedTo.java | 99 +- .../org/gitlab4j/api/models/Application.java | 88 +- .../api/models/ApplicationSettings.java | 320 +- .../org/gitlab4j/api/models/ApprovalRule.java | 230 +- .../api/models/ApprovalRuleParams.java | 238 +- .../gitlab4j/api/models/ApprovalState.java | 68 +- .../org/gitlab4j/api/models/ApprovedBy.java | 8 +- .../org/gitlab4j/api/models/Artifact.java | 12 +- .../gitlab4j/api/models/ArtifactsFile.java | 4 +- .../java/org/gitlab4j/api/models/Assets.java | 261 +- .../org/gitlab4j/api/models/Assignee.java | 1 - .../org/gitlab4j/api/models/AuditEvent.java | 5 +- .../gitlab4j/api/models/AuditEventDetail.java | 5 +- .../java/org/gitlab4j/api/models/Author.java | 1 - .../org/gitlab4j/api/models/AwardEmoji.java | 18 +- .../java/org/gitlab4j/api/models/Badge.java | 10 +- .../java/org/gitlab4j/api/models/Blame.java | 68 +- .../java/org/gitlab4j/api/models/Board.java | 122 +- .../org/gitlab4j/api/models/BoardList.java | 4 +- .../java/org/gitlab4j/api/models/Branch.java | 6 +- .../api/models/BranchAccessLevel.java | 4 +- .../java/org/gitlab4j/api/models/Bridge.java | 5 +- .../gitlab4j/api/models/ChangelogPayload.java | 7 +- .../java/org/gitlab4j/api/models/Changes.java | 199 +- .../java/org/gitlab4j/api/models/Comment.java | 6 +- .../java/org/gitlab4j/api/models/Commit.java | 9 +- .../org/gitlab4j/api/models/CommitAction.java | 328 +- .../gitlab4j/api/models/CommitPayload.java | 358 +- .../org/gitlab4j/api/models/CommitRef.java | 39 +- .../org/gitlab4j/api/models/CommitStats.java | 84 +- .../org/gitlab4j/api/models/CommitStatus.java | 5 +- .../api/models/CommitStatusFilter.java | 18 +- .../gitlab4j/api/models/CompareResults.java | 8 +- .../org/gitlab4j/api/models/Contributor.java | 2 +- .../gitlab4j/api/models/CustomAttribute.java | 1 - .../org/gitlab4j/api/models/DeployKey.java | 5 +- .../org/gitlab4j/api/models/DeployToken.java | 6 +- .../org/gitlab4j/api/models/Deployable.java | 360 +- .../org/gitlab4j/api/models/Deployment.java | 214 +- .../gitlab4j/api/models/DeploymentFilter.java | 197 +- .../gitlab4j/api/models/DetailedStatus.java | 198 +- .../java/org/gitlab4j/api/models/Diff.java | 8 +- .../java/org/gitlab4j/api/models/DiffRef.java | 7 +- .../org/gitlab4j/api/models/Discussion.java | 4 +- .../api/models/DownstreamPipeline.java | 4 +- .../org/gitlab4j/api/models/Duration.java | 133 +- .../java/org/gitlab4j/api/models/Email.java | 52 +- .../org/gitlab4j/api/models/Environment.java | 207 +- .../java/org/gitlab4j/api/models/Epic.java | 4 +- .../org/gitlab4j/api/models/EpicFilter.java | 51 +- .../org/gitlab4j/api/models/EpicIssue.java | 13 +- .../gitlab4j/api/models/EpicIssueLink.java | 5 +- .../java/org/gitlab4j/api/models/Event.java | 7 +- .../org/gitlab4j/api/models/EventData.java | 6 +- .../java/org/gitlab4j/api/models/Exists.java | 8 +- .../org/gitlab4j/api/models/ExportStatus.java | 294 +- .../api/models/ExternalStatusCheck.java | 4 +- .../ExternalStatusCheckProtectedBranch.java | 3 - .../api/models/ExternalStatusCheckResult.java | 4 +- .../api/models/ExternalStatusCheckStatus.java | 8 +- .../org/gitlab4j/api/models/FileUpload.java | 84 +- .../gitlab4j/api/models/GitLabCiTemplate.java | 4 +- .../api/models/GitLabCiTemplateElement.java | 4 +- .../java/org/gitlab4j/api/models/GpgKey.java | 4 +- .../org/gitlab4j/api/models/GpgSignature.java | 138 +- .../java/org/gitlab4j/api/models/Group.java | 12 +- .../org/gitlab4j/api/models/GroupFilter.java | 32 +- .../org/gitlab4j/api/models/GroupParams.java | 402 +- .../api/models/GroupProjectsFilter.java | 33 +- .../gitlab4j/api/models/HealthCheckInfo.java | 30 +- .../api/models/HealthCheckStatus.java | 9 +- .../org/gitlab4j/api/models/Identity.java | 84 +- .../api/models/ImpersonationToken.java | 292 +- .../org/gitlab4j/api/models/ImportStatus.java | 255 +- .../java/org/gitlab4j/api/models/Issue.java | 1 - .../org/gitlab4j/api/models/IssueEvent.java | 193 +- .../org/gitlab4j/api/models/IssueFilter.java | 73 +- .../org/gitlab4j/api/models/IssueLink.java | 84 +- .../gitlab4j/api/models/IssuesStatistics.java | 156 +- .../api/models/IssuesStatisticsFilter.java | 248 +- .../org/gitlab4j/api/models/Iteration.java | 66 +- .../gitlab4j/api/models/IterationFilter.java | 19 +- .../java/org/gitlab4j/api/models/Job.java | 6 +- .../org/gitlab4j/api/models/JobAttribute.java | 46 +- .../gitlab4j/api/models/JobAttributes.java | 35 +- .../org/gitlab4j/api/models/JobStatus.java | 10 +- .../java/org/gitlab4j/api/models/Key.java | 5 +- .../java/org/gitlab4j/api/models/Label.java | 37 +- .../org/gitlab4j/api/models/LabelEvent.java | 212 +- .../gitlab4j/api/models/LdapGroupLink.java | 9 +- .../java/org/gitlab4j/api/models/License.java | 250 +- .../java/org/gitlab4j/api/models/Link.java | 7 +- .../org/gitlab4j/api/models/Markdown.java | 4 +- .../java/org/gitlab4j/api/models/Member.java | 5 +- .../org/gitlab4j/api/models/Membership.java | 4 +- .../api/models/MembershipSourceType.java | 4 +- .../org/gitlab4j/api/models/MergeRequest.java | 11 +- .../api/models/MergeRequestFilter.java | 31 +- .../api/models/MergeRequestParams.java | 511 +- .../org/gitlab4j/api/models/Metadata.java | 10 +- .../org/gitlab4j/api/models/Milestone.java | 10 +- .../org/gitlab4j/api/models/Namespace.java | 4 +- .../java/org/gitlab4j/api/models/Note.java | 46 +- .../api/models/NotificationSettings.java | 15 +- .../java/org/gitlab4j/api/models/Package.java | 4 +- .../org/gitlab4j/api/models/PackageFile.java | 219 +- .../gitlab4j/api/models/PackageFilter.java | 21 +- .../org/gitlab4j/api/models/PackageType.java | 63 +- .../org/gitlab4j/api/models/Permissions.java | 66 +- .../api/models/PersonalAccessToken.java | 10 +- .../org/gitlab4j/api/models/Pipeline.java | 3 +- .../gitlab4j/api/models/PipelineFilter.java | 380 +- .../gitlab4j/api/models/PipelineSchedule.java | 1 - .../gitlab4j/api/models/PipelineStatus.java | 91 +- .../org/gitlab4j/api/models/Position.java | 16 +- .../java/org/gitlab4j/api/models/Project.java | 25 +- .../gitlab4j/api/models/ProjectAccess.java | 66 +- .../api/models/ProjectAccessToken.java | 8 +- .../api/models/ProjectApprovalsConfig.java | 256 +- .../gitlab4j/api/models/ProjectFetches.java | 153 +- .../gitlab4j/api/models/ProjectFilter.java | 71 +- .../api/models/ProjectGroupsFilter.java | 11 +- .../org/gitlab4j/api/models/ProjectHook.java | 5 +- .../api/models/ProjectSharedGroup.java | 15 +- .../api/models/ProjectStatistics.java | 3 +- .../gitlab4j/api/models/ProtectedBranch.java | 1 - .../org/gitlab4j/api/models/ProtectedTag.java | 4 +- .../org/gitlab4j/api/models/PushData.java | 3 +- .../org/gitlab4j/api/models/PushRules.java | 403 +- .../org/gitlab4j/api/models/References.java | 7 +- .../api/models/RegistryRepository.java | 4 +- .../api/models/RegistryRepositoryTag.java | 5 +- .../org/gitlab4j/api/models/RelatedEpic.java | 4 +- .../java/org/gitlab4j/api/models/Release.java | 314 +- .../api/models/ReleaseLinkParams.java | 3 - .../gitlab4j/api/models/ReleaseParams.java | 230 +- .../org/gitlab4j/api/models/RemoteMirror.java | 4 +- .../org/gitlab4j/api/models/Repository.java | 4 +- .../api/models/RepositoryArchiveParams.java | 6 +- .../gitlab4j/api/models/RepositoryFile.java | 8 +- .../java/org/gitlab4j/api/models/Runner.java | 24 +- .../org/gitlab4j/api/models/RunnerDetail.java | 13 +- .../gitlab4j/api/models/SamlGroupLink.java | 7 +- .../org/gitlab4j/api/models/SearchBlob.java | 4 +- .../java/org/gitlab4j/api/models/Setting.java | 4522 ++++++++--------- .../org/gitlab4j/api/models/SharedGroup.java | 8 +- .../java/org/gitlab4j/api/models/Snippet.java | 7 +- .../java/org/gitlab4j/api/models/SshKey.java | 147 +- .../org/gitlab4j/api/models/SystemHook.java | 4 +- .../java/org/gitlab4j/api/models/Tag.java | 4 +- .../api/models/TaskCompletionStatus.java | 5 +- .../org/gitlab4j/api/models/TimeStats.java | 4 +- .../java/org/gitlab4j/api/models/Todo.java | 22 +- .../java/org/gitlab4j/api/models/Topic.java | 4 +- .../org/gitlab4j/api/models/TopicParams.java | 12 +- .../org/gitlab4j/api/models/TreeItem.java | 8 +- .../java/org/gitlab4j/api/models/Trigger.java | 144 +- .../java/org/gitlab4j/api/models/User.java | 6 +- .../org/gitlab4j/api/models/Variable.java | 23 +- .../java/org/gitlab4j/api/models/Version.java | 4 +- .../org/gitlab4j/api/models/Visibility.java | 103 +- .../gitlab4j/api/models/WikiAttachment.java | 159 +- .../org/gitlab4j/api/models/WikiPage.java | 7 +- .../api/services/BugzillaService.java | 12 +- .../services/CustomIssueTrackerService.java | 12 +- .../api/services/EmailOnPushService.java | 104 +- .../api/services/ExternalWikiService.java | 4 +- .../gitlab4j/api/services/HipChatService.java | 348 +- .../gitlab4j/api/services/JiraService.java | 328 +- .../api/services/MattermostService.java | 560 +- .../api/services/NotificationService.java | 619 +-- .../gitlab4j/api/services/SlackService.java | 624 +-- .../GroupMemberSystemHookEvent.java | 2 +- .../api/systemhooks/GroupSystemHookEvent.java | 2 +- .../api/systemhooks/KeySystemHookEvent.java | 2 +- .../MergeRequestSystemHookEvent.java | 2 +- .../systemhooks/ProjectSystemHookEvent.java | 2 +- .../api/systemhooks/RepositoryChange.java | 78 +- .../RepositorySystemHookEvent.java | 202 +- .../api/systemhooks/SystemHookEvent.java | 64 +- .../api/systemhooks/SystemHookListener.java | 167 +- .../api/systemhooks/SystemHookManager.java | 624 +-- .../TeamMemberSystemHookEvent.java | 4 +- .../api/systemhooks/UserSystemHookEvent.java | 2 +- .../gitlab4j/api/utils/AccessTokenUtils.java | 1584 +++--- .../org/gitlab4j/api/utils/DurationUtils.java | 374 +- .../org/gitlab4j/api/utils/EmailChecker.java | 53 +- .../org/gitlab4j/api/utils/FileUtils.java | 251 +- .../gitlab4j/api/utils/HttpRequestUtils.java | 341 +- .../java/org/gitlab4j/api/utils/ISO8601.java | 59 +- .../org/gitlab4j/api/utils/JacksonJson.java | 44 +- .../api/utils/JacksonJsonEnumHelper.java | 197 +- .../api/utils/MaskingLoggingFilter.java | 741 +-- .../api/utils/Oauth2LoginStreamingOutput.java | 156 +- .../org/gitlab4j/api/utils/SecretString.java | 128 +- .../org/gitlab4j/api/utils/UrlEncoder.java | 62 +- .../gitlab4j/api/webhook/AbstractEvent.java | 2 +- .../api/webhook/AbstractPushEvent.java | 405 +- .../org/gitlab4j/api/webhook/BuildCommit.java | 208 +- .../org/gitlab4j/api/webhook/BuildEvent.java | 514 +- .../gitlab4j/api/webhook/ChangeContainer.java | 60 +- .../gitlab4j/api/webhook/DeploymentEvent.java | 2 +- .../java/org/gitlab4j/api/webhook/Event.java | 5 +- .../gitlab4j/api/webhook/EventChanges.java | 5 +- .../org/gitlab4j/api/webhook/EventCommit.java | 176 +- .../org/gitlab4j/api/webhook/EventIssue.java | 306 +- .../org/gitlab4j/api/webhook/EventLabel.java | 4 +- .../api/webhook/EventMergeRequest.java | 1092 ++-- .../gitlab4j/api/webhook/EventProject.java | 314 +- .../api/webhook/EventReleaseAssets.java | 4 +- .../gitlab4j/api/webhook/EventRepository.java | 152 +- .../gitlab4j/api/webhook/EventSnippet.java | 228 +- .../org/gitlab4j/api/webhook/IssueEvent.java | 207 +- .../org/gitlab4j/api/webhook/JobEvent.java | 465 +- .../api/webhook/MergeRequestChanges.java | 1 - .../api/webhook/MergeRequestEvent.java | 209 +- .../org/gitlab4j/api/webhook/NoteEvent.java | 571 +-- .../gitlab4j/api/webhook/PipelineEvent.java | 394 +- .../org/gitlab4j/api/webhook/PushEvent.java | 1 - .../gitlab4j/api/webhook/ReleaseEvent.java | 2 +- .../gitlab4j/api/webhook/TagPushEvent.java | 1 - .../gitlab4j/api/webhook/WebHookListener.java | 185 +- .../gitlab4j/api/webhook/WebHookManager.java | 669 ++- .../gitlab4j/api/webhook/WikiPageEvent.java | 356 +- .../gitlab4j/api/AbstractIntegrationTest.java | 5 +- .../java/org/gitlab4j/api/HelperUtils.java | 3 +- src/test/java/org/gitlab4j/api/JsonUtils.java | 478 +- .../java/org/gitlab4j/api/MockResponse.java | 472 +- .../gitlab4j/api/MockServletInputStream.java | 134 +- .../gitlab4j/api/PagerSpliteratorTest.java | 130 +- .../org/gitlab4j/api/PropertyConstants.java | 68 +- .../api/SetupIntegrationTestExtension.java | 636 +-- .../org/gitlab4j/api/TestAccessToken.java | 11 +- .../gitlab4j/api/TestAccessTokenUtils.java | 36 +- .../api/TestApplicationSettingsApi.java | 33 +- .../org/gitlab4j/api/TestApplicationsApi.java | 23 +- .../org/gitlab4j/api/TestAvatarUpload.java | 9 +- .../api/TestCommitDiscussionsApi.java | 20 +- .../java/org/gitlab4j/api/TestCommitsApi.java | 217 +- .../org/gitlab4j/api/TestDeployKeysApi.java | 5 +- .../org/gitlab4j/api/TestDeployTokensApi.java | 58 +- .../org/gitlab4j/api/TestDeploymentsApi.java | 101 +- .../java/org/gitlab4j/api/TestDuration.java | 11 +- .../org/gitlab4j/api/TestEnvironmentsApi.java | 105 +- .../gitlab4j/api/TestEpicDiscussionsApi.java | 19 +- .../java/org/gitlab4j/api/TestEventsApi.java | 47 +- .../api/TestExternalStatusCheckApi.java | 27 +- .../java/org/gitlab4j/api/TestGitLabApi.java | 8 +- .../org/gitlab4j/api/TestGitLabApiBeans.java | 37 +- .../org/gitlab4j/api/TestGitLabApiEvents.java | 29 +- .../gitlab4j/api/TestGitLabApiException.java | 15 +- .../org/gitlab4j/api/TestGitLabCiYamlApi.java | 24 +- .../org/gitlab4j/api/TestGitLabLogin.java | 6 +- .../java/org/gitlab4j/api/TestGroupApi.java | 40 +- .../api/TestGroupCustomAttributes.java | 9 +- .../org/gitlab4j/api/TestHealthCheckApi.java | 19 +- .../java/org/gitlab4j/api/TestISO8601.java | 6 +- .../api/TestIgnoreCertificateErrors.java | 27 +- .../org/gitlab4j/api/TestImportExportApi.java | 33 +- .../gitlab4j/api/TestIssueDiscussionsApi.java | 19 +- .../java/org/gitlab4j/api/TestIssuesApi.java | 38 +- .../java/org/gitlab4j/api/TestJobApi.java | 9 +- .../java/org/gitlab4j/api/TestLabelsApi.java | 40 +- .../org/gitlab4j/api/TestMarkdownApi.java | 40 +- .../org/gitlab4j/api/TestMergeRequestApi.java | 119 +- .../api/TestMergeRequestDiscussionsApi.java | 19 +- .../org/gitlab4j/api/TestMetadataApi.java | 2 - .../org/gitlab4j/api/TestNamespaceApi.java | 18 +- .../java/org/gitlab4j/api/TestNotesApi.java | 13 +- .../api/TestNotificationSettingsApi.java | 19 +- .../api/TestOauth2LoginStreamingOutput.java | 3 +- .../java/org/gitlab4j/api/TestPackageApi.java | 20 +- src/test/java/org/gitlab4j/api/TestPager.java | 39 +- .../org/gitlab4j/api/TestPipelineApi.java | 102 +- .../java/org/gitlab4j/api/TestProjectApi.java | 353 +- .../gitlab4j/api/TestProjectApiSnippets.java | 7 +- .../api/TestProjectCustomAttributes.java | 9 +- .../api/TestProtectedBranchesApi.java | 20 +- .../org/gitlab4j/api/TestReleaseLinksApi.java | 15 +- .../org/gitlab4j/api/TestReleasesApi.java | 45 +- .../org/gitlab4j/api/TestRepositoryApi.java | 64 +- .../gitlab4j/api/TestRepositoryFileApi.java | 37 +- .../api/TestRepositorySubmodulesApi.java | 19 +- .../api/TestRequestResponseLogging.java | 24 +- .../api/TestResourceStateEventsApi.java | 68 +- .../java/org/gitlab4j/api/TestRunnersApi.java | 11 +- .../java/org/gitlab4j/api/TestSearchApi.java | 41 +- .../org/gitlab4j/api/TestServicesApi.java | 728 +-- .../api/TestSnippetDiscussionsApi.java | 19 +- .../org/gitlab4j/api/TestSnippetsApi.java | 38 +- .../java/org/gitlab4j/api/TestStreams.java | 22 +- .../org/gitlab4j/api/TestSystemHooksApi.java | 20 +- .../java/org/gitlab4j/api/TestTagsApi.java | 26 +- .../java/org/gitlab4j/api/TestTodosApi.java | 11 +- .../java/org/gitlab4j/api/TestTopicsApi.java | 15 +- .../gitlab4j/api/TestUnitMergeRequestApi.java | 32 +- .../java/org/gitlab4j/api/TestUpload.java | 16 +- .../java/org/gitlab4j/api/TestUserApi.java | 265 +- .../java/org/gitlab4j/api/TestWikisApi.java | 18 +- .../api/models/ApplicationSettingsTest.java | 17 +- 374 files changed, 27376 insertions(+), 22040 deletions(-) diff --git a/build.gradle b/build.gradle index 880067584..523c116f9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ plugins { id 'java-library' + id 'com.diffplug.spotless' version '6.2.0' id 'signing' id 'maven-publish' id 'de.marcphilipp.nexus-publish' version '0.4.0' @@ -54,6 +55,14 @@ repositories { mavenCentral() } +spotless { + java { + palantirJavaFormat() + importOrder 'java', 'javax', 'jakarta', 'org', 'com', '' + removeUnusedImports() + } +} + nexusPublishing { repositories { sonatype { diff --git a/src/main/java/org/gitlab4j/api/AbstractApi.java b/src/main/java/org/gitlab4j/api/AbstractApi.java index 20371e963..a6d89a397 100644 --- a/src/main/java/org/gitlab4j/api/AbstractApi.java +++ b/src/main/java/org/gitlab4j/api/AbstractApi.java @@ -44,7 +44,7 @@ public Object getProjectIdOrPath(Object obj) throws GitLabApiException { } else if (obj instanceof Long) { return (obj); } else if (obj instanceof Integer) { - //Compatibility with older version of gitlab4j-api: + // Compatibility with older version of gitlab4j-api: return Long.valueOf(((Integer) obj).longValue()); } else if (obj instanceof String) { return (urlEncode(((String) obj).trim())); @@ -63,8 +63,8 @@ public Object getProjectIdOrPath(Object obj) throws GitLabApiException { 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 Long, String, or a Project instance")); + throw (new RuntimeException("Cannot determine ID or path from provided " + + obj.getClass().getSimpleName() + " instance, must be Long, String, or a Project instance")); } } @@ -82,7 +82,7 @@ public Object getGroupIdOrPath(Object obj) throws GitLabApiException { } else if (obj instanceof Long) { return (obj); } else if (obj instanceof Integer) { - //Compatibility with older version of gitlab4j-api: + // Compatibility with older version of gitlab4j-api: return Long.valueOf(((Integer) obj).longValue()); } else if (obj instanceof String) { return (urlEncode(((String) obj).trim())); @@ -101,8 +101,8 @@ public Object getGroupIdOrPath(Object obj) throws GitLabApiException { 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 Long, String, or a Group instance")); + throw (new RuntimeException("Cannot determine ID or path from provided " + + obj.getClass().getSimpleName() + " instance, must be Long, String, or a Group instance")); } } @@ -120,7 +120,7 @@ public Object getUserIdOrUsername(Object obj) throws GitLabApiException { } else if (obj instanceof Long) { return (obj); } else if (obj instanceof Integer) { - //Compatibility with older version of gitlab4j-api: + // Compatibility with older version of gitlab4j-api: return Long.valueOf(((Integer) obj).longValue()); } else if (obj instanceof String) { return (urlEncode(((String) obj).trim())); @@ -139,8 +139,8 @@ public Object getUserIdOrUsername(Object obj) throws GitLabApiException { 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 Long, String, or a User instance")); + throw (new RuntimeException("Cannot determine ID or username from provided " + + obj.getClass().getSimpleName() + " instance, must be Long, String, or a User instance")); } } @@ -158,7 +158,7 @@ public Object getLabelIdOrName(Object obj) throws GitLabApiException { } else if (obj instanceof Long) { return (obj); } else if (obj instanceof Integer) { - //Compatibility with older version of gitlab4j-api: + // Compatibility with older version of gitlab4j-api: return Long.valueOf(((Integer) obj).longValue()); } else if (obj instanceof String) { return (urlEncode(((String) obj).trim())); @@ -177,8 +177,8 @@ public Object getLabelIdOrName(Object obj) throws GitLabApiException { throw (new RuntimeException("Cannot determine ID or name from provided Label instance")); } else { - throw (new RuntimeException("Cannot determine ID or name from provided " + obj.getClass().getSimpleName() + - " instance, must be Long, String, or a Label instance")); + throw (new RuntimeException("Cannot determine ID or name from provided " + + obj.getClass().getSimpleName() + " instance, must be Long, String, or a Label instance")); } } @@ -189,7 +189,7 @@ public Object getNamespaceIdOrPath(Object obj) throws GitLabApiException { } else if (obj instanceof Long) { return (obj); } else if (obj instanceof Integer) { - //Compatibility with older version of gitlab4j-api: + // Compatibility with older version of gitlab4j-api: return Long.valueOf(((Integer) obj).longValue()); } else if (obj instanceof String) { return (urlEncode(((String) obj).trim())); @@ -208,8 +208,8 @@ public Object getNamespaceIdOrPath(Object obj) throws GitLabApiException { throw (new RuntimeException("Cannot determine ID or path from provided Namespace instance")); } else { - throw (new RuntimeException("Cannot determine ID or path from provided " + obj.getClass().getSimpleName() + - " instance, must be Long, String, or a Namespace instance")); + throw (new RuntimeException("Cannot determine ID or path from provided " + + obj.getClass().getSimpleName() + " instance, must be Long, String, or a Namespace instance")); } } @@ -253,7 +253,9 @@ protected String urlEncode(String s) throws GitLabApiException { * @return a ClientResponse instance with the data returned from the endpoint * @throws GitLabApiException if any exception occurs during execution */ - protected Response get(Response.Status expectedStatus, MultivaluedMap queryParams, Object... pathArgs) throws GitLabApiException { + protected Response get( + Response.Status expectedStatus, MultivaluedMap queryParams, Object... pathArgs) + throws GitLabApiException { try { return validate(getApiClient().get(queryParams, pathArgs), expectedStatus); } catch (Exception e) { @@ -272,7 +274,12 @@ protected Response get(Response.Status expectedStatus, MultivaluedMap queryParams, String accepts, Object... pathArgs) throws GitLabApiException { + protected Response getWithAccepts( + Response.Status expectedStatus, + MultivaluedMap queryParams, + String accepts, + Object... pathArgs) + throws GitLabApiException { try { return validate(getApiClient().getWithAccepts(queryParams, accepts, pathArgs), expectedStatus); } catch (Exception e) { @@ -290,7 +297,8 @@ protected Response getWithAccepts(Response.Status expectedStatus, MultivaluedMap * @return a ClientResponse instance with the data returned from the endpoint * @throws GitLabApiException if any exception occurs during execution */ - protected Response get(Response.Status expectedStatus, MultivaluedMap queryParams, URL url) throws GitLabApiException { + protected Response get(Response.Status expectedStatus, MultivaluedMap queryParams, URL url) + throws GitLabApiException { try { return validate(getApiClient().get(queryParams, url), expectedStatus); } catch (Exception e) { @@ -308,7 +316,9 @@ protected Response get(Response.Status expectedStatus, MultivaluedMap queryParams, Object... pathArgs) throws GitLabApiException { + protected Response head( + Response.Status expectedStatus, MultivaluedMap queryParams, Object... pathArgs) + throws GitLabApiException { try { return validate(getApiClient().head(queryParams, pathArgs), expectedStatus); } catch (Exception e) { @@ -326,7 +336,9 @@ protected Response head(Response.Status expectedStatus, MultivaluedMap queryParams, Object... pathArgs) throws GitLabApiException { + protected Response patch( + Response.Status expectedStatus, MultivaluedMap queryParams, Object... pathArgs) + throws GitLabApiException { try { return validate(getApiClient().patch(queryParams, pathArgs), expectedStatus); } catch (Exception e) { @@ -344,7 +356,8 @@ protected Response patch(Response.Status expectedStatus, MultivaluedMap queryParams, URL url) throws GitLabApiException { + protected Response patch(Response.Status expectedStatus, MultivaluedMap queryParams, URL url) + throws GitLabApiException { try { return validate(getApiClient().patch(queryParams, url), expectedStatus); } catch (Exception e) { @@ -362,7 +375,8 @@ protected Response patch(Response.Status expectedStatus, MultivaluedMap queryParams, Object... pathArgs) throws GitLabApiException { + protected Response post( + Response.Status expectedStatus, MultivaluedMap queryParams, Object... pathArgs) + throws GitLabApiException { try { return validate(getApiClient().post(queryParams, pathArgs), expectedStatus); } catch (Exception e) { @@ -455,7 +474,9 @@ protected Response post(Response.Status expectedStatus, Form formData, URL url) * @return a ClientResponse instance with the data returned from the endpoint * @throws GitLabApiException if any exception occurs during execution */ - protected Response upload(Response.Status expectedStatus, String name, File fileToUpload, String mediaType, Object... pathArgs) throws GitLabApiException { + protected Response upload( + Response.Status expectedStatus, String name, File fileToUpload, String mediaType, Object... pathArgs) + throws GitLabApiException { try { return validate(getApiClient().upload(name, fileToUpload, mediaType, pathArgs), expectedStatus); } catch (Exception e) { @@ -463,7 +484,14 @@ protected Response upload(Response.Status expectedStatus, String name, File file } } - protected Response upload(Response.Status expectedStatus, String name, InputStream inputStream, String filename, String mediaType, Object... pathArgs) throws GitLabApiException { + protected Response upload( + Response.Status expectedStatus, + String name, + InputStream inputStream, + String filename, + String mediaType, + Object... pathArgs) + throws GitLabApiException { try { return validate(getApiClient().upload(name, inputStream, filename, mediaType, pathArgs), expectedStatus); } catch (Exception e) { @@ -483,7 +511,8 @@ protected Response upload(Response.Status expectedStatus, String name, InputStre * @return a ClientResponse instance with the data returned from the endpoint * @throws GitLabApiException if any exception occurs during execution */ - protected Response upload(Response.Status expectedStatus, String name, File fileToUpload, String mediaType, URL url) throws GitLabApiException { + 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) { @@ -504,7 +533,9 @@ protected Response upload(Response.Status expectedStatus, String name, File file * @return a ClientResponse instance with the data returned from the endpoint * @throws GitLabApiException if any exception occurs during execution */ - protected Response upload(Response.Status expectedStatus, String name, File fileToUpload, String mediaType, Form formData, URL url) throws GitLabApiException { + protected Response upload( + Response.Status expectedStatus, String name, File fileToUpload, String mediaType, Form formData, URL url) + throws GitLabApiException { try { return validate(getApiClient().upload(name, fileToUpload, mediaType, formData, url), expectedStatus); @@ -523,7 +554,9 @@ protected Response upload(Response.Status expectedStatus, String name, File file * @return a ClientResponse instance with the data returned from the endpoint * @throws GitLabApiException if any exception occurs during execution */ - protected Response put(Response.Status expectedStatus, MultivaluedMap queryParams, Object... pathArgs) throws GitLabApiException { + protected Response put( + Response.Status expectedStatus, MultivaluedMap queryParams, Object... pathArgs) + throws GitLabApiException { try { return validate(getApiClient().put(queryParams, pathArgs), expectedStatus); } catch (Exception e) { @@ -541,7 +574,8 @@ protected Response put(Response.Status expectedStatus, MultivaluedMap queryParams, URL url) throws GitLabApiException { + protected Response put(Response.Status expectedStatus, MultivaluedMap queryParams, URL url) + throws GitLabApiException { try { return validate(getApiClient().put(queryParams, url), expectedStatus); } catch (Exception e) { @@ -559,7 +593,8 @@ protected Response put(Response.Status expectedStatus, MultivaluedMap queryParams, Object... pathArgs) throws GitLabApiException { + protected Response delete( + Response.Status expectedStatus, MultivaluedMap queryParams, Object... pathArgs) + throws GitLabApiException { try { return validate(getApiClient().delete(queryParams, pathArgs), expectedStatus); } catch (Exception e) { @@ -652,7 +691,8 @@ protected Response delete(Response.Status expectedStatus, MultivaluedMap queryParams, URL url) throws GitLabApiException { + protected Response delete(Response.Status expectedStatus, MultivaluedMap queryParams, URL url) + throws GitLabApiException { try { return validate(getApiClient().delete(queryParams, url), expectedStatus); } catch (Exception e) { @@ -681,7 +721,8 @@ protected void addFormParam(Form formData, String name, Object value) throws Ill * @param required the field is required flag * @throws IllegalArgumentException if a required parameter is null or empty */ - protected void addFormParam(Form formData, String name, Object value, boolean required) throws IllegalArgumentException { + protected void addFormParam(Form formData, String name, Object value, boolean required) + throws IllegalArgumentException { if (value == null) { @@ -762,7 +803,10 @@ protected MultivaluedMap getPerPageQueryParam(int perPage) { * @return a MultivaluedMap instance containing "page" and "per_page" params */ protected MultivaluedMap getPageQueryParams(int page, int perPage) { - return (new GitLabApiForm().withParam(PAGE_PARAM, page).withParam(PER_PAGE_PARAM, perPage).asMap()); + return (new GitLabApiForm() + .withParam(PAGE_PARAM, page) + .withParam(PER_PAGE_PARAM, perPage) + .asMap()); } /** @@ -773,13 +817,14 @@ protected MultivaluedMap getPageQueryParams(int page, int perPag * @param customAttributesEnabled enables customAttributes for this query * @return a MultivaluedMap instance containing "page" and "per_page" params */ - protected MultivaluedMap getPageQueryParams(int page, int perPage, boolean customAttributesEnabled) { + protected MultivaluedMap getPageQueryParams( + int page, int perPage, boolean customAttributesEnabled) { GitLabApiForm form = new GitLabApiForm().withParam(PAGE_PARAM, page).withParam(PER_PAGE_PARAM, perPage); if (customAttributesEnabled) return (form.withParam("with_custom_attributes", true).asMap()); - return (form.asMap()); + return (form.asMap()); } /** @@ -788,7 +833,9 @@ protected MultivaluedMap getPageQueryParams(int page, int perPag * @return a MultivaluedMap instance containing the "per_page" param with the default value */ protected MultivaluedMap getDefaultPerPageParam() { - return (new GitLabApiForm().withParam(PER_PAGE_PARAM, getDefaultPerPage()).asMap()); + return (new GitLabApiForm() + .withParam(PER_PAGE_PARAM, getDefaultPerPage()) + .asMap()); } /** diff --git a/src/main/java/org/gitlab4j/api/ApplicationSettingsApi.java b/src/main/java/org/gitlab4j/api/ApplicationSettingsApi.java index 28ff1d716..708932de4 100644 --- a/src/main/java/org/gitlab4j/api/ApplicationSettingsApi.java +++ b/src/main/java/org/gitlab4j/api/ApplicationSettingsApi.java @@ -5,8 +5,8 @@ import javax.ws.rs.core.Response; -import org.gitlab4j.api.models.Setting; import org.gitlab4j.api.models.ApplicationSettings; +import org.gitlab4j.api.models.Setting; import org.gitlab4j.api.utils.ISO8601; import com.fasterxml.jackson.databind.JsonNode; @@ -53,7 +53,7 @@ public ApplicationSettings updateApplicationSettings(ApplicationSettings appSett } final GitLabApiForm form = new GitLabApiForm(); - appSettings.getSettings().forEach((s, v) -> form.withParam(s, v)); + appSettings.getSettings().forEach((s, v) -> form.withParam(s, v)); Response response = put(Response.Status.OK, form.asMap(), "application", "settings"); JsonNode root = response.readEntity(JsonNode.class); return (parseApplicationSettings(root)); @@ -116,40 +116,42 @@ public static final ApplicationSettings parseApplicationSettings(JsonNode root) String fieldName = fieldNames.next(); switch (fieldName) { - case "id": - appSettings.setId(root.path(fieldName).asLong()); - break; - - case "created_at": - try { - String value = root.path(fieldName).asText(); - appSettings.setCreatedAt(ISO8601.toDate(value)); - } catch (ParseException pe) { - throw new GitLabApiException(pe); - } - break; - - case "updated_at": - try { - String value = root.path(fieldName).asText(); - appSettings.setUpdatedAt(ISO8601.toDate(value)); - } catch (ParseException pe) { - throw new GitLabApiException(pe); - } - break; - - default: - - Setting setting = Setting.forValue(fieldName); - if (setting != null) { - appSettings.addSetting(setting, root.path(fieldName)); - } else { - GitLabApi.getLogger().warning(String.format("Unknown setting: %s, type: %s", - fieldName, root.path(fieldName).getClass().getSimpleName())); - appSettings.addSetting(fieldName, root.path(fieldName)); - } - - break; + case "id": + appSettings.setId(root.path(fieldName).asLong()); + break; + + case "created_at": + try { + String value = root.path(fieldName).asText(); + appSettings.setCreatedAt(ISO8601.toDate(value)); + } catch (ParseException pe) { + throw new GitLabApiException(pe); + } + break; + + case "updated_at": + try { + String value = root.path(fieldName).asText(); + appSettings.setUpdatedAt(ISO8601.toDate(value)); + } catch (ParseException pe) { + throw new GitLabApiException(pe); + } + break; + + default: + Setting setting = Setting.forValue(fieldName); + if (setting != null) { + appSettings.addSetting(setting, root.path(fieldName)); + } else { + GitLabApi.getLogger() + .warning(String.format( + "Unknown setting: %s, type: %s", + fieldName, + root.path(fieldName).getClass().getSimpleName())); + appSettings.addSetting(fieldName, root.path(fieldName)); + } + + break; } } diff --git a/src/main/java/org/gitlab4j/api/ApplicationsApi.java b/src/main/java/org/gitlab4j/api/ApplicationsApi.java index b5c793702..c20101831 100644 --- a/src/main/java/org/gitlab4j/api/ApplicationsApi.java +++ b/src/main/java/org/gitlab4j/api/ApplicationsApi.java @@ -83,7 +83,8 @@ public Stream getApplicationsStream() throws GitLabApiException { * @return the created Application instance * @throws GitLabApiException if any exception occurs */ - public Application createApplication(String name, String redirectUri, ApplicationScope[] scopes) throws GitLabApiException { + public Application createApplication(String name, String redirectUri, ApplicationScope[] scopes) + throws GitLabApiException { if (scopes == null || scopes.length == 0) { throw new GitLabApiException("scopes cannot be null or empty"); @@ -103,7 +104,8 @@ public Application createApplication(String name, String redirectUri, Applicatio * @return the created Application instance * @throws GitLabApiException if any exception occurs */ - public Application createApplication(String name, String redirectUri, List scopes) throws GitLabApiException { + public Application createApplication(String name, String redirectUri, List scopes) + throws GitLabApiException { if (scopes == null || scopes.isEmpty()) { throw new GitLabApiException("scopes cannot be null or empty"); @@ -113,7 +115,7 @@ public Application createApplication(String name, String redirectUri, List getAuditEvents(Date created_after, Date created_before, String entityType, Long entityId) throws GitLabApiException { - return (getAuditEvents(created_after, created_before, entityType, entityId, getDefaultPerPage()).all()); + public List getAuditEvents(Date created_after, Date created_before, String entityType, Long entityId) + throws GitLabApiException { + return (getAuditEvents(created_after, created_before, entityType, entityId, getDefaultPerPage()) + .all()); } /** @@ -49,7 +51,9 @@ public List getAuditEvents(Date created_after, Date created_before, * @return a Pager of group Audit events * @throws GitLabApiException if any exception occurs */ - public Pager getAuditEvents(Date created_after, Date created_before, String entityType, Long entityId, int itemsPerPage) throws GitLabApiException { + public Pager getAuditEvents( + Date created_after, Date created_before, String entityType, Long entityId, int itemsPerPage) + throws GitLabApiException { Form form = new GitLabApiForm() .withParam("created_before", ISO8601.toString(created_before, false)) .withParam("created_after", ISO8601.toString(created_after, false)) @@ -70,7 +74,8 @@ public Pager getAuditEvents(Date created_after, Date created_before, * @return a Stream of group Audit events * @throws GitLabApiException if any exception occurs */ - public Stream getAuditEventsStream(Date created_after, Date created_before, String entityType, Long entityId) throws GitLabApiException { + public Stream getAuditEventsStream( + Date created_after, Date created_before, String entityType, Long entityId) throws GitLabApiException { return (getAuditEvents(created_after, created_before, entityType, entityId, getDefaultPerPage()).stream()); } diff --git a/src/main/java/org/gitlab4j/api/AwardEmojiApi.java b/src/main/java/org/gitlab4j/api/AwardEmojiApi.java index dce6a1306..207dfcd89 100644 --- a/src/main/java/org/gitlab4j/api/AwardEmojiApi.java +++ b/src/main/java/org/gitlab4j/api/AwardEmojiApi.java @@ -30,8 +30,14 @@ public AwardEmojiApi(GitLabApi gitLabApi) { * @throws GitLabApiException if any exception occurs */ public List getIssueAwardEmojis(Object projectIdOrPath, Long issueIid) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()), - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "award_emoji"); + Response response = get( + Response.Status.OK, + getPageQueryParams(1, getDefaultPerPage()), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "award_emoji"); return response.readEntity(new GenericType>() {}); } @@ -45,9 +51,16 @@ public List getIssueAwardEmojis(Object projectIdOrPath, Long issueIi * @return a list of AwardEmoji for the specified merge request * @throws GitLabApiException if any exception occurs */ - public List getMergeRequestAwardEmojis(Object projectIdOrPath, Long mergeRequestIid) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()), - "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "award_emoji"); + public List getMergeRequestAwardEmojis(Object projectIdOrPath, Long mergeRequestIid) + throws GitLabApiException { + Response response = get( + Response.Status.OK, + getPageQueryParams(1, getDefaultPerPage()), + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "award_emoji"); return response.readEntity(new GenericType>() {}); } @@ -62,8 +75,14 @@ public List getMergeRequestAwardEmojis(Object projectIdOrPath, Long * @throws GitLabApiException if any exception occurs */ public List getSnippetAwardEmojis(Object projectIdOrPath, Long snippetId) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()), - "projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji"); + Response response = get( + Response.Status.OK, + getPageQueryParams(1, getDefaultPerPage()), + "projects", + getProjectIdOrPath(projectIdOrPath), + "snippets", + snippetId, + "award_emoji"); return response.readEntity(new GenericType>() {}); } @@ -78,9 +97,18 @@ public List getSnippetAwardEmojis(Object projectIdOrPath, Long snipp * @return a list of AwardEmoji for the specified note * @throws GitLabApiException if any exception occurs */ - public List getIssueNoteAwardEmojis(Object projectIdOrPath, Long issueIid, Long noteId) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()), - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji"); + public List getIssueNoteAwardEmojis(Object projectIdOrPath, Long issueIid, Long 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>() {}); } @@ -95,7 +123,8 @@ public List getIssueNoteAwardEmojis(Object projectIdOrPath, Long iss * @return a list of AwardEmoji for the specified note * @throws GitLabApiException if any exception occurs */ - public List getNoteAwardEmojis(Object projectIdOrPath, Long issueIid, Long noteId) throws GitLabApiException { + public List getNoteAwardEmojis(Object projectIdOrPath, Long issueIid, Long noteId) + throws GitLabApiException { return getIssueNoteAwardEmojis(projectIdOrPath, issueIid, noteId); } @@ -110,9 +139,18 @@ public List getNoteAwardEmojis(Object projectIdOrPath, Long issueIid * @return a list of AwardEmoji for the specified note * @throws GitLabApiException if any exception occurs */ - public List getMergeRequestNoteAwardEmojis(Object projectIdOrPath, Long mergeRequestIid, Long noteId) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()), - "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji"); + public List getMergeRequestNoteAwardEmojis(Object projectIdOrPath, Long mergeRequestIid, Long noteId) + throws GitLabApiException { + Response response = get( + Response.Status.OK, + getPageQueryParams(1, getDefaultPerPage()), + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "notes", + noteId, + "award_emoji"); return response.readEntity(new GenericType>() {}); } @@ -127,9 +165,17 @@ public List getMergeRequestNoteAwardEmojis(Object projectIdOrPath, L * @return an AwardEmoji instance for the specified award emoji * @throws GitLabApiException if any exception occurs */ - public AwardEmoji getIssueAwardEmoji(Object projectIdOrPath, Long issueIid, Long awardId) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()), - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "award_emoji", awardId); + public AwardEmoji getIssueAwardEmoji(Object projectIdOrPath, Long issueIid, Long 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)); } @@ -144,9 +190,17 @@ public AwardEmoji getIssueAwardEmoji(Object projectIdOrPath, Long issueIid, Long * @return an AwardEmoji instance for the specified award emoji * @throws GitLabApiException if any exception occurs */ - public AwardEmoji getMergeRequestAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, Long awardId) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()), - "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "award_emoji", awardId); + public AwardEmoji getMergeRequestAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, Long 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)); } @@ -161,9 +215,17 @@ public AwardEmoji getMergeRequestAwardEmoji(Object projectIdOrPath, Long mergeRe * @return an AwardEmoji instance for the specified award emoji * @throws GitLabApiException if any exception occurs */ - public AwardEmoji getSnippetAwardEmoji(Object projectIdOrPath, Long snippetId, Long awardId) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()), - "projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji", awardId); + public AwardEmoji getSnippetAwardEmoji(Object projectIdOrPath, Long snippetId, Long 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)); } @@ -179,9 +241,19 @@ public AwardEmoji getSnippetAwardEmoji(Object projectIdOrPath, Long snippetId, L * @return an AwardEmoji instance for the specified award emoji * @throws GitLabApiException if any exception occurs */ - public AwardEmoji getIssueNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, Long awardId) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()), - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId); + public AwardEmoji getIssueNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, Long awardId) + throws GitLabApiException { + Response response = get( + Response.Status.OK, + getPageQueryParams(1, getDefaultPerPage()), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "notes", + noteId, + "award_emoji", + awardId); return (response.readEntity(AwardEmoji.class)); } @@ -199,8 +271,9 @@ public AwardEmoji getIssueNoteAwardEmoji(Object projectIdOrPath, Long issueIid, * @deprecated use {@link #getIssueNoteAwardEmoji(Object, Long, Long, Long)} instead */ @Deprecated - public AwardEmoji getNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, Long awardId) throws GitLabApiException { - return getIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, awardId); + public AwardEmoji getNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, Long awardId) + throws GitLabApiException { + return getIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, awardId); } /** @@ -215,9 +288,19 @@ public AwardEmoji getNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long * @return an AwardEmoji instance for the specified award emoji * @throws GitLabApiException if any exception occurs */ - public AwardEmoji getMergeRequestNoteAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, Long noteId, Long awardId) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()), - "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji", awardId); + public AwardEmoji getMergeRequestNoteAwardEmoji( + Object projectIdOrPath, Long mergeRequestIid, Long noteId, Long awardId) throws GitLabApiException { + Response response = get( + Response.Status.OK, + getPageQueryParams(1, getDefaultPerPage()), + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "notes", + noteId, + "award_emoji", + awardId); return (response.readEntity(AwardEmoji.class)); } @@ -233,9 +316,15 @@ public AwardEmoji getMergeRequestNoteAwardEmoji(Object projectIdOrPath, Long mer * @throws GitLabApiException if any exception occurs */ public AwardEmoji addIssueAwardEmoji(Object projectIdOrPath, Long issueIid, 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, "award_emoji"); + GitLabApiForm form = new GitLabApiForm().withParam("name", name, true); + Response response = post( + Response.Status.CREATED, + form.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "award_emoji"); return (response.readEntity(AwardEmoji.class)); } @@ -250,10 +339,17 @@ public AwardEmoji addIssueAwardEmoji(Object projectIdOrPath, Long issueIid, Stri * @return an AwardEmoji instance for the added award emoji * @throws GitLabApiException if any exception occurs */ - public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, String name) throws GitLabApiException { - GitLabApiForm form = new GitLabApiForm().withParam("name", name, true); - Response response = post(Response.Status.CREATED, form.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "award_emoji"); + public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, String name) + throws GitLabApiException { + GitLabApiForm form = new GitLabApiForm().withParam("name", name, true); + Response response = post( + Response.Status.CREATED, + form.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "award_emoji"); return (response.readEntity(AwardEmoji.class)); } @@ -268,10 +364,17 @@ public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Long mergeRe * @return an AwardEmoji instance for the added award emoji * @throws GitLabApiException if any exception occurs */ - public AwardEmoji addSnippetAwardEmoji(Object projectIdOrPath, Long snippetId, String name) throws GitLabApiException { - GitLabApiForm form = new GitLabApiForm().withParam("name", name, true); - Response response = post(Response.Status.CREATED, form.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji"); + public AwardEmoji addSnippetAwardEmoji(Object projectIdOrPath, Long snippetId, String name) + throws GitLabApiException { + GitLabApiForm form = new GitLabApiForm().withParam("name", name, true); + Response response = post( + Response.Status.CREATED, + form.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "snippets", + snippetId, + "award_emoji"); return (response.readEntity(AwardEmoji.class)); } @@ -287,10 +390,19 @@ public AwardEmoji addSnippetAwardEmoji(Object projectIdOrPath, Long snippetId, S * @return an AwardEmoji instance for the added award emoji * @throws GitLabApiException if any exception occurs */ - public AwardEmoji addIssueNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long 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"); + public AwardEmoji addIssueNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long 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)); } @@ -308,7 +420,8 @@ public AwardEmoji addIssueNoteAwardEmoji(Object projectIdOrPath, Long issueIid, * @deprecated use {@link #addIssueNoteAwardEmoji(Object, Long, Long, String)} */ @Deprecated - public AwardEmoji addNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, String name) throws GitLabApiException { + public AwardEmoji addNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, String name) + throws GitLabApiException { return addIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, name); } @@ -324,10 +437,19 @@ public AwardEmoji addNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long * @return an AwardEmoji instance for the added award emoji * @throws GitLabApiException if any exception occurs */ - public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, 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), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji"); + public AwardEmoji addMergeRequestAwardEmoji( + Object projectIdOrPath, Integer mergeRequestIid, 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), + "merge_requests", + mergeRequestIid, + "notes", + noteId, + "award_emoji"); return (response.readEntity(AwardEmoji.class)); } @@ -342,8 +464,15 @@ public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Integer merg * @throws GitLabApiException if any exception occurs */ public void deleteIssueAwardEmoji(Object projectIdOrPath, Long issueIid, Long awardId) throws GitLabApiException { - delete(Response.Status.NO_CONTENT, null, - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "award_emoji", awardId); + delete( + Response.Status.NO_CONTENT, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "award_emoji", + awardId); } /** @@ -356,9 +485,17 @@ public void deleteIssueAwardEmoji(Object projectIdOrPath, Long issueIid, Long aw * @param awardId the ID of the award emoji to delete * @throws GitLabApiException if any exception occurs */ - public void deleteMergeRequestAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, Long awardId) throws GitLabApiException { - delete(Response.Status.NO_CONTENT, null, - "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "award_emoji", awardId); + public void deleteMergeRequestAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, Long awardId) + throws GitLabApiException { + delete( + Response.Status.NO_CONTENT, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "award_emoji", + awardId); } /** @@ -371,9 +508,17 @@ public void deleteMergeRequestAwardEmoji(Object projectIdOrPath, Long mergeReque * @param awardId the ID of the award emoji to delete * @throws GitLabApiException if any exception occurs */ - public void deleteSnippetAwardEmoji(Object projectIdOrPath, Long snippetId, Long awardId) throws GitLabApiException { - delete(Response.Status.NO_CONTENT, null, - "projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji", awardId); + public void deleteSnippetAwardEmoji(Object projectIdOrPath, Long snippetId, Long awardId) + throws GitLabApiException { + delete( + Response.Status.NO_CONTENT, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "snippets", + snippetId, + "award_emoji", + awardId); } /** @@ -387,9 +532,19 @@ public void deleteSnippetAwardEmoji(Object projectIdOrPath, Long snippetId, Long * @param awardId the ID of the award emoji to delete * @throws GitLabApiException if any exception occurs */ - public void deleteIssueNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, Long awardId) throws GitLabApiException { - delete(Response.Status.NO_CONTENT, null, - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId); + public void deleteIssueNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, Long awardId) + throws GitLabApiException { + delete( + Response.Status.NO_CONTENT, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "notes", + noteId, + "award_emoji", + awardId); } /** @@ -405,7 +560,8 @@ public void deleteIssueNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Lon * @deprecated use {@link #deleteIssueNoteAwardEmoji(Object, Long, Long, Long)} instead */ @Deprecated - public void deleteNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, Long awardId) throws GitLabApiException { + public void deleteNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, Long awardId) + throws GitLabApiException { deleteIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, awardId); } @@ -420,8 +576,18 @@ public void deleteNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long not * @param awardId the ID of the award emoji to delete * @throws GitLabApiException if any exception occurs */ - public void deleteMergeRequestNoteAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, Long noteId, Long awardId) throws GitLabApiException { - delete(Response.Status.NO_CONTENT, null, - "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji", awardId); + public void deleteMergeRequestNoteAwardEmoji( + Object projectIdOrPath, Long mergeRequestIid, Long noteId, Long awardId) throws GitLabApiException { + delete( + Response.Status.NO_CONTENT, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "notes", + noteId, + "award_emoji", + awardId); } } diff --git a/src/main/java/org/gitlab4j/api/BoardsApi.java b/src/main/java/org/gitlab4j/api/BoardsApi.java index 975cba5e4..09047b1b6 100644 --- a/src/main/java/org/gitlab4j/api/BoardsApi.java +++ b/src/main/java/org/gitlab4j/api/BoardsApi.java @@ -49,8 +49,12 @@ public List getBoards(Object projectIdOrPath) throws GitLabApiException { * @throws GitLabApiException if any exception occurs */ public List getBoards(Object projectIdOrPath, int page, int perPage) throws GitLabApiException { - Response response = get(javax.ws.rs.core.Response.Status.OK, getPageQueryParams(page, perPage), - "projects", getProjectIdOrPath(projectIdOrPath), "boards"); + Response response = get( + javax.ws.rs.core.Response.Status.OK, + getPageQueryParams(page, perPage), + "projects", + getProjectIdOrPath(projectIdOrPath), + "boards"); return (response.readEntity(new GenericType>() {})); } @@ -65,8 +69,8 @@ public List getBoards(Object projectIdOrPath, int page, int perPage) thro * @throws GitLabApiException if any exception occurs */ public Pager getBoards(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Board.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "boards")); + return (new Pager( + this, Board.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "boards")); } /** @@ -93,8 +97,8 @@ public Stream getBoardsStream(Object projectIdOrPath) throws GitLabApiExc * @throws GitLabApiException if any exception occurs */ public Board getBoard(Object projectIdOrPath, Long boardId) throws GitLabApiException { - Response response = get(Response.Status.OK, null, - "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId); + Response response = + get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId); return (response.readEntity(Board.class)); } @@ -129,7 +133,8 @@ public Optional getOptionalBoard(Object projectIdOrPath, Long boardId) { */ public Board createBoard(Object projectIdOrPath, String name) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm().withParam("name", name, true); - Response response = post(Response.Status.CREATED, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "boards"); + Response response = post( + Response.Status.CREATED, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "boards"); return (response.readEntity(Board.class)); } @@ -150,16 +155,28 @@ public Board createBoard(Object projectIdOrPath, String name) throws GitLabApiEx * @return the updated Board instance * @throws GitLabApiException if any exception occurs */ - public BoardList updateBoard(Object projectIdOrPath, Long boardId, String name, - Long assigneeId, Long milestoneId, String labels, Integer weight) throws GitLabApiException { + public BoardList updateBoard( + Object projectIdOrPath, + Long boardId, + String name, + Long assigneeId, + Long milestoneId, + String labels, + Integer weight) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("name", name) .withParam("assignee_id", assigneeId) .withParam("milestone_id", milestoneId) .withParam("labels", labels) .withParam("weight", weight); - Response response = put(Response.Status.OK, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId); + Response response = put( + Response.Status.OK, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "boards", + boardId); return (response.readEntity(BoardList.class)); } @@ -205,9 +222,16 @@ public List getBoardLists(Object projectIdOrPath, Long boardId) throw * @return a list of the issue board's lists in the specified range * @throws GitLabApiException if any exception occurs */ - public List getBoardLists(Object projectIdOrPath, Long boardId, int page, int perPage) throws GitLabApiException { - Response response = get(javax.ws.rs.core.Response.Status.OK, getPageQueryParams(page, perPage), - "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists"); + public List getBoardLists(Object projectIdOrPath, Long boardId, int page, int perPage) + throws GitLabApiException { + Response response = get( + javax.ws.rs.core.Response.Status.OK, + getPageQueryParams(page, perPage), + "projects", + getProjectIdOrPath(projectIdOrPath), + "boards", + boardId, + "lists"); return (response.readEntity(new GenericType>() {})); } @@ -222,9 +246,18 @@ public List getBoardLists(Object projectIdOrPath, Long boardId, int p * @return a Pager of the issue board's lists * @throws GitLabApiException if any exception occurs */ - public Pager getBoardLists(Object projectIdOrPath, Long boardId, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, BoardList.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists")); + public Pager getBoardLists(Object projectIdOrPath, Long boardId, int itemsPerPage) + throws GitLabApiException { + return (new Pager( + this, + BoardList.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "boards", + boardId, + "lists")); } /** @@ -253,8 +286,15 @@ public Stream getBoardsListsStream(Object projectIdOrPath, Long board * @throws GitLabApiException if any exception occurs */ public BoardList getBoardList(Object projectIdOrPath, Long boardId, Long listId) throws GitLabApiException { - Response response = get(Response.Status.OK, null, - "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists", listId); + Response response = get( + Response.Status.OK, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "boards", + boardId, + "lists", + listId); return (response.readEntity(BoardList.class)); } @@ -288,9 +328,15 @@ public Optional getOptionalBoardList(Object projectIdOrPath, Long boa * @throws GitLabApiException if any exception occurs */ public BoardList createBoardList(Object projectIdOrPath, Long boardId, Long labelId) throws GitLabApiException { - GitLabApiForm formData = new GitLabApiForm() - .withParam("label_id", labelId, true); - Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists"); + GitLabApiForm formData = new GitLabApiForm().withParam("label_id", labelId, true); + Response response = post( + Response.Status.CREATED, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "boards", + boardId, + "lists"); return (response.readEntity(BoardList.class)); } @@ -306,10 +352,18 @@ public BoardList createBoardList(Object projectIdOrPath, Long boardId, Long labe * @return the updated BoardList instance * @throws GitLabApiException if any exception occurs */ - public BoardList updateBoardList(Object projectIdOrPath, Long boardId, Long listId, Integer position) throws GitLabApiException { + public BoardList updateBoardList(Object projectIdOrPath, Long boardId, Long listId, Integer position) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm().withParam("position", position, true); - Response response = putWithFormData(Response.Status.OK, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists", listId); + Response response = putWithFormData( + Response.Status.OK, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "boards", + boardId, + "lists", + listId); return (response.readEntity(BoardList.class)); } @@ -324,6 +378,14 @@ public BoardList updateBoardList(Object projectIdOrPath, Long boardId, Long list * @throws GitLabApiException if any exception occurs */ public void deleteBoardList(Object projectIdOrPath, Long boardId, Long listId) throws GitLabApiException { - delete(Response.Status.NO_CONTENT, null, "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists", listId); + delete( + Response.Status.NO_CONTENT, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "boards", + boardId, + "lists", + listId); } } diff --git a/src/main/java/org/gitlab4j/api/CommitsApi.java b/src/main/java/org/gitlab4j/api/CommitsApi.java index ece23acbf..ef205cb8f 100644 --- a/src/main/java/org/gitlab4j/api/CommitsApi.java +++ b/src/main/java/org/gitlab4j/api/CommitsApi.java @@ -46,7 +46,8 @@ public CommitsApi(GitLabApi gitLabApi) { * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ public List getCommits(Object projectIdOrPath) throws GitLabApiException { - return (getCommits(projectIdOrPath, null, null, null, null, true, null, null, getDefaultPerPage()).all()); + return (getCommits(projectIdOrPath, null, null, null, null, true, null, null, getDefaultPerPage()) + .all()); } /** @@ -90,7 +91,7 @@ public Pager getCommits(Object projectIdOrPath, int itemsPerPage) throws * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ public Stream getCommitStream(Object projectIdOrPath) throws GitLabApiException { - return (getCommits(projectIdOrPath, null, null, null,null, true, null, null, getDefaultPerPage()).stream()); + return (getCommits(projectIdOrPath, null, null, null, null, true, null, null, getDefaultPerPage()).stream()); } /** @@ -106,8 +107,10 @@ public Stream getCommitStream(Object projectIdOrPath) throws GitLabApiEx * @return a list containing the commits for the specified project ID * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public List getCommits(Object projectIdOrPath, String ref, Date since, Date until, String path) throws GitLabApiException { - return (getCommits(projectIdOrPath, ref, since, until, path, null, null, null, getDefaultPerPage()).all()); + public List getCommits(Object projectIdOrPath, String ref, Date since, Date until, String path) + throws GitLabApiException { + return (getCommits(projectIdOrPath, ref, since, until, path, null, null, null, getDefaultPerPage()) + .all()); } /** @@ -122,7 +125,8 @@ public List getCommits(Object projectIdOrPath, String ref, Date since, D * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ public List getCommits(Object projectIdOrPath, String ref, String path) throws GitLabApiException { - return (getCommits(projectIdOrPath, ref, null, null, path, null, null, null, getDefaultPerPage()).all()); + return (getCommits(projectIdOrPath, ref, null, null, path, null, null, null, getDefaultPerPage()) + .all()); } /** @@ -137,8 +141,10 @@ public List getCommits(Object projectIdOrPath, String ref, String path) * @return a list containing the commits for the specified project ID * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public List getCommits(Object projectIdOrPath, String ref, Date since, Date until) throws GitLabApiException { - return (getCommits(projectIdOrPath, ref, since, until, null, null, null, null, getDefaultPerPage()).all()); + public List getCommits(Object projectIdOrPath, String ref, Date since, Date until) + throws GitLabApiException { + return (getCommits(projectIdOrPath, ref, since, until, null, null, null, null, getDefaultPerPage()) + .all()); } /** @@ -157,7 +163,8 @@ public List getCommits(Object projectIdOrPath, String ref, Date since, D * @deprecated */ @Deprecated - public List getCommits(Object projectIdOrPath, String ref, Date since, Date until, int page, int perPage) throws GitLabApiException { + public List getCommits(Object projectIdOrPath, String ref, Date since, Date until, int page, int perPage) + throws GitLabApiException { return (getCommits(projectIdOrPath, ref, since, until, null, page, perPage)); } @@ -173,7 +180,8 @@ public List getCommits(Object projectIdOrPath, String ref, Date since, D * @return a Stream containing the commits for the specified project ID * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public Stream getCommitsStream(Object projectIdOrPath, String ref, Date since, Date until) throws GitLabApiException { + public Stream getCommitsStream(Object projectIdOrPath, String ref, Date since, Date until) + throws GitLabApiException { return (getCommits(projectIdOrPath, ref, since, until, null, null, null, null, getDefaultPerPage()).stream()); } @@ -190,7 +198,8 @@ public Stream getCommitsStream(Object projectIdOrPath, String ref, Date * @return a Stream containing the commits for the specified project ID * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public Stream getCommitsStream(Object projectIdOrPath, String ref, Date since, Date until, String path) throws GitLabApiException { + public Stream getCommitsStream(Object projectIdOrPath, String ref, Date since, Date until, String path) + throws GitLabApiException { return (getCommits(projectIdOrPath, ref, since, until, path, null, null, null, getDefaultPerPage()).stream()); } @@ -211,15 +220,23 @@ public Stream getCommitsStream(Object projectIdOrPath, String ref, Date * @deprecated */ @Deprecated - public List getCommits(Object projectIdOrPath, String ref, Date since, Date until, String path, int page, int perPage) throws GitLabApiException { + public List getCommits( + Object projectIdOrPath, String ref, Date since, Date until, String path, int page, int perPage) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("ref_name", ref) .withParam("since", ISO8601.toString(since, false)) .withParam("until", ISO8601.toString(until, false)) .withParam("path", (path == null ? null : urlEncode(path))) - .withParam(PAGE_PARAM, page) + .withParam(PAGE_PARAM, page) .withParam(PER_PAGE_PARAM, perPage); - Response response = get(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits"); + Response response = get( + Response.Status.OK, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits"); return (response.readEntity(new GenericType>() {})); } @@ -236,7 +253,8 @@ public List getCommits(Object projectIdOrPath, String ref, Date since, D * @return a Pager containing the commits for the specified project ID * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public Pager getCommits(Object projectIdOrPath, String ref, Date since, Date until, int itemsPerPage) throws GitLabApiException { + public Pager getCommits(Object projectIdOrPath, String ref, Date since, Date until, int itemsPerPage) + throws GitLabApiException { return getCommits(projectIdOrPath, ref, since, until, null, null, null, null, itemsPerPage); } @@ -254,7 +272,9 @@ public Pager getCommits(Object projectIdOrPath, String ref, Date since, * @return a Pager containing the commits for the specified project ID * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public Pager getCommits(Object projectIdOrPath, String ref, Date since, Date until, String path, int itemsPerPage) throws GitLabApiException { + public Pager getCommits( + Object projectIdOrPath, String ref, Date since, Date until, String path, int itemsPerPage) + throws GitLabApiException { return (getCommits(projectIdOrPath, ref, since, until, path, null, null, null, itemsPerPage)); } @@ -274,9 +294,18 @@ public Pager getCommits(Object projectIdOrPath, String ref, Date since, * @return a Pager containing the commits for the specified project ID * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public List getCommits(Object projectIdOrPath, String ref, Date since, Date until, - String path, Boolean all, Boolean withStats, Boolean firstParent) throws GitLabApiException { - return (getCommits(projectIdOrPath, ref, since, until, path, all, withStats, firstParent, getDefaultPerPage()).all()); + public List getCommits( + Object projectIdOrPath, + String ref, + Date since, + Date until, + String path, + Boolean all, + Boolean withStats, + Boolean firstParent) + throws GitLabApiException { + return (getCommits(projectIdOrPath, ref, since, until, path, all, withStats, firstParent, getDefaultPerPage()) + .all()); } /** @@ -296,8 +325,17 @@ public List getCommits(Object projectIdOrPath, String ref, Date since, D * @return a Pager containing the commits for the specified project ID * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public Pager getCommits(Object projectIdOrPath, String ref, Date since, Date until, - String path, Boolean all, Boolean withStats, Boolean firstParent, int itemsPerPage) throws GitLabApiException { + public Pager getCommits( + Object projectIdOrPath, + String ref, + Date since, + Date until, + String path, + Boolean all, + Boolean withStats, + Boolean firstParent, + int itemsPerPage) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("ref_name", ref) .withParam("since", ISO8601.toString(since, false)) @@ -306,7 +344,15 @@ public Pager getCommits(Object projectIdOrPath, String ref, Date since, .withParam("all", all) .withParam("with_stats", withStats) .withParam("first_parent", firstParent); - return (new Pager(this, Commit.class, itemsPerPage, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits")); + return (new Pager( + this, + Commit.class, + itemsPerPage, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits")); } /** @@ -325,9 +371,18 @@ public Pager getCommits(Object projectIdOrPath, String ref, Date since, * @return a Stream containing the commits for the specified project ID * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public Stream getCommitsStream(Object projectIdOrPath, String ref, Date since, Date until, - String path, Boolean all, Boolean withStats, Boolean firstParent) throws GitLabApiException { - return (getCommits(projectIdOrPath, ref, since, until, path, all, withStats, firstParent, getDefaultPerPage()).stream()); + public Stream getCommitsStream( + Object projectIdOrPath, + String ref, + Date since, + Date until, + String path, + Boolean all, + Boolean withStats, + Boolean firstParent) + throws GitLabApiException { + return (getCommits(projectIdOrPath, ref, since, until, path, all, withStats, firstParent, getDefaultPerPage()) + .stream()); } /** @@ -341,7 +396,14 @@ public Stream getCommitsStream(Object projectIdOrPath, String ref, Date * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ public Commit getCommit(Object projectIdOrPath, String sha) throws GitLabApiException { - Response response = get(Response.Status.OK, getDefaultPerPageParam(), "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", urlEncode(sha)); + Response response = get( + Response.Status.OK, + getDefaultPerPageParam(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + urlEncode(sha)); return (response.readEntity(Commit.class)); } @@ -374,7 +436,8 @@ public Optional getOptionalCommit(Object projectIdOrPath, String sha) { * @since Gitlab 10.6 */ public List getCommitRefs(Object projectIdOrPath, String sha) throws GitLabApiException { - return (getCommitRefs(projectIdOrPath, sha, RefType.ALL, getDefaultPerPage()).all()); + return (getCommitRefs(projectIdOrPath, sha, RefType.ALL, getDefaultPerPage()) + .all()); } /** @@ -389,7 +452,8 @@ public List getCommitRefs(Object projectIdOrPath, String sha) throws * @throws GitLabApiException GitLabApiException if any exception occurs during execution * @since Gitlab 10.6 */ - public Pager getCommitRefs(Object projectIdOrPath, String sha, int itemsPerPage) throws GitLabApiException { + public Pager getCommitRefs(Object projectIdOrPath, String sha, int itemsPerPage) + throws GitLabApiException { return (getCommitRefs(projectIdOrPath, sha, RefType.ALL, itemsPerPage)); } @@ -420,8 +484,10 @@ public Stream getCommitRefsStream(Object projectIdOrPath, String sha) * @throws GitLabApiException GitLabApiException if any exception occurs during execution * @since Gitlab 10.6 */ - public List getCommitRefs(Object projectIdOrPath, String sha, RefType refType) throws GitLabApiException { - return (getCommitRefs(projectIdOrPath, sha, refType, getDefaultPerPage()).all()); + public List getCommitRefs(Object projectIdOrPath, String sha, RefType refType) + throws GitLabApiException { + return (getCommitRefs(projectIdOrPath, sha, refType, getDefaultPerPage()) + .all()); } /** @@ -437,9 +503,20 @@ public List getCommitRefs(Object projectIdOrPath, String sha, RefType * @throws GitLabApiException GitLabApiException if any exception occurs during execution * @since Gitlab 10.6 */ - public Pager getCommitRefs(Object projectIdOrPath, String sha, CommitRef.RefType refType, int itemsPerPage) throws GitLabApiException { + public Pager getCommitRefs( + Object projectIdOrPath, String sha, CommitRef.RefType refType, int itemsPerPage) throws GitLabApiException { Form form = new GitLabApiForm().withParam("type", refType); - return (new Pager(this, CommitRef.class, itemsPerPage, form.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", urlEncode(sha), "refs")); + return (new Pager( + this, + CommitRef.class, + itemsPerPage, + form.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + urlEncode(sha), + "refs")); } /** @@ -454,7 +531,8 @@ public Pager getCommitRefs(Object projectIdOrPath, String sha, Commit * @throws GitLabApiException GitLabApiException if any exception occurs during execution * @since Gitlab 10.6 */ - public Stream getCommitRefsStream(Object projectIdOrPath, String sha, RefType refType) throws GitLabApiException { + public Stream getCommitRefsStream(Object projectIdOrPath, String sha, RefType refType) + throws GitLabApiException { return (getCommitRefs(projectIdOrPath, sha, refType, getDefaultPerPage()).stream()); } @@ -469,8 +547,10 @@ public Stream getCommitRefsStream(Object projectIdOrPath, String sha, * @return a List containing the commit statuses for the specified project and sha that meet the provided filter * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public List getCommitStatuses(Object projectIdOrPath, String sha, CommitStatusFilter filter) throws GitLabApiException { - return (getCommitStatuses(projectIdOrPath, sha, filter, getDefaultPerPage()).all()); + public List getCommitStatuses(Object projectIdOrPath, String sha, CommitStatusFilter filter) + throws GitLabApiException { + return (getCommitStatuses(projectIdOrPath, sha, filter, getDefaultPerPage()) + .all()); } /** @@ -486,8 +566,9 @@ public List getCommitStatuses(Object projectIdOrPath, String sha, * @return a List containing the commit statuses for the specified project and sha that meet the provided filter * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public List getCommitStatuses(Object projectIdOrPath, String sha, - CommitStatusFilter filter, int page, int perPage) throws GitLabApiException { + public List getCommitStatuses( + Object projectIdOrPath, String sha, CommitStatusFilter filter, int page, int perPage) + throws GitLabApiException { if (projectIdOrPath == null) { throw new RuntimeException("projectIdOrPath cannot be null"); @@ -497,10 +578,17 @@ public List getCommitStatuses(Object projectIdOrPath, String sha, throw new RuntimeException("sha cannot be null"); } - MultivaluedMap queryParams = (filter != null ? - filter.getQueryParams(page, perPage).asMap() : getPageQueryParams(page, perPage)); - Response response = get(Response.Status.OK, queryParams, - "projects", this.getProjectIdOrPath(projectIdOrPath), "repository", "commits", sha, "statuses"); + MultivaluedMap queryParams = + (filter != null ? filter.getQueryParams(page, perPage).asMap() : getPageQueryParams(page, perPage)); + Response response = get( + Response.Status.OK, + queryParams, + "projects", + this.getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + sha, + "statuses"); return (response.readEntity(new GenericType>() {})); } @@ -516,8 +604,8 @@ public List getCommitStatuses(Object projectIdOrPath, String sha, * @return a Pager containing the commit statuses for the specified project and sha that meet the provided filter * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public Pager getCommitStatuses(Object projectIdOrPath, String sha, - CommitStatusFilter filter, int itemsPerPage) throws GitLabApiException { + public Pager getCommitStatuses( + Object projectIdOrPath, String sha, CommitStatusFilter filter, int itemsPerPage) throws GitLabApiException { if (projectIdOrPath == null) { throw new RuntimeException("projectIdOrPath cannot be null"); @@ -527,9 +615,19 @@ public Pager getCommitStatuses(Object projectIdOrPath, String sha, throw new RuntimeException("sha cannot be null"); } - MultivaluedMap queryParams = (filter != null ? filter.getQueryParams().asMap() : null); - return (new Pager(this, CommitStatus.class, itemsPerPage, queryParams, - "projects", this.getProjectIdOrPath(projectIdOrPath), "repository", "commits", sha, "statuses")); + MultivaluedMap queryParams = + (filter != null ? filter.getQueryParams().asMap() : null); + return (new Pager( + this, + CommitStatus.class, + itemsPerPage, + queryParams, + "projects", + this.getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + sha, + "statuses")); } /** @@ -543,7 +641,8 @@ public Pager getCommitStatuses(Object projectIdOrPath, String sha, * @return a Stream containing the commit statuses for the specified project and sha that meet the provided filter * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public Stream getCommitStatusesStream(Object projectIdOrPath, String sha, CommitStatusFilter filter) throws GitLabApiException { + public Stream getCommitStatusesStream(Object projectIdOrPath, String sha, CommitStatusFilter filter) + throws GitLabApiException { return (getCommitStatuses(projectIdOrPath, sha, filter, getDefaultPerPage()).stream()); } @@ -567,7 +666,8 @@ public Stream getCommitStatusesStream(Object projectIdOrPath, Stri * @return a CommitStatus instance with the updated info * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBuildState state, CommitStatus status) throws GitLabApiException { + public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBuildState state, CommitStatus status) + throws GitLabApiException { return addCommitStatus(projectIdOrPath, sha, state, null, status); } @@ -594,7 +694,9 @@ public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBu * @deprecated use {@link #addCommitStatus(Object, String, org.gitlab4j.api.Constants.CommitBuildState, CommitStatus)} and set the pipelineId value in the {@link CommitStatus} parameter */ @Deprecated - public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBuildState state, Long pipelineId, CommitStatus status) throws GitLabApiException { + public CommitStatus addCommitStatus( + Object projectIdOrPath, String sha, CommitBuildState state, Long pipelineId, CommitStatus status) + throws GitLabApiException { if (projectIdOrPath == null) { throw new RuntimeException("projectIdOrPath cannot be null"); @@ -607,13 +709,16 @@ public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBu GitLabApiForm formData = new GitLabApiForm().withParam("state", state, true); if (status != null) { formData.withParam("ref", status.getRef()) - .withParam("name", status.getName()) - .withParam("target_url", status.getTargetUrl()) - .withParam("description", status.getDescription()) - .withParam("coverage", status.getCoverage()) - .withParam("pipeline_id", status.getPipelineId()); - if (pipelineId != null && status.getPipelineId() != null && !Objects.equals(status.getPipelineId(), pipelineId)) { - throw new IllegalArgumentException("The parameter 'pipelineId' and the pipelineId value the 'status' parameter are different. Set the two values to be the same or one of the two values to null."); + .withParam("name", status.getName()) + .withParam("target_url", status.getTargetUrl()) + .withParam("description", status.getDescription()) + .withParam("coverage", status.getCoverage()) + .withParam("pipeline_id", status.getPipelineId()); + if (pipelineId != null + && status.getPipelineId() != null + && !Objects.equals(status.getPipelineId(), pipelineId)) { + throw new IllegalArgumentException( + "The parameter 'pipelineId' and the pipelineId value the 'status' parameter are different. Set the two values to be the same or one of the two values to null."); } } @@ -621,7 +726,8 @@ public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBu formData.withParam("pipeline_id", pipelineId); } - Response response = post(Response.Status.OK, formData, "projects", getProjectIdOrPath(projectIdOrPath), "statuses", sha); + Response response = + post(Response.Status.OK, formData, "projects", getProjectIdOrPath(projectIdOrPath), "statuses", sha); return (response.readEntity(CommitStatus.class)); } @@ -640,7 +746,7 @@ public List getDiff(Object projectIdOrPath, String sha) throws GitLabApiEx } /** - * Get the Pager of diffs of a commit in a project. + * Get the Pager of diffs of a commit in a project. * *
GitLab Endpoint: GET /projects/:id/repository/commits/:sha/diff
* @@ -660,12 +766,21 @@ public Pager getDiff(Object projectIdOrPath, String sha, int itemsPerPage) throw new RuntimeException("sha cannot be null"); } - return (new Pager(this, Diff.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", sha, "diff")); + return (new Pager( + this, + Diff.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + sha, + "diff")); } /** - * Get the Diff of diffs of a commit in a project. + * Get the Diff of diffs of a commit in a project. * *
GitLab Endpoint: GET /projects/:id/repository/commits/:sha/diff
* @@ -704,7 +819,17 @@ public List getComments(Object projectIdOrPath, String sha) throws GitL * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ public Pager getComments(Object projectIdOrPath, String sha, int itemsPerPage) throws GitLabApiException { - return new Pager(this, Comment.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", sha, "comments"); + return new Pager( + this, + Comment.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + sha, + "comments"); } /** @@ -736,13 +861,23 @@ public Stream getCommentsStream(Object projectIdOrPath, String sha) thr * @return a Comment instance for the posted comment * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public Comment addComment(Object projectIdOrPath, String sha, String note, String path, Integer line, LineType lineType) throws GitLabApiException { + public Comment addComment( + Object projectIdOrPath, String sha, String note, String path, Integer line, LineType lineType) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("note", note, true) .withParam("path", path) .withParam("line", line) .withParam("line_type", lineType); - Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", sha, "comments"); + Response response = post( + Response.Status.CREATED, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + sha, + "comments"); return (response.readEntity(Comment.class)); } @@ -776,16 +911,23 @@ public Comment addComment(Object projectIdOrPath, String sha, String note) throw * @return the created Commit instance * @throws GitLabApiException if any exception occurs during execution */ - public Commit createCommit(Object projectIdOrPath, String branch, String commitMessage, String startBranch, - String authorEmail, String authorName, CommitAction action) throws GitLabApiException { + public Commit createCommit( + Object projectIdOrPath, + String branch, + String commitMessage, + String startBranch, + String authorEmail, + String authorName, + CommitAction action) + throws GitLabApiException { // Validate the action if (action == null) { throw new GitLabApiException("action cannot be null or empty."); } - return (createCommit(projectIdOrPath, branch, commitMessage, startBranch, - authorEmail, authorName, Arrays.asList(action))); + return (createCommit( + projectIdOrPath, branch, commitMessage, startBranch, authorEmail, authorName, Arrays.asList(action))); } /** @@ -803,8 +945,15 @@ public Commit createCommit(Object projectIdOrPath, String branch, String commitM * @return the created Commit instance * @throws GitLabApiException if any exception occurs during execution */ - public Commit createCommit(Object projectIdOrPath, String branch, String commitMessage, String startBranch, - String authorEmail, String authorName, List actions) throws GitLabApiException { + public Commit createCommit( + Object projectIdOrPath, + String branch, + String commitMessage, + String startBranch, + String authorEmail, + String authorName, + List actions) + throws GitLabApiException { CommitPayload payload = new CommitPayload() .withBranch(branch) @@ -829,7 +978,7 @@ public Commit createCommit(Object projectIdOrPath, String branch, String commitM public Commit createCommit(Object projectIdOrPath, CommitPayload payload) throws GitLabApiException { // Validate the actions - List actions = payload.getActions(); + List actions = payload.getActions(); if (actions == null || actions.isEmpty()) { throw new GitLabApiException("actions cannot be null or empty."); } @@ -850,8 +999,13 @@ public Commit createCommit(Object projectIdOrPath, CommitPayload payload) throws payload.setStartProject(getProjectIdOrPath(payload.getStartProject())); } - Response response = post(Response.Status.CREATED, payload, - "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits"); + Response response = post( + Response.Status.CREATED, + payload, + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits"); return (response.readEntity(Commit.class)); } @@ -869,8 +1023,15 @@ public Commit createCommit(Object projectIdOrPath, CommitPayload payload) throws */ public Commit revertCommit(Object projectIdOrPath, String sha, String branch) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm().withParam("branch", branch, true); - Response response = post(Response.Status.CREATED, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", sha, "revert"); + Response response = post( + Response.Status.CREATED, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + sha, + "revert"); return (response.readEntity(Commit.class)); } @@ -888,8 +1049,15 @@ public Commit revertCommit(Object projectIdOrPath, String sha, String branch) th */ public Commit cherryPickCommit(Object projectIdOrPath, String sha, String branch) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm().withParam("branch", branch, true); - Response response = post(Response.Status.CREATED, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", sha, "cherry_pick"); + Response response = post( + Response.Status.CREATED, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + sha, + "cherry_pick"); return (response.readEntity(Commit.class)); } @@ -918,9 +1086,19 @@ public List getMergeRequests(Object projectIdOrPath, String sha) t * @return a Pager containing the MergeRequest instances for the specified project/SHA * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public Pager getMergeRequests(Object projectIdOrPath, String sha, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, MergeRequest.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", urlEncode(sha), "merge_requests")); + public Pager getMergeRequests(Object projectIdOrPath, String sha, int itemsPerPage) + throws GitLabApiException { + return (new Pager( + this, + MergeRequest.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + urlEncode(sha), + "merge_requests")); } /** @@ -948,8 +1126,15 @@ public Stream getMergeRequestsStream(Object projectIdOrPath, Strin * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ public GpgSignature getGpgSignature(Object projectIdOrPath, String sha) throws GitLabApiException { - Response response = get(Response.Status.OK, getDefaultPerPageParam(), - "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", urlEncode(sha), "signature"); + Response response = get( + Response.Status.OK, + getDefaultPerPageParam(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + urlEncode(sha), + "signature"); return (response.readEntity(GpgSignature.class)); } diff --git a/src/main/java/org/gitlab4j/api/Constants.java b/src/main/java/org/gitlab4j/api/Constants.java index 117b7dae8..604dd3fe5 100644 --- a/src/main/java/org/gitlab4j/api/Constants.java +++ b/src/main/java/org/gitlab4j/api/Constants.java @@ -1,1123 +1,1282 @@ -package org.gitlab4j.api; - -import java.util.HashMap; -import java.util.Map; - -import org.gitlab4j.api.utils.JacksonJsonEnumHelper; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public interface Constants { - - /** The total number of items HTTP header key. */ - public static final String TOTAL_HEADER = "X-Total"; - - /** The total number of pages HTTP header key. */ - public static final String TOTAL_PAGES_HEADER = "X-Total-Pages"; - - /** The number of items per page HTTP header key. */ - public static final String PER_PAGE = "X-Per-Page"; - - /** The index of the current page (starting at 1) HTTP header key. */ - public static final String PAGE_HEADER = "X-Page"; - - /** The index of the next page HTTP header key. */ - public static final String NEXT_PAGE_HEADER = "X-Next-Page"; - - /** The index of the previous page HTTP header key. */ - public static final String PREV_PAGE_HEADER = "X-Prev-Page"; - - /** Items per page param HTTP header key. */ - public static final String PER_PAGE_PARAM = "per_page"; - - /** Page param HTTP header key. */ - public static final String PAGE_PARAM = "page"; - - /** Used to specify the type of authentication token. */ - public enum TokenType { - ACCESS, OAUTH2_ACCESS, PRIVATE; - } - - /** Enum to specify encoding of file contents. */ - public enum Encoding { - TEXT, BASE64; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(Encoding.class); - - @JsonCreator - public static Encoding forValue(String value) { - return enumHelper.forValue((value != null ? value.toLowerCase() : value)); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for ordering the results of various API calls. */ - public enum SortOrder { - - ASC, DESC; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(SortOrder.class); - - @JsonCreator - public static SortOrder forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - - /** Enum to use for ordering the results of getEpics(). */ - public enum EpicOrderBy { - - CREATED_AT, UPDATED_AT; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(EpicOrderBy.class); - - @JsonCreator - public static EpicOrderBy forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for ordering the results of getIssues(). */ - public enum IssueOrderBy { - - CREATED_AT, UPDATED_AT; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(IssueOrderBy.class); - - @JsonCreator - public static IssueOrderBy forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for ordering the results of getPackages(). */ - public enum PackageOrderBy { - - NAME, CREATED_AT, VERSION, TYPE, PROJECT_PATH; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(PackageOrderBy.class); - - @JsonCreator - public static PackageOrderBy forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for filtering the results of getPackages(). */ - public enum PackageStatus { - - DEFAULT, HIDDEN, PROCESSING; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(PackageStatus.class); - - @JsonCreator - public static PackageStatus forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for ordering the results of getProjects(). */ - public enum ProjectOrderBy { - - ID, NAME, PATH, CREATED_AT, UPDATED_AT, LAST_ACTIVITY_AT; - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(ProjectOrderBy.class); - - @JsonCreator - public static ProjectOrderBy forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for ordering the results of getPipelines(). */ - public enum PipelineOrderBy { - - ID, STATUS, REF, UPDATED_AT, USER_ID; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(PipelineOrderBy.class); - - @JsonCreator - public static PipelineOrderBy forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for ordering the results of getMergeRequests(). */ - public enum MergeRequestOrderBy { - - CREATED_AT, UPDATED_AT; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(MergeRequestOrderBy.class); - - @JsonCreator - public static MergeRequestOrderBy forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for ordering the results of getGroups() and getSubGroups(). */ - public enum GroupOrderBy { - - NAME, PATH, ID, SIMILARITY; - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(GroupOrderBy.class); - - @JsonCreator - public static GroupOrderBy forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for ordering the results of getTags(). */ - public enum TagOrderBy { - - NAME, UPDATED; - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(TagOrderBy.class); - - @JsonCreator - public static TagOrderBy forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for ordering the results of getDeployments. */ - public static enum DeploymentOrderBy { - - ID, IID, CREATED_AT, UPDATED_AT, REF; - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(DeploymentOrderBy.class); - - @JsonCreator - public static DeploymentOrderBy forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for ordering the results of getContibutors(). */ - public enum ContributorOrderBy { - - NAME, EMAIL, COMMITS; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(ContributorOrderBy.class); - - @JsonCreator - public static ContributorOrderBy forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the scope when calling getPipelines(). */ - public enum PipelineScope { - - RUNNING, PENDING, FINISHED, BRANCHES, TAGS; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(PipelineScope.class); - - @JsonCreator - public static PipelineScope forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the source when calling getPipelines(). */ - public enum PipelineSource { - - PUSH, WEB, TRIGGER, SCHEDULE, API, EXTERNAL, PIPELINE, CHAT, WEBIDE, MERGE_REQUEST_EVENT, EXTERNAL_PULL_REQUEST_EVENT; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(PipelineSource.class); - - @JsonCreator - public static PipelineSource forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the scope when calling getJobs(). */ - public enum JobScope { - - CREATED, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(JobScope.class); - - @JsonCreator - public static JobScope forValue(String value) { return enumHelper.forValue(value); } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the scope when calling the various get issue methods. */ - public enum IssueScope { - - CREATED_BY_ME, ASSIGNED_TO_ME, ALL; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(IssueScope.class); - - @JsonCreator - public static IssueScope forValue(String value) { return enumHelper.forValue(value); } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the scope for getMergeRequests methods. */ - public enum MergeRequestScope { - - CREATED_BY_ME, ASSIGNED_TO_ME, ALL; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(MergeRequestScope.class); - - @JsonCreator - public static MergeRequestScope forValue(String value) { return enumHelper.forValue(value); } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for querying the state of a MergeRequest */ - public enum MergeRequestState { - - OPENED, CLOSED, LOCKED, MERGED, ALL; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(MergeRequestState.class); - - @JsonCreator - public static MergeRequestState forValue(String value) { return enumHelper.forValue(value); } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the scope of the search attribute when calling getMergeRequests(). */ - public enum MergeRequestSearchIn { - - TITLE, DESCRIPTION; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(MergeRequestSearchIn.class); - - @JsonCreator - public static MergeRequestSearchIn forValue(String value) { return enumHelper.forValue(value); } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the state of a merge request or issue update. */ - public enum StateEvent { - - CLOSE, REOPEN; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(StateEvent.class); - - @JsonCreator - public static StateEvent forValue(String value) { return enumHelper.forValue(value); } - - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to used to store the state of an issue. */ - public enum IssueState { - - OPENED, CLOSED, REOPENED; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(IssueState.class); - - @JsonCreator - public static IssueState forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - public enum MilestoneState { - - ACTIVE, CLOSED, ACTIVATE, CLOSE; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(MilestoneState.class); - - @JsonCreator - public static MilestoneState forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the event action_type. */ - public enum ActionType { - - CREATED, UPDATED, OPENED, CLOSED, REOPENED, PUSHED, COMMENTED, MERGED, JOINED, LEFT, DESTROYED, EXPIRED, REMOVED, DELETED, APPROVED, ACCEPTED, IMPORTED; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(ActionType.class); - - @JsonCreator - public static ActionType forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the event target_type. */ - public enum TargetType { - - ISSUE, MILESTONE, MERGE_REQUEST, NOTE, PROJECT, SNIPPET, USER; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(TargetType.class, true, false, true); - - @JsonCreator - public static TargetType forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the line type for a commit comment. */ - public enum LineType { - - OLD, NEW; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(LineType.class); - - @JsonCreator - public static LineType forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to specify the state of an ImpersonationToken. */ - public enum ImpersonationState { - - ALL, ACTIVE, INACTIVE; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(ImpersonationState.class); - - @JsonCreator - public static ImpersonationState forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to specify the format of a downloaded archive. */ - public enum ArchiveFormat { - - BZ2, TAR, TAR_BZ2, TAR_GZ, TB2, TBZ, TBZ2, ZIP; - - private final String value; - - ArchiveFormat() { - this.value = name().toLowerCase().replace('_', '.'); - } - - private static Map valuesMap = new HashMap(8); - static { - for (ArchiveFormat archiveFormat : ArchiveFormat.values()) - valuesMap.put(archiveFormat.value, archiveFormat); - } - - public static ArchiveFormat forValue(String value) throws GitLabApiException { - - if (value == null || value.trim().isEmpty()) { - return (null); - } - - ArchiveFormat archiveFormat = valuesMap.get(value); - if (archiveFormat != null) { - return (archiveFormat); - } - - throw new GitLabApiException("Invalid format! Options are tar.gz, tar.bz2, tbz, tbz2, tb2, bz2, tar, and zip."); - } - - @Override - public String toString() { - return (value); - } - } - - /** - * Enum for the various Commit build status values. - */ - public enum CommitBuildState { - - PENDING, RUNNING, SUCCESS, FAILED, CANCELED, SKIPPED; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(CommitBuildState.class); - - @JsonCreator - public static CommitBuildState forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** - * Enum for the various Application scope values. - */ - public enum ApplicationScope { - - /** Access the authenticated user's API */ - API, - - /** Read the authenticated user's personal information */ - READ_USER, - - /** Perform API actions as any user in the system */ - SUDO, - - /** Allows read-access to the repository */ - READ_REPOSITORY, - - /** Authenticate using OpenID Connect */ - OPENID, - - /** Allows read-only access to the user's personal information using OpenID Connect */ - PROFILE, - - /** Allows read-only access to the user's primary email address using OpenID Connect */ - EMAIL; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(ApplicationScope.class); - - @JsonCreator - public static ApplicationScope forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** - * Enum for the search scope when doing a globalSearch() with the SearchApi. - */ - public enum SearchScope { - - PROJECTS, ISSUES, MERGE_REQUESTS, MILESTONES, SNIPPET_TITLES, SNIPPET_BLOBS, USERS, - BLOBS, COMMITS, WIKI_BLOBS; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(SearchScope.class); - - @JsonCreator - public static SearchScope forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** - * Enum for the search scope when doing a groupSearch() with the SearchApi. - */ - public enum GroupSearchScope { - - PROJECTS, ISSUES, MERGE_REQUESTS, MILESTONES, WIKI_BLOBS, COMMITS, BLOBS, NOTES, USERS; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(GroupSearchScope.class); - - @JsonCreator - public static GroupSearchScope forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** - * Enum for the search scope when doing a projectSearch() with the SearchApi. - */ - public enum ProjectSearchScope { - - BLOBS, COMMITS, ISSUES, MERGE_REQUESTS, MILESTONES, NOTES, WIKI_BLOBS, USERS; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(ProjectSearchScope.class); - - @JsonCreator - public static ProjectSearchScope forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the action when doing a getTodos() with the TodosApi. */ - public enum TodoAction { - - ASSIGNED, MENTIONED, BUILD_FAILED, MARKED, APPROVAL_REQUIRED, UNMERGEABLE, DIRECTLY_ADDRESSED; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(TodoAction.class); - - @JsonCreator - public static TodoAction forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the state when doing a getTodos() with the TodosApi. */ - public enum TodoState { - - PENDING, DONE; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(TodoState.class); - - @JsonCreator - public static TodoState forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the type when doing a getTodos() with the TodosApi. */ - public enum TodoType { - - ISSUE, MERGE_REQUEST; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(TodoType.class, true, true); - - @JsonCreator - public static TodoType forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the status of a deployment. */ - public enum DeploymentStatus { - /** - * After some tests, {@link #CREATED} value is not a valid value. - */ - CREATED, RUNNING, SUCCESS, FAILED, CANCELED; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(DeploymentStatus.class); - - @JsonCreator - public static DeploymentStatus forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the deploy token scope. */ - public enum DeployTokenScope { - READ_REPOSITORY, READ_REGISTRY; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(DeployTokenScope.class); - - @JsonCreator - public static DeployTokenScope forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the project token scope. */ - public enum ProjectAccessTokenScope { - API, READ_API, READ_REGISTRY, WRITE_REGISTRY, READ_REPOSITORY, WRITE_REPOSITORY, CREATE_RUNNER; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(ProjectAccessTokenScope.class); - - @JsonCreator - public static ProjectAccessTokenScope forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum for the build_git_strategy of the project instance. */ - enum SquashOption { - - NEVER, ALWAYS, DEFAULT_ON, DEFAULT_OFF; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(SquashOption.class); - - @JsonCreator - public static SquashOption forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum for the build_git_strategy of the project instance. */ - enum BuildGitStrategy { - - FETCH, CLONE; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(BuildGitStrategy.class); - - @JsonCreator - public static BuildGitStrategy forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - enum AutoDevopsDeployStrategy { - CONTINUOUS, MANUAL, TIMED_INCREMENTAL; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(AutoDevopsDeployStrategy.class); - - @JsonCreator - public static AutoDevopsDeployStrategy forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** Enum to use for specifying the Event scope. */ - public enum EventScope { - ALL; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(EventScope.class); - - @JsonCreator - public static EventScope forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** - * Constant to specify the project_creation_level for the group. - */ - public enum ProjectCreationLevel { - NOONE, DEVELOPER, MAINTAINER; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(ProjectCreationLevel.class); - - @JsonCreator - public static ProjectCreationLevel forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - /** - * Constant to specify the subgroup_creation_level for the group. - */ - public enum SubgroupCreationLevel { - OWNER, MAINTAINER; - - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(SubgroupCreationLevel.class); - - @JsonCreator - public static SubgroupCreationLevel forValue(String value) { - return enumHelper.forValue(value); - } - - @JsonValue - public String toValue() { - return (enumHelper.toString(this)); - } - - @Override - public String toString() { - return (enumHelper.toString(this)); - } - } - - public enum DefaultBranchProtectionLevel { - NOT_PROTECTED(0), - PARTIALLY_PROTECTED(1), - FULLY_PROTECTED(2), - PROTECTED_AGAINST_PUSHES(3), - FULL_PROTECTION_AFTER_INITIAL_PUSH(4); - - @JsonValue - private final int value; - - private DefaultBranchProtectionLevel(int value) { - this.value = value; - } - - @Override - public String toString() { - return Integer.toString(value); - } - } -} +package org.gitlab4j.api; + +import java.util.HashMap; +import java.util.Map; + +import org.gitlab4j.api.utils.JacksonJsonEnumHelper; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public interface Constants { + + /** The total number of items HTTP header key. */ + public static final String TOTAL_HEADER = "X-Total"; + + /** The total number of pages HTTP header key. */ + public static final String TOTAL_PAGES_HEADER = "X-Total-Pages"; + + /** The number of items per page HTTP header key. */ + public static final String PER_PAGE = "X-Per-Page"; + + /** The index of the current page (starting at 1) HTTP header key. */ + public static final String PAGE_HEADER = "X-Page"; + + /** The index of the next page HTTP header key. */ + public static final String NEXT_PAGE_HEADER = "X-Next-Page"; + + /** The index of the previous page HTTP header key. */ + public static final String PREV_PAGE_HEADER = "X-Prev-Page"; + + /** Items per page param HTTP header key. */ + public static final String PER_PAGE_PARAM = "per_page"; + + /** Page param HTTP header key. */ + public static final String PAGE_PARAM = "page"; + + /** Used to specify the type of authentication token. */ + public enum TokenType { + ACCESS, + OAUTH2_ACCESS, + PRIVATE; + } + + /** Enum to specify encoding of file contents. */ + public enum Encoding { + TEXT, + BASE64; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(Encoding.class); + + @JsonCreator + public static Encoding forValue(String value) { + return enumHelper.forValue((value != null ? value.toLowerCase() : value)); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for ordering the results of various API calls. */ + public enum SortOrder { + ASC, + DESC; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(SortOrder.class); + + @JsonCreator + public static SortOrder forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for ordering the results of getEpics(). */ + public enum EpicOrderBy { + CREATED_AT, + UPDATED_AT; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(EpicOrderBy.class); + + @JsonCreator + public static EpicOrderBy forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for ordering the results of getIssues(). */ + public enum IssueOrderBy { + CREATED_AT, + UPDATED_AT; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(IssueOrderBy.class); + + @JsonCreator + public static IssueOrderBy forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for ordering the results of getPackages(). */ + public enum PackageOrderBy { + NAME, + CREATED_AT, + VERSION, + TYPE, + PROJECT_PATH; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(PackageOrderBy.class); + + @JsonCreator + public static PackageOrderBy forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for filtering the results of getPackages(). */ + public enum PackageStatus { + DEFAULT, + HIDDEN, + PROCESSING; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(PackageStatus.class); + + @JsonCreator + public static PackageStatus forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for ordering the results of getProjects(). */ + public enum ProjectOrderBy { + ID, + NAME, + PATH, + CREATED_AT, + UPDATED_AT, + LAST_ACTIVITY_AT; + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(ProjectOrderBy.class); + + @JsonCreator + public static ProjectOrderBy forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for ordering the results of getPipelines(). */ + public enum PipelineOrderBy { + ID, + STATUS, + REF, + UPDATED_AT, + USER_ID; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(PipelineOrderBy.class); + + @JsonCreator + public static PipelineOrderBy forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for ordering the results of getMergeRequests(). */ + public enum MergeRequestOrderBy { + CREATED_AT, + UPDATED_AT; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(MergeRequestOrderBy.class); + + @JsonCreator + public static MergeRequestOrderBy forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for ordering the results of getGroups() and getSubGroups(). */ + public enum GroupOrderBy { + NAME, + PATH, + ID, + SIMILARITY; + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(GroupOrderBy.class); + + @JsonCreator + public static GroupOrderBy forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for ordering the results of getTags(). */ + public enum TagOrderBy { + NAME, + UPDATED; + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(TagOrderBy.class); + + @JsonCreator + public static TagOrderBy forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for ordering the results of getDeployments. */ + public static enum DeploymentOrderBy { + ID, + IID, + CREATED_AT, + UPDATED_AT, + REF; + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(DeploymentOrderBy.class); + + @JsonCreator + public static DeploymentOrderBy forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for ordering the results of getContibutors(). */ + public enum ContributorOrderBy { + NAME, + EMAIL, + COMMITS; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(ContributorOrderBy.class); + + @JsonCreator + public static ContributorOrderBy forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the scope when calling getPipelines(). */ + public enum PipelineScope { + RUNNING, + PENDING, + FINISHED, + BRANCHES, + TAGS; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(PipelineScope.class); + + @JsonCreator + public static PipelineScope forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the source when calling getPipelines(). */ + public enum PipelineSource { + PUSH, + WEB, + TRIGGER, + SCHEDULE, + API, + EXTERNAL, + PIPELINE, + CHAT, + WEBIDE, + MERGE_REQUEST_EVENT, + EXTERNAL_PULL_REQUEST_EVENT; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(PipelineSource.class); + + @JsonCreator + public static PipelineSource forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the scope when calling getJobs(). */ + public enum JobScope { + CREATED, + PENDING, + RUNNING, + FAILED, + SUCCESS, + CANCELED, + SKIPPED, + MANUAL; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(JobScope.class); + + @JsonCreator + public static JobScope forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the scope when calling the various get issue methods. */ + public enum IssueScope { + CREATED_BY_ME, + ASSIGNED_TO_ME, + ALL; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(IssueScope.class); + + @JsonCreator + public static IssueScope forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the scope for getMergeRequests methods. */ + public enum MergeRequestScope { + CREATED_BY_ME, + ASSIGNED_TO_ME, + ALL; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(MergeRequestScope.class); + + @JsonCreator + public static MergeRequestScope forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for querying the state of a MergeRequest */ + public enum MergeRequestState { + OPENED, + CLOSED, + LOCKED, + MERGED, + ALL; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(MergeRequestState.class); + + @JsonCreator + public static MergeRequestState forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the scope of the search attribute when calling getMergeRequests(). */ + public enum MergeRequestSearchIn { + TITLE, + DESCRIPTION; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(MergeRequestSearchIn.class); + + @JsonCreator + public static MergeRequestSearchIn forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the state of a merge request or issue update. */ + public enum StateEvent { + CLOSE, + REOPEN; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(StateEvent.class); + + @JsonCreator + public static StateEvent forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to used to store the state of an issue. */ + public enum IssueState { + OPENED, + CLOSED, + REOPENED; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(IssueState.class); + + @JsonCreator + public static IssueState forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + public enum MilestoneState { + ACTIVE, + CLOSED, + ACTIVATE, + CLOSE; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(MilestoneState.class); + + @JsonCreator + public static MilestoneState forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the event action_type. */ + public enum ActionType { + CREATED, + UPDATED, + OPENED, + CLOSED, + REOPENED, + PUSHED, + COMMENTED, + MERGED, + JOINED, + LEFT, + DESTROYED, + EXPIRED, + REMOVED, + DELETED, + APPROVED, + ACCEPTED, + IMPORTED; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(ActionType.class); + + @JsonCreator + public static ActionType forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the event target_type. */ + public enum TargetType { + ISSUE, + MILESTONE, + MERGE_REQUEST, + NOTE, + PROJECT, + SNIPPET, + USER; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(TargetType.class, true, false, true); + + @JsonCreator + public static TargetType forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the line type for a commit comment. */ + public enum LineType { + OLD, + NEW; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(LineType.class); + + @JsonCreator + public static LineType forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to specify the state of an ImpersonationToken. */ + public enum ImpersonationState { + ALL, + ACTIVE, + INACTIVE; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(ImpersonationState.class); + + @JsonCreator + public static ImpersonationState forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to specify the format of a downloaded archive. */ + public enum ArchiveFormat { + BZ2, + TAR, + TAR_BZ2, + TAR_GZ, + TB2, + TBZ, + TBZ2, + ZIP; + + private final String value; + + ArchiveFormat() { + this.value = name().toLowerCase().replace('_', '.'); + } + + private static Map valuesMap = new HashMap(8); + + static { + for (ArchiveFormat archiveFormat : ArchiveFormat.values()) + valuesMap.put(archiveFormat.value, archiveFormat); + } + + public static ArchiveFormat forValue(String value) throws GitLabApiException { + + if (value == null || value.trim().isEmpty()) { + return (null); + } + + ArchiveFormat archiveFormat = valuesMap.get(value); + if (archiveFormat != null) { + return (archiveFormat); + } + + throw new GitLabApiException( + "Invalid format! Options are tar.gz, tar.bz2, tbz, tbz2, tb2, bz2, tar, and zip."); + } + + @Override + public String toString() { + return (value); + } + } + + /** + * Enum for the various Commit build status values. + */ + public enum CommitBuildState { + PENDING, + RUNNING, + SUCCESS, + FAILED, + CANCELED, + SKIPPED; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(CommitBuildState.class); + + @JsonCreator + public static CommitBuildState forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** + * Enum for the various Application scope values. + */ + public enum ApplicationScope { + + /** Access the authenticated user's API */ + API, + + /** Read the authenticated user's personal information */ + READ_USER, + + /** Perform API actions as any user in the system */ + SUDO, + + /** Allows read-access to the repository */ + READ_REPOSITORY, + + /** Authenticate using OpenID Connect */ + OPENID, + + /** Allows read-only access to the user's personal information using OpenID Connect */ + PROFILE, + + /** Allows read-only access to the user's primary email address using OpenID Connect */ + EMAIL; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(ApplicationScope.class); + + @JsonCreator + public static ApplicationScope forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** + * Enum for the search scope when doing a globalSearch() with the SearchApi. + */ + public enum SearchScope { + PROJECTS, + ISSUES, + MERGE_REQUESTS, + MILESTONES, + SNIPPET_TITLES, + SNIPPET_BLOBS, + USERS, + BLOBS, + COMMITS, + WIKI_BLOBS; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(SearchScope.class); + + @JsonCreator + public static SearchScope forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** + * Enum for the search scope when doing a groupSearch() with the SearchApi. + */ + public enum GroupSearchScope { + PROJECTS, + ISSUES, + MERGE_REQUESTS, + MILESTONES, + WIKI_BLOBS, + COMMITS, + BLOBS, + NOTES, + USERS; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(GroupSearchScope.class); + + @JsonCreator + public static GroupSearchScope forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** + * Enum for the search scope when doing a projectSearch() with the SearchApi. + */ + public enum ProjectSearchScope { + BLOBS, + COMMITS, + ISSUES, + MERGE_REQUESTS, + MILESTONES, + NOTES, + WIKI_BLOBS, + USERS; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(ProjectSearchScope.class); + + @JsonCreator + public static ProjectSearchScope forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the action when doing a getTodos() with the TodosApi. */ + public enum TodoAction { + ASSIGNED, + MENTIONED, + BUILD_FAILED, + MARKED, + APPROVAL_REQUIRED, + UNMERGEABLE, + DIRECTLY_ADDRESSED; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(TodoAction.class); + + @JsonCreator + public static TodoAction forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the state when doing a getTodos() with the TodosApi. */ + public enum TodoState { + PENDING, + DONE; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(TodoState.class); + + @JsonCreator + public static TodoState forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the type when doing a getTodos() with the TodosApi. */ + public enum TodoType { + ISSUE, + MERGE_REQUEST; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(TodoType.class, true, true); + + @JsonCreator + public static TodoType forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the status of a deployment. */ + public enum DeploymentStatus { + /** + * After some tests, {@link #CREATED} value is not a valid value. + */ + CREATED, + RUNNING, + SUCCESS, + FAILED, + CANCELED; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(DeploymentStatus.class); + + @JsonCreator + public static DeploymentStatus forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the deploy token scope. */ + public enum DeployTokenScope { + READ_REPOSITORY, + READ_REGISTRY; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(DeployTokenScope.class); + + @JsonCreator + public static DeployTokenScope forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the project token scope. */ + public enum ProjectAccessTokenScope { + API, + READ_API, + READ_REGISTRY, + WRITE_REGISTRY, + READ_REPOSITORY, + WRITE_REPOSITORY, + CREATE_RUNNER; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(ProjectAccessTokenScope.class); + + @JsonCreator + public static ProjectAccessTokenScope forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum for the build_git_strategy of the project instance. */ + enum SquashOption { + NEVER, + ALWAYS, + DEFAULT_ON, + DEFAULT_OFF; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(SquashOption.class); + + @JsonCreator + public static SquashOption forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum for the build_git_strategy of the project instance. */ + enum BuildGitStrategy { + FETCH, + CLONE; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(BuildGitStrategy.class); + + @JsonCreator + public static BuildGitStrategy forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + enum AutoDevopsDeployStrategy { + CONTINUOUS, + MANUAL, + TIMED_INCREMENTAL; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(AutoDevopsDeployStrategy.class); + + @JsonCreator + public static AutoDevopsDeployStrategy forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** Enum to use for specifying the Event scope. */ + public enum EventScope { + ALL; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(EventScope.class); + + @JsonCreator + public static EventScope forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** + * Constant to specify the project_creation_level for the group. + */ + public enum ProjectCreationLevel { + NOONE, + DEVELOPER, + MAINTAINER; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(ProjectCreationLevel.class); + + @JsonCreator + public static ProjectCreationLevel forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + /** + * Constant to specify the subgroup_creation_level for the group. + */ + public enum SubgroupCreationLevel { + OWNER, + MAINTAINER; + + private static JacksonJsonEnumHelper enumHelper = + new JacksonJsonEnumHelper<>(SubgroupCreationLevel.class); + + @JsonCreator + public static SubgroupCreationLevel forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + public enum DefaultBranchProtectionLevel { + NOT_PROTECTED(0), + PARTIALLY_PROTECTED(1), + FULLY_PROTECTED(2), + PROTECTED_AGAINST_PUSHES(3), + FULL_PROTECTION_AFTER_INITIAL_PUSH(4); + + @JsonValue + private final int value; + + private DefaultBranchProtectionLevel(int value) { + this.value = value; + } + + @Override + public String toString() { + return Integer.toString(value); + } + } +} diff --git a/src/main/java/org/gitlab4j/api/ContainerRegistryApi.java b/src/main/java/org/gitlab4j/api/ContainerRegistryApi.java index 87fc62892..ab3454f07 100644 --- a/src/main/java/org/gitlab4j/api/ContainerRegistryApi.java +++ b/src/main/java/org/gitlab4j/api/ContainerRegistryApi.java @@ -68,11 +68,16 @@ public List getRepositories(Object projectIdOrPath) throws G * @return a list of registry repositories for the specified range * @throws GitLabApiException if any exception occurs */ - public List getRepositories(Object projectIdOrPath, int page, int perPage) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), - "projects", getProjectIdOrPath(projectIdOrPath), "registry", "repositories"); - return response.readEntity(new GenericType>() { - }); + public List getRepositories(Object projectIdOrPath, int page, int perPage) + throws GitLabApiException { + Response response = get( + Response.Status.OK, + getPageQueryParams(page, perPage), + "projects", + getProjectIdOrPath(projectIdOrPath), + "registry", + "repositories"); + return response.readEntity(new GenericType>() {}); } /** @@ -85,9 +90,17 @@ public List getRepositories(Object projectIdOrPath, int page * @return a Pager of registry repositories for the specified range * @throws GitLabApiException if any exception occurs */ - public Pager getRepositories(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager<>(this, RegistryRepository.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "registry", "repositories")); + public Pager getRepositories(Object projectIdOrPath, int itemsPerPage) + throws GitLabApiException { + return (new Pager<>( + this, + RegistryRepository.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "registry", + "repositories")); } /** @@ -120,7 +133,14 @@ public void deleteRepository(Object projectIdOrPath, Long repositoryId) throws G throw new RuntimeException("repositoryId cannot be null"); } - delete(Response.Status.NO_CONTENT, null, "projects", getProjectIdOrPath(projectIdOrPath), "registry", "repositories", repositoryId); + delete( + Response.Status.NO_CONTENT, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "registry", + "repositories", + repositoryId); } /** @@ -133,8 +153,10 @@ public void deleteRepository(Object projectIdOrPath, Long repositoryId) throws G * @return a list of Repository Tags for the specified repository ID * @throws GitLabApiException if any exception occurs */ - public List getRepositoryTags(Object projectIdOrPath, Long repositoryId) throws GitLabApiException { - return getRepositoryTags(projectIdOrPath, repositoryId, getDefaultPerPage()).all(); + public List getRepositoryTags(Object projectIdOrPath, Long repositoryId) + throws GitLabApiException { + return getRepositoryTags(projectIdOrPath, repositoryId, getDefaultPerPage()) + .all(); } /** @@ -148,9 +170,19 @@ public List getRepositoryTags(Object projectIdOrPath, Lon * @return a Pager of Repository Tags for the specified repository ID * @throws GitLabApiException if any exception occurs */ - public Pager getRepositoryTags(Object projectIdOrPath, Long repositoryId, int itemsPerPage) throws GitLabApiException { - return (new Pager<>(this, RegistryRepositoryTag.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "registry", "repositories", repositoryId, "tags")); + public Pager getRepositoryTags(Object projectIdOrPath, Long repositoryId, int itemsPerPage) + throws GitLabApiException { + return (new Pager<>( + this, + RegistryRepositoryTag.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "registry", + "repositories", + repositoryId, + "tags")); } /** @@ -163,7 +195,8 @@ public Pager getRepositoryTags(Object projectIdOrPath, Lo * @return a list of Repository Tags for the specified repository ID * @throws GitLabApiException if any exception occurs */ - public Stream getRepositoryTagsStream(Object projectIdOrPath, Long repositoryId) throws GitLabApiException { + public Stream getRepositoryTagsStream(Object projectIdOrPath, Long repositoryId) + throws GitLabApiException { return getRepositoryTags(projectIdOrPath, repositoryId, getDefaultPerPage()).stream(); } @@ -178,11 +211,19 @@ public Stream getRepositoryTagsStream(Object projectIdOrP * @return the Repository Tag for the specified repository ID * @throws GitLabApiException if any exception occurs */ - public RegistryRepositoryTag getRepositoryTag(Object projectIdOrPath, Long repositoryId, String tagName) throws GitLabApiException { - Response response = get(Response.Status.OK, null, - "projects", getProjectIdOrPath(projectIdOrPath), "registry", "repositories", repositoryId, "tags", tagName); - return response.readEntity(new GenericType() { - }); + public RegistryRepositoryTag getRepositoryTag(Object projectIdOrPath, Long repositoryId, String tagName) + throws GitLabApiException { + Response response = get( + Response.Status.OK, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "registry", + "repositories", + repositoryId, + "tags", + tagName); + return response.readEntity(new GenericType() {}); } /** @@ -195,7 +236,8 @@ public RegistryRepositoryTag getRepositoryTag(Object projectIdOrPath, Long repos * @param tagName the name of tag * @return the Repository Tag for the specified repository ID as the value of the Optional */ - public Optional getOptionalRepositoryTag(Object projectIdOrPath, Long repositoryId, String tagName) { + public Optional getOptionalRepositoryTag( + Object projectIdOrPath, Long repositoryId, String tagName) { try { return (Optional.ofNullable(getRepositoryTag(projectIdOrPath, repositoryId, tagName))); } catch (GitLabApiException glae) { @@ -213,13 +255,23 @@ public Optional getOptionalRepositoryTag(Object projectId * @param tagName the name of the tag to delete * @throws GitLabApiException if any exception occurs */ - public void deleteRepositoryTag(Object projectIdOrPath, Long repositoryId, String tagName) throws GitLabApiException { + public void deleteRepositoryTag(Object projectIdOrPath, Long repositoryId, String tagName) + throws GitLabApiException { if (repositoryId == null) { throw new RuntimeException("repositoryId cannot be null"); } - delete(Response.Status.NO_CONTENT, null, "projects", getProjectIdOrPath(projectIdOrPath), "registry", "repositories", repositoryId, "tags", tagName); + delete( + Response.Status.NO_CONTENT, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "registry", + "repositories", + repositoryId, + "tags", + tagName); } /** @@ -249,13 +301,23 @@ public void deleteRepositoryTag(Object projectIdOrPath, Long repositoryId, Strin * 1h, 1d, 1month. * @throws GitLabApiException if any exception occurs */ - public void deleteRepositoryTags(Object projectIdOrPath, Long repositoryId, String nameRegex, Integer keepN, String olderThan) throws GitLabApiException { + public void deleteRepositoryTags( + Object projectIdOrPath, Long repositoryId, String nameRegex, Integer keepN, String olderThan) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("name_regex", nameRegex, true) .withParam("keep_n", keepN) .withParam("older_than", olderThan); - delete(Response.Status.NO_CONTENT, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "registry", "repositories", repositoryId, "tags"); + delete( + Response.Status.NO_CONTENT, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "registry", + "repositories", + repositoryId, + "tags"); } } diff --git a/src/main/java/org/gitlab4j/api/DeployKeysApi.java b/src/main/java/org/gitlab4j/api/DeployKeysApi.java index c8525956d..1132a95e1 100644 --- a/src/main/java/org/gitlab4j/api/DeployKeysApi.java +++ b/src/main/java/org/gitlab4j/api/DeployKeysApi.java @@ -32,7 +32,7 @@ public List getDeployKeys() throws GitLabApiException { } /** - * Get a list of all deploy keys across all projects of the GitLab instance using the specified page and per page settings. + * Get a list of all deploy keys across all projects of the GitLab instance using the specified page and per page settings. * This method requires admin access. * *
GitLab Endpoint: GET /deploy_keys
@@ -86,7 +86,7 @@ public List getProjectDeployKeys(Object projectIdOrPath) throws GitLa } /** - * Get a list of the deploy keys for the specified project using the specified page and per page settings. + * Get a list of the deploy keys for the specified project using the specified page and per page settings. * This method requires admin access. * *
GitLab Endpoint: GET /projects/:id/deploy_keys
@@ -97,9 +97,14 @@ public List getProjectDeployKeys(Object projectIdOrPath) throws GitLa * @return the list of DeployKey in the specified range * @throws GitLabApiException if any exception occurs */ - public List getProjectDeployKeys(Object projectIdOrPath, int page, int perPage) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), - "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys"); + public List getProjectDeployKeys(Object projectIdOrPath, int page, int perPage) + throws GitLabApiException { + Response response = get( + Response.Status.OK, + getPageQueryParams(page, perPage), + "projects", + getProjectIdOrPath(projectIdOrPath), + "deploy_keys"); return (response.readEntity(new GenericType>() {})); } @@ -114,8 +119,14 @@ public List getProjectDeployKeys(Object projectIdOrPath, int page, in * @throws GitLabApiException if any exception occurs */ public Pager getProjectDeployKeys(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, DeployKey.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys")); + return (new Pager( + this, + DeployKey.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "deploy_keys")); } /** @@ -147,8 +158,8 @@ public DeployKey getDeployKey(Object projectIdOrPath, Long keyId) throws GitLabA throw new RuntimeException("keyId cannot be null"); } - Response response = get(Response.Status.OK, null, - "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys", keyId); + Response response = + get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys", keyId); return (response.readEntity(DeployKey.class)); } @@ -181,14 +192,15 @@ public Optional getOptionalDeployKey(Object projectIdOrPath, Long key * @return an DeployKey instance with info on the added deploy key * @throws GitLabApiException if any exception occurs */ - public DeployKey addDeployKey(Object projectIdOrPath, String title, String key, Boolean canPush) throws GitLabApiException { + public DeployKey addDeployKey(Object projectIdOrPath, String title, String key, Boolean canPush) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("title", title, true) .withParam("key", key, true) - .withParam("can_push", canPush); - Response response = post(Response.Status.CREATED, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys"); + .withParam("can_push", canPush); + Response response = + post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys"); return (response.readEntity(DeployKey.class)); } @@ -204,7 +216,8 @@ public DeployKey addDeployKey(Object projectIdOrPath, String title, String key, * @return an updated DeployKey instance * @throws GitLabApiException if any exception occurs */ - public DeployKey updateDeployKey(Object projectIdOrPath, Long deployKeyId, String title, Boolean canPush) throws GitLabApiException { + public DeployKey updateDeployKey(Object projectIdOrPath, Long deployKeyId, String title, Boolean canPush) + throws GitLabApiException { if (deployKeyId == null) { throw new RuntimeException("deployKeyId cannot be null"); @@ -213,8 +226,8 @@ public DeployKey updateDeployKey(Object projectIdOrPath, Long deployKeyId, Strin final DeployKey key = new DeployKey(); key.setCanPush(canPush); key.setTitle(title); - final Response response = put(Response.Status.OK, key, - "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys", deployKeyId); + final Response response = put( + Response.Status.OK, key, "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys", deployKeyId); return (response.readEntity(DeployKey.class)); } @@ -253,8 +266,14 @@ public DeployKey enableDeployKey(Object projectIdOrPath, Long keyId) throws GitL throw new RuntimeException("keyId cannot be null"); } - Response response = post(Response.Status.CREATED, (Form)null, - "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys", keyId, "enable"); + Response response = post( + Response.Status.CREATED, + (Form) null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "deploy_keys", + keyId, + "enable"); return (response.readEntity(DeployKey.class)); } } diff --git a/src/main/java/org/gitlab4j/api/DeployTokensApi.java b/src/main/java/org/gitlab4j/api/DeployTokensApi.java index 214089f1a..696ce34ff 100644 --- a/src/main/java/org/gitlab4j/api/DeployTokensApi.java +++ b/src/main/java/org/gitlab4j/api/DeployTokensApi.java @@ -1,12 +1,13 @@ package org.gitlab4j.api; -import org.gitlab4j.api.models.DeployToken; - -import javax.ws.rs.core.Response; import java.util.Date; import java.util.List; import java.util.stream.Stream; +import javax.ws.rs.core.Response; + +import org.gitlab4j.api.models.DeployToken; + /** * This class implements the client side API for the GitLab Deploy Tokens API calls. * See https://docs.gitlab.com/ee/api/deploy_tokens.html @@ -88,9 +89,16 @@ public List getProjectDeployTokens(Object projectIdOrPath) throws G * @return a Pager of DeployToken * @throws GitLabApiException if any exception occurs */ - public Pager getProjectDeployTokens(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager<>(this, DeployToken.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "deploy_tokens")); + public Pager getProjectDeployTokens(Object projectIdOrPath, int itemsPerPage) + throws GitLabApiException { + return (new Pager<>( + this, + DeployToken.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "deploy_tokens")); } /** @@ -119,14 +127,22 @@ public Stream getProjectDeployTokensStream(Object projectIdOrPath) * @return an DeployToken instance with info on the added deploy token * @throws GitLabApiException if any exception occurs */ - public DeployToken addProjectDeployToken(Object projectIdOrPath, String name, Date expiresAt, String username, List scopes) throws GitLabApiException { + public DeployToken addProjectDeployToken( + Object projectIdOrPath, String name, Date expiresAt, String username, List scopes) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("name", name, true) - .withParam("expires_at", expiresAt, true) // Currently documented as not required but api fails if not provided - .withParam("username", username, true)// Currently documented as not required but api fails if not provided + .withParam( + "expires_at", + expiresAt, + true) // Currently documented as not required but api fails if not provided + .withParam( + "username", + username, + true) // Currently documented as not required but api fails if not provided .withParam("scopes", scopes, true); - Response response = post(Response.Status.CREATED, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "deploy_tokens"); + Response response = post( + Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "deploy_tokens"); return (response.readEntity(DeployToken.class)); } @@ -176,8 +192,14 @@ public List getGroupDeployTokens(Object groupIdOrPath) throws GitLa * @throws GitLabApiException if any exception occurs */ public Pager getGroupDeployTokens(Object groupIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager<>(this, DeployToken.class, itemsPerPage, null, - "groups", getGroupIdOrPath(groupIdOrPath), "deploy_tokens")); + return (new Pager<>( + this, + DeployToken.class, + itemsPerPage, + null, + "groups", + getGroupIdOrPath(groupIdOrPath), + "deploy_tokens")); } /** @@ -206,14 +228,22 @@ public Stream getGroupDeployTokensStream(Object groupIdOrPath) thro * @return an DeployToken instance with info on the added deploy token * @throws GitLabApiException if any exception occurs */ - public DeployToken addGroupDeployToken(Object groupIdOrPath, String name, Date expiresAt, String username, List scopes) throws GitLabApiException { + public DeployToken addGroupDeployToken( + Object groupIdOrPath, String name, Date expiresAt, String username, List scopes) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("name", name, true) - .withParam("expires_at", expiresAt, true) // Currently documented as not required but api fails if not provided - .withParam("username", username, true)// Currently documented as not required but api fails if not provided + .withParam( + "expires_at", + expiresAt, + true) // Currently documented as not required but api fails if not provided + .withParam( + "username", + username, + true) // Currently documented as not required but api fails if not provided .withParam("scopes", scopes, true); - Response response = post(Response.Status.CREATED, formData, - "groups", getGroupIdOrPath(groupIdOrPath), "deploy_tokens"); + Response response = + post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "deploy_tokens"); return (response.readEntity(DeployToken.class)); } @@ -234,5 +264,4 @@ public void deleteGroupDeployToken(Object groupIdOrPath, Long tokenId) throws Gi delete(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "deploy_tokens", tokenId); } - } diff --git a/src/main/java/org/gitlab4j/api/DeploymentsApi.java b/src/main/java/org/gitlab4j/api/DeploymentsApi.java index 299c7ce3d..1f10ca620 100644 --- a/src/main/java/org/gitlab4j/api/DeploymentsApi.java +++ b/src/main/java/org/gitlab4j/api/DeploymentsApi.java @@ -31,7 +31,8 @@ public DeploymentsApi(GitLabApi gitLabApi) { * @throws GitLabApiException if any exception occurs */ public List getProjectDeployments(Object projectIdOrPath) throws GitLabApiException { - return (getProjectDeployments(projectIdOrPath, null, getDefaultPerPage()).all()); + return (getProjectDeployments(projectIdOrPath, null, getDefaultPerPage()) + .all()); } /** @@ -58,7 +59,8 @@ public Pager getProjectDeployments(Object projectIdOrPath, int items * @return a Pager of Deployment * @throws GitLabApiException if any exception occurs */ - public Pager getProjectDeployments(Object projectIdOrPath, DeploymentFilter filter) throws GitLabApiException { + public Pager getProjectDeployments(Object projectIdOrPath, DeploymentFilter filter) + throws GitLabApiException { return (getProjectDeployments(projectIdOrPath, filter, getDefaultPerPage())); } @@ -73,10 +75,17 @@ public Pager getProjectDeployments(Object projectIdOrPath, Deploymen * @return a Pager of Deployment * @throws GitLabApiException if any exception occurs */ - public Pager getProjectDeployments(Object projectIdOrPath, DeploymentFilter filter, int itemsPerPage) throws GitLabApiException { + public Pager getProjectDeployments(Object projectIdOrPath, DeploymentFilter filter, int itemsPerPage) + throws GitLabApiException { GitLabApiForm formData = (filter != null ? filter.getQueryParams() : new GitLabApiForm()); - return (new Pager(this, Deployment.class, itemsPerPage, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "deployments")); + return (new Pager( + this, + Deployment.class, + itemsPerPage, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "deployments")); } /** @@ -102,7 +111,8 @@ public Stream getProjectDeploymentsStream(Object projectIdOrPath) th * @return a list of Deployment * @throws GitLabApiException if any exception occurs */ - public Stream getProjectDeploymentsStream(Object projectIdOrPath, DeploymentFilter filter) throws GitLabApiException { + public Stream getProjectDeploymentsStream(Object projectIdOrPath, DeploymentFilter filter) + throws GitLabApiException { return (getProjectDeployments(projectIdOrPath, filter, getDefaultPerPage()).stream()); } @@ -117,8 +127,13 @@ public Stream getProjectDeploymentsStream(Object projectIdOrPath, De * @throws GitLabApiException if any exception occurs */ public Deployment getDeployment(Object projectIdOrPath, Long deploymentId) throws GitLabApiException { - Response response = get(Response.Status.OK, getDefaultPerPageParam(), - "projects", getProjectIdOrPath(projectIdOrPath), "deployments", deploymentId); + Response response = get( + Response.Status.OK, + getDefaultPerPageParam(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "deployments", + deploymentId); return (response.readEntity(Deployment.class)); } @@ -153,7 +168,9 @@ public Optional getOptionalDeployment(Object projectIdOrPath, Long d * @return a Deployment instance with info on the added deployment * @throws GitLabApiException if any exception occurs */ - public Deployment addDeployment(Object projectIdOrPath, String environment, String sha, String ref, Boolean tag, DeploymentStatus status) throws GitLabApiException { + public Deployment addDeployment( + Object projectIdOrPath, String environment, String sha, String ref, Boolean tag, DeploymentStatus status) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("environment", environment, true) @@ -162,8 +179,8 @@ public Deployment addDeployment(Object projectIdOrPath, String environment, Stri .withParam("tag", tag, true) .withParam("status", status, true); - Response response = post(Response.Status.CREATED, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "deployments"); + Response response = + post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "deployments"); return (response.readEntity(Deployment.class)); } @@ -178,7 +195,8 @@ public Deployment addDeployment(Object projectIdOrPath, String environment, Stri * @return an updated Deployment instance * @throws GitLabApiException if any exception occurs */ - public Deployment updateDeployment(Object projectIdOrPath, Long deploymentId, DeploymentStatus status) throws GitLabApiException { + public Deployment updateDeployment(Object projectIdOrPath, Long deploymentId, DeploymentStatus status) + throws GitLabApiException { if (deploymentId == null) { throw new RuntimeException("deploymentId cannot be null"); @@ -186,8 +204,13 @@ public Deployment updateDeployment(Object projectIdOrPath, Long deploymentId, De final Deployment deployment = new Deployment(); deployment.setStatus(status); - final Response response = put(Response.Status.OK, deployment, - "projects", getProjectIdOrPath(projectIdOrPath), "deployments", deploymentId); + final Response response = put( + Response.Status.OK, + deployment, + "projects", + getProjectIdOrPath(projectIdOrPath), + "deployments", + deploymentId); return (response.readEntity(Deployment.class)); } @@ -203,7 +226,8 @@ public Deployment updateDeployment(Object projectIdOrPath, Long deploymentId, De * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ public List getMergeRequests(Object projectIdOrPath, Long deploymentId) throws GitLabApiException { - return (getMergeRequests(projectIdOrPath, deploymentId, getDefaultPerPage()).all()); + return (getMergeRequests(projectIdOrPath, deploymentId, getDefaultPerPage()) + .all()); } /** @@ -217,9 +241,18 @@ public List getMergeRequests(Object projectIdOrPath, Long deployme * @return a Pager containing the MergeRequest instances shipped with a given deployment * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public Pager getMergeRequests(Object projectIdOrPath, Long deploymentId, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, MergeRequest.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "deployments", deploymentId, "merge_requests")); + public Pager getMergeRequests(Object projectIdOrPath, Long deploymentId, int itemsPerPage) + throws GitLabApiException { + return (new Pager( + this, + MergeRequest.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "deployments", + deploymentId, + "merge_requests")); } /** @@ -232,9 +265,8 @@ public Pager getMergeRequests(Object projectIdOrPath, Long deploym * @return a Stream containing the MergeRequest instances shipped with a given deployment * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public Stream getMergeRequestsStream(Object projectIdOrPath, Long deploymentId) throws GitLabApiException { + public Stream getMergeRequestsStream(Object projectIdOrPath, Long deploymentId) + throws GitLabApiException { return (getMergeRequests(projectIdOrPath, deploymentId, getDefaultPerPage()).stream()); } - - } diff --git a/src/main/java/org/gitlab4j/api/DiscussionsApi.java b/src/main/java/org/gitlab4j/api/DiscussionsApi.java index 687d5a836..78fd58295 100644 --- a/src/main/java/org/gitlab4j/api/DiscussionsApi.java +++ b/src/main/java/org/gitlab4j/api/DiscussionsApi.java @@ -48,12 +48,19 @@ public List getIssueDiscussions(Object projectIdOrPath, Long issueIi * @return a list containing the discussions for the specified issue * @throws GitLabApiException if any exception occurs during execution */ - public List getIssueDiscussions(Object projectIdOrPath, Long issueIid, int maxItems) throws GitLabApiException { + public List getIssueDiscussions(Object projectIdOrPath, Long issueIid, int maxItems) + throws GitLabApiException { if (maxItems < 1) { return (getIssueDiscussions(projectIdOrPath, issueIid)); } else { - Response response = get(Response.Status.OK, getPerPageQueryParam(maxItems), - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "discussions"); + Response response = get( + Response.Status.OK, + getPerPageQueryParam(maxItems), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "discussions"); return (response.readEntity(new GenericType>() {})); } } @@ -69,9 +76,18 @@ public List getIssueDiscussions(Object projectIdOrPath, Long issueIi * @return a Pager containing the Discussion instances for the specified issue * @throws GitLabApiException if any exception occurs during execution */ - public Pager getIssueDiscussionsPager(Object projectIdOrPath, Long issueIid, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Discussion.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "discussions")); + public Pager getIssueDiscussionsPager(Object projectIdOrPath, Long issueIid, int itemsPerPage) + throws GitLabApiException { + return (new Pager( + this, + Discussion.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "discussions")); } /** @@ -84,7 +100,8 @@ public Pager getIssueDiscussionsPager(Object projectIdOrPath, Long i * @return a Stream instance containing the Discussion instances for the specified issue * @throws GitLabApiException if any exception occurs during execution */ - public Stream getIssueDiscussionsStream(Object projectIdOrPath, Long issueIid) throws GitLabApiException { + public Stream getIssueDiscussionsStream(Object projectIdOrPath, Long issueIid) + throws GitLabApiException { Pager pager = getIssueDiscussionsPager(projectIdOrPath, issueIid, getDefaultPerPage()); return (pager.stream()); } @@ -115,12 +132,19 @@ public List getSnippetDiscussions(Object projectIdOrPath, Long snipp * @return a list containing the discussions for the specified snippet * @throws GitLabApiException if any exception occurs during execution */ - public List getSnippetDiscussions(Object projectIdOrPath, Long snippetId, int maxItems) throws GitLabApiException { + public List getSnippetDiscussions(Object projectIdOrPath, Long snippetId, int maxItems) + throws GitLabApiException { if (maxItems < 1) { return (getSnippetDiscussions(projectIdOrPath, snippetId)); } else { - Response response = get(Response.Status.OK, getPerPageQueryParam(maxItems), - "projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "discussions"); + Response response = get( + Response.Status.OK, + getPerPageQueryParam(maxItems), + "projects", + getProjectIdOrPath(projectIdOrPath), + "snippets", + snippetId, + "discussions"); return (response.readEntity(new GenericType>() {})); } } @@ -136,9 +160,18 @@ public List getSnippetDiscussions(Object projectIdOrPath, Long snipp * @return a Pager containing the Discussion instances for the specified snippet * @throws GitLabApiException if any exception occurs during execution */ - public Pager getSnippetDiscussionsPager(Object projectIdOrPath, Long snippetId, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Discussion.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "discussions")); + public Pager getSnippetDiscussionsPager(Object projectIdOrPath, Long snippetId, int itemsPerPage) + throws GitLabApiException { + return (new Pager( + this, + Discussion.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "snippets", + snippetId, + "discussions")); } /** @@ -151,12 +184,12 @@ public Pager getSnippetDiscussionsPager(Object projectIdOrPath, Long * @return a Stream instance containing the Discussion instances for the specified snippet * @throws GitLabApiException if any exception occurs during execution */ - public Stream getSnippetDiscussionsStream(Object projectIdOrPath, Long snippetId) throws GitLabApiException { + public Stream getSnippetDiscussionsStream(Object projectIdOrPath, Long snippetId) + throws GitLabApiException { Pager pager = getSnippetDiscussionsPager(projectIdOrPath, snippetId, getDefaultPerPage()); return (pager.stream()); } - /** * Get a list of all discussions for the specified epic. * @@ -183,12 +216,19 @@ public List getEpicDiscussions(Object projectIdOrPath, Long epicId) * @return a list containing the discussions for the specified epic * @throws GitLabApiException if any exception occurs during execution */ - public List getEpicDiscussions(Object projectIdOrPath, Long epicId, int maxItems) throws GitLabApiException { + public List getEpicDiscussions(Object projectIdOrPath, Long epicId, int maxItems) + throws GitLabApiException { if (maxItems < 1) { return (getEpicDiscussions(projectIdOrPath, epicId)); } else { - Response response = get(Response.Status.OK, getPerPageQueryParam(maxItems), - "projects", getProjectIdOrPath(projectIdOrPath), "epics", epicId, "discussions"); + Response response = get( + Response.Status.OK, + getPerPageQueryParam(maxItems), + "projects", + getProjectIdOrPath(projectIdOrPath), + "epics", + epicId, + "discussions"); return (response.readEntity(new GenericType>() {})); } } @@ -204,9 +244,18 @@ public List getEpicDiscussions(Object projectIdOrPath, Long epicId, * @return a Pager containing the Discussion instances for the specified epic * @throws GitLabApiException if any exception occurs during execution */ - public Pager getEpicDiscussionsPager(Object projectIdOrPath, Long epicId, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Discussion.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "epics", epicId, "discussions")); + public Pager getEpicDiscussionsPager(Object projectIdOrPath, Long epicId, int itemsPerPage) + throws GitLabApiException { + return (new Pager( + this, + Discussion.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "epics", + epicId, + "discussions")); } /** @@ -234,8 +283,10 @@ public Stream getEpicDiscussionsStream(Object projectIdOrPath, Long * @return a list containing all the discussions for the specified merge request * @throws GitLabApiException if any exception occurs during execution */ - public List getMergeRequestDiscussions(Object projectIdOrPath, Long mergeRequestIid) throws GitLabApiException { - Pager pager = getMergeRequestDiscussionsPager(projectIdOrPath, mergeRequestIid, getDefaultPerPage()); + public List getMergeRequestDiscussions(Object projectIdOrPath, Long mergeRequestIid) + throws GitLabApiException { + Pager pager = + getMergeRequestDiscussionsPager(projectIdOrPath, mergeRequestIid, getDefaultPerPage()); return (pager.all()); } @@ -250,12 +301,19 @@ public List getMergeRequestDiscussions(Object projectIdOrPath, Long * @return a list containing the discussions for the specified merge request * @throws GitLabApiException if any exception occurs during execution */ - public List getMergeRequestDiscussions(Object projectIdOrPath, Long mergeRequestIid, int maxItems) throws GitLabApiException { + public List getMergeRequestDiscussions(Object projectIdOrPath, Long mergeRequestIid, int maxItems) + throws GitLabApiException { if (maxItems < 1) { return (getMergeRequestDiscussions(projectIdOrPath, mergeRequestIid)); } else { - Response response = get(Response.Status.OK, getPerPageQueryParam(maxItems), - "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "discussions"); + Response response = get( + Response.Status.OK, + getPerPageQueryParam(maxItems), + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "discussions"); return (response.readEntity(new GenericType>() {})); } } @@ -271,9 +329,18 @@ public List getMergeRequestDiscussions(Object projectIdOrPath, Long * @return a Pager containing the Discussion instances for the specified merge request * @throws GitLabApiException if any exception occurs during execution */ - public Pager getMergeRequestDiscussionsPager(Object projectIdOrPath, Long mergeRequestIid, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Discussion.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "discussions")); + public Pager getMergeRequestDiscussionsPager( + Object projectIdOrPath, Long mergeRequestIid, int itemsPerPage) throws GitLabApiException { + return (new Pager( + this, + Discussion.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "discussions")); } /** @@ -286,8 +353,10 @@ public Pager getMergeRequestDiscussionsPager(Object projectIdOrPath, * @return a Stream instance containing the Discussion instances for the specified issue * @throws GitLabApiException if any exception occurs during execution */ - public Stream getMergeRequestDiscussionsStream(Object projectIdOrPath, Long mergeRequestIid) throws GitLabApiException { - Pager pager = getMergeRequestDiscussionsPager(projectIdOrPath, mergeRequestIid, getDefaultPerPage()); + public Stream getMergeRequestDiscussionsStream(Object projectIdOrPath, Long mergeRequestIid) + throws GitLabApiException { + Pager pager = + getMergeRequestDiscussionsPager(projectIdOrPath, mergeRequestIid, getDefaultPerPage()); return (pager.stream()); } @@ -306,8 +375,14 @@ public Stream getMergeRequestDiscussionsStream(Object projectIdOrPat * @return a Discussion instance containing the newly created discussion * @throws GitLabApiException if any exception occurs during execution */ - public Discussion createMergeRequestDiscussion(Object projectIdOrPath, Long mergeRequestIid, - String body, Date createdAt, String positionHash, Position position) throws GitLabApiException { + public Discussion createMergeRequestDiscussion( + Object projectIdOrPath, + Long mergeRequestIid, + String body, + Date createdAt, + String positionHash, + Position position) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("body", body, true) @@ -316,21 +391,27 @@ public Discussion createMergeRequestDiscussion(Object projectIdOrPath, Long merg if (position != null) { formData.withParam("position[base_sha]", position.getBaseSha(), true) - .withParam("position[start_sha]", position.getStartSha(), true) - .withParam("position[head_sha]", position.getHeadSha(), true) - .withParam("position[position_type]", position.getPositionType(), true) - .withParam("position[new_path]", position.getNewPath()) - .withParam("position[new_line]", position.getNewLine()) - .withParam("position[old_path]", position.getOldPath()) - .withParam("position[old_line]", position.getOldLine()) - .withParam("position[width]", position.getWidth()) - .withParam("position[height]", position.getHeight()) - .withParam("position[x]", position.getX()) - .withParam("position[y]", position.getY()); + .withParam("position[start_sha]", position.getStartSha(), true) + .withParam("position[head_sha]", position.getHeadSha(), true) + .withParam("position[position_type]", position.getPositionType(), true) + .withParam("position[new_path]", position.getNewPath()) + .withParam("position[new_line]", position.getNewLine()) + .withParam("position[old_path]", position.getOldPath()) + .withParam("position[old_line]", position.getOldLine()) + .withParam("position[width]", position.getWidth()) + .withParam("position[height]", position.getHeight()) + .withParam("position[x]", position.getX()) + .withParam("position[y]", position.getY()); } - Response response = post(Response.Status.CREATED, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "discussions"); + Response response = post( + Response.Status.CREATED, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "discussions"); return (response.readEntity(Discussion.class)); } @@ -346,11 +427,19 @@ public Discussion createMergeRequestDiscussion(Object projectIdOrPath, Long merg * @return the updated DIscussion instance * @throws GitLabApiException if any exception occurs during execution */ - public Discussion resolveMergeRequestDiscussion(Object projectIdOrPath, Long mergeRequestIid, - String discussionId, Boolean resolved) throws GitLabApiException { + public Discussion resolveMergeRequestDiscussion( + Object projectIdOrPath, Long mergeRequestIid, String discussionId, Boolean resolved) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm().withParam("resolved", resolved, true); - Response response = put(Response.Status.OK, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "discussions", discussionId); + Response response = put( + Response.Status.OK, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "discussions", + discussionId); return (response.readEntity(Discussion.class)); } @@ -365,10 +454,19 @@ public Discussion resolveMergeRequestDiscussion(Object projectIdOrPath, Long mer * @param noteId the note ID to delete * @throws GitLabApiException if any exception occurs during execution */ - public void deleteMergeRequestDiscussionNote(Object projectIdOrPath, Long mergeRequestIid, - String discussionId, Long noteId) throws GitLabApiException { - delete(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), - "merge_requests", mergeRequestIid, "discussions", discussionId, "notes", noteId); + public void deleteMergeRequestDiscussionNote( + Object projectIdOrPath, Long mergeRequestIid, String discussionId, Long noteId) throws GitLabApiException { + delete( + Response.Status.OK, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "discussions", + discussionId, + "notes", + noteId); } /** @@ -397,12 +495,20 @@ public List getCommitDiscussions(Object projectIdOrPath, String comm * @return a list containing the discussions for the specified commit * @throws GitLabApiException if any exception occurs during execution */ - public List getCommitDiscussions(Object projectIdOrPath, String commitSha, int maxItems) throws GitLabApiException { + public List getCommitDiscussions(Object projectIdOrPath, String commitSha, int maxItems) + throws GitLabApiException { if (maxItems < 1) { return (getCommitDiscussions(projectIdOrPath, commitSha)); } else { - Response response = get(Response.Status.OK, getPerPageQueryParam(maxItems), - "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", commitSha, "discussions"); + Response response = get( + Response.Status.OK, + getPerPageQueryParam(maxItems), + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + commitSha, + "discussions"); return (response.readEntity(new GenericType>() {})); } } @@ -418,9 +524,19 @@ public List getCommitDiscussions(Object projectIdOrPath, String comm * @return a Pager containing the Discussion instances for the specified commit * @throws GitLabApiException if any exception occurs during execution */ - public Pager getCommitDiscussionsPager(Object projectIdOrPath, String commitSha, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Discussion.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", commitSha, "discussions")); + public Pager getCommitDiscussionsPager(Object projectIdOrPath, String commitSha, int itemsPerPage) + throws GitLabApiException { + return (new Pager( + this, + Discussion.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + commitSha, + "discussions")); } /** @@ -433,7 +549,8 @@ public Pager getCommitDiscussionsPager(Object projectIdOrPath, Strin * @return a Stream instance containing the Discussion instances for the specified commit * @throws GitLabApiException if any exception occurs during execution */ - public Stream getCommitDiscussionsStream(Object projectIdOrPath, String commitSha) throws GitLabApiException { + public Stream getCommitDiscussionsStream(Object projectIdOrPath, String commitSha) + throws GitLabApiException { Pager pager = getCommitDiscussionsPager(projectIdOrPath, commitSha, getDefaultPerPage()); return (pager.stream()); } @@ -449,9 +566,18 @@ public Stream getCommitDiscussionsStream(Object projectIdOrPath, Str * @return the Discussion instance specified by discussionId for the specified commit * @throws GitLabApiException if any exception occurs during execution */ - public Discussion getCommitDiscussion(Object projectIdOrPath, String commitSha, String discussionId) throws GitLabApiException { - Response response = get(Response.Status.OK, null, - "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", commitSha, "discussions", discussionId); + public Discussion getCommitDiscussion(Object projectIdOrPath, String commitSha, String discussionId) + throws GitLabApiException { + Response response = get( + Response.Status.OK, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + commitSha, + "discussions", + discussionId); return (response.readEntity(Discussion.class)); } @@ -465,7 +591,8 @@ public Discussion getCommitDiscussion(Object projectIdOrPath, String commitSha, * @param discussionId the ID of the discussion * @return an Optional instance with the specified Discussion instance as a value */ - public Optional getOptionalCommitDiscussion(Object projectIdOrPath, String commitSha, String discussionId) { + public Optional getOptionalCommitDiscussion( + Object projectIdOrPath, String commitSha, String discussionId) { try { return (Optional.ofNullable(getCommitDiscussion(projectIdOrPath, commitSha, discussionId))); } catch (GitLabApiException glae) { @@ -488,8 +615,14 @@ public Optional getOptionalCommitDiscussion(Object projectIdOrPath, * @return a Discussion instance containing the newly created discussion * @throws GitLabApiException if any exception occurs during execution */ - public Discussion createCommitDiscussion(Object projectIdOrPath, String commitSha, - String body, Date createdAt, String positionHash, Position position) throws GitLabApiException { + public Discussion createCommitDiscussion( + Object projectIdOrPath, + String commitSha, + String body, + Date createdAt, + String positionHash, + Position position) + throws GitLabApiException { if (position == null) { throw new GitLabApiException("position instance can not be null"); @@ -512,8 +645,15 @@ public Discussion createCommitDiscussion(Object projectIdOrPath, String commitSh .withParam("position[x]", position.getX()) .withParam("position[y]", position.getY()); - Response response = post(Response.Status.CREATED, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", commitSha, "discussions"); + Response response = post( + Response.Status.CREATED, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + commitSha, + "discussions"); return (response.readEntity(Discussion.class)); } @@ -530,16 +670,24 @@ public Discussion createCommitDiscussion(Object projectIdOrPath, String commitSh * @return a Note instance containing the newly created discussion note * @throws GitLabApiException if any exception occurs during execution */ - public Note addCommitDiscussionNote(Object projectIdOrPath, String commitSha, String discussionId, - String body, Date createdAt) throws GitLabApiException { - - GitLabApiForm formData = new GitLabApiForm() - .withParam("body", body, true) - .withParam("created_at", createdAt); - - Response response = post(Response.Status.CREATED, formData, - "projects", getProjectIdOrPath(projectIdOrPath), - "repository", "commits", commitSha, "discussions", discussionId, "notes"); + public Note addCommitDiscussionNote( + Object projectIdOrPath, String commitSha, String discussionId, String body, Date createdAt) + throws GitLabApiException { + + GitLabApiForm formData = + new GitLabApiForm().withParam("body", body, true).withParam("created_at", createdAt); + + Response response = post( + Response.Status.CREATED, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + commitSha, + "discussions", + discussionId, + "notes"); return (response.readEntity(Note.class)); } @@ -556,13 +704,23 @@ public Note addCommitDiscussionNote(Object projectIdOrPath, String commitSha, St * @return a Note instance containing the updated discussion note * @throws GitLabApiException if any exception occurs during execution */ - public Note modifyCommitDiscussionNote(Object projectIdOrPath, - String commitSha, String discussionId, Long noteId, String body) throws GitLabApiException { + public Note modifyCommitDiscussionNote( + Object projectIdOrPath, String commitSha, String discussionId, Long noteId, String body) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm().withParam("body", body, true); - Response response = this.putWithFormData(Response.Status.OK, formData, - "projects", getProjectIdOrPath(projectIdOrPath), - "repository", "commits", commitSha, "discussions", discussionId, "notes", noteId); + Response response = this.putWithFormData( + Response.Status.OK, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + commitSha, + "discussions", + discussionId, + "notes", + noteId); return (response.readEntity(Note.class)); } @@ -579,13 +737,23 @@ public Note modifyCommitDiscussionNote(Object projectIdOrPath, * @return a Note instance containing the updated discussion note * @throws GitLabApiException if any exception occurs during execution */ - public Note resolveCommitDiscussionNote(Object projectIdOrPath, - String commitSha, String discussionId, Long noteId, Boolean resolved) throws GitLabApiException { + public Note resolveCommitDiscussionNote( + Object projectIdOrPath, String commitSha, String discussionId, Long noteId, Boolean resolved) + throws GitLabApiException { GitLabApiForm queryParams = new GitLabApiForm().withParam("resolved", resolved); - Response response = this.put(Response.Status.OK, queryParams.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), - "repository", "commits", commitSha, "discussions", discussionId, "notes", noteId); + Response response = this.put( + Response.Status.OK, + queryParams.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + commitSha, + "discussions", + discussionId, + "notes", + noteId); return (response.readEntity(Note.class)); } @@ -600,10 +768,20 @@ public Note resolveCommitDiscussionNote(Object projectIdOrPath, * @param noteId the note ID to delete * @throws GitLabApiException if any exception occurs during execution */ - public void deleteCommitDiscussionNote(Object projectIdOrPath, String commitSha, - String discussionId, Long noteId) throws GitLabApiException { - delete(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), - "repository", "commits", commitSha, "discussions", discussionId, "notes", noteId); + public void deleteCommitDiscussionNote(Object projectIdOrPath, String commitSha, String discussionId, Long noteId) + throws GitLabApiException { + delete( + Response.Status.OK, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "repository", + "commits", + commitSha, + "discussions", + discussionId, + "notes", + noteId); } /** @@ -619,15 +797,22 @@ public void deleteCommitDiscussionNote(Object projectIdOrPath, String commitSha, * @return a Note instance containing the newly created discussion note * @throws GitLabApiException if any exception occurs during execution */ - public Note addMergeRequestThreadNote(Object projectIdOrPath, Long mergeRequestIid, - String discussionId, String body, Date createdAt) throws GitLabApiException { - - GitLabApiForm formData = new GitLabApiForm() - .withParam("body", body, true) - .withParam("created_at", createdAt); - Response response = post(Response.Status.CREATED, formData, - "projects", getProjectIdOrPath(projectIdOrPath), - "merge_requests", mergeRequestIid, "discussions", discussionId, "notes"); + public Note addMergeRequestThreadNote( + Object projectIdOrPath, Long mergeRequestIid, String discussionId, String body, Date createdAt) + throws GitLabApiException { + + GitLabApiForm formData = + new GitLabApiForm().withParam("body", body, true).withParam("created_at", createdAt); + Response response = post( + Response.Status.CREATED, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "discussions", + discussionId, + "notes"); return (response.readEntity(Note.class)); } @@ -645,13 +830,27 @@ public Note addMergeRequestThreadNote(Object projectIdOrPath, Long mergeRequestI * @return a Note instance containing the updated discussion note * @throws GitLabApiException if any exception occurs during execution */ - public Note modifyMergeRequestThreadNote(Object projectIdOrPath, Long mergeRequestIid, - String discussionId, Long noteId, String body, Boolean resolved) throws GitLabApiException { + public Note modifyMergeRequestThreadNote( + Object projectIdOrPath, + Long mergeRequestIid, + String discussionId, + Long noteId, + String body, + Boolean resolved) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm().withParam("body", body).withParam("resolved", resolved); - Response response = this.putWithFormData(Response.Status.OK, formData, - "projects", getProjectIdOrPath(projectIdOrPath), - "merge_requests", mergeRequestIid, "discussions", discussionId, "notes", noteId); + Response response = this.putWithFormData( + Response.Status.OK, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "discussions", + discussionId, + "notes", + noteId); return (response.readEntity(Note.class)); } @@ -666,10 +865,19 @@ public Note modifyMergeRequestThreadNote(Object projectIdOrPath, Long mergeReque * @param noteId the note ID to delete * @throws GitLabApiException if any exception occurs during execution */ - public void deleteMergeRequestThreadNote(Object projectIdOrPath, Long mergeRequestIid, - String discussionId, Long noteId) throws GitLabApiException { - delete(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), - "merge_requests", mergeRequestIid, "discussions", discussionId, "notes", noteId); + public void deleteMergeRequestThreadNote( + Object projectIdOrPath, Long mergeRequestIid, String discussionId, Long noteId) throws GitLabApiException { + delete( + Response.Status.OK, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "discussions", + discussionId, + "notes", + noteId); } /** @@ -684,12 +892,18 @@ public void deleteMergeRequestThreadNote(Object projectIdOrPath, Long mergeReque * @return a Discussion instance containing the newly created discussion * @throws GitLabApiException if any exception occurs during execution */ - public Discussion createIssueDiscussion(Object projectIdOrPath, Long issueIid, String body, Date createdAt) throws GitLabApiException { - GitLabApiForm formData = new GitLabApiForm() - .withParam("body", body, true) - .withParam("created_at", createdAt); - Response response = post(Response.Status.CREATED, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "discussions"); + public Discussion createIssueDiscussion(Object projectIdOrPath, Long issueIid, String body, Date createdAt) + throws GitLabApiException { + GitLabApiForm formData = + new GitLabApiForm().withParam("body", body, true).withParam("created_at", createdAt); + Response response = post( + Response.Status.CREATED, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "discussions"); return (response.readEntity(Discussion.class)); } @@ -706,13 +920,21 @@ public Discussion createIssueDiscussion(Object projectIdOrPath, Long issueIid, S * @return a Note instance containing the newly created note * @throws GitLabApiException if any exception occurs during execution */ - public Note addIssueThreadNote(Object projectIdOrPath, Long issueIid, - String discussionId, String body, Date createdAt) throws GitLabApiException { - GitLabApiForm formData = new GitLabApiForm() - .withParam("body", body, true) - .withParam("created_at", createdAt); - Response response = post(Response.Status.CREATED, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "discussions", discussionId, "notes"); + public Note addIssueThreadNote( + Object projectIdOrPath, Long issueIid, String discussionId, String body, Date createdAt) + throws GitLabApiException { + GitLabApiForm formData = + new GitLabApiForm().withParam("body", body, true).withParam("created_at", createdAt); + Response response = post( + Response.Status.CREATED, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "discussions", + discussionId, + "notes"); return (response.readEntity(Note.class)); } @@ -729,12 +951,21 @@ public Note addIssueThreadNote(Object projectIdOrPath, Long issueIid, * @return a Note instance containing the modified note * @throws GitLabApiException if any exception occurs during execution */ - public Note modifyIssueThreadNote(Object projectIdOrPath, Long issueIid, - String discussionId, Long noteId, String body) throws GitLabApiException { - GitLabApiForm formData = new GitLabApiForm() - .withParam("body", body, true); - Response response = putWithFormData(Response.Status.OK, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "discussions", discussionId, "notes", noteId); + public Note modifyIssueThreadNote( + Object projectIdOrPath, Long issueIid, String discussionId, Long noteId, String body) + throws GitLabApiException { + GitLabApiForm formData = new GitLabApiForm().withParam("body", body, true); + Response response = putWithFormData( + Response.Status.OK, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "discussions", + discussionId, + "notes", + noteId); return (response.readEntity(Note.class)); } @@ -749,9 +980,18 @@ public Note modifyIssueThreadNote(Object projectIdOrPath, Long issueIid, * @param noteId the id of the note * @throws GitLabApiException if any exception occurs during execution */ - public void deleteIssueThreadNote(Object projectIdOrPath, Long issueIid, - String discussionId, Long noteId) throws GitLabApiException { - delete(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "discussions", discussionId, "notes", noteId); + public void deleteIssueThreadNote(Object projectIdOrPath, Long issueIid, String discussionId, Long noteId) + throws GitLabApiException { + delete( + Response.Status.OK, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "discussions", + discussionId, + "notes", + noteId); } - } diff --git a/src/main/java/org/gitlab4j/api/EnvironmentsApi.java b/src/main/java/org/gitlab4j/api/EnvironmentsApi.java index 2816f18ae..9c16b8bc6 100644 --- a/src/main/java/org/gitlab4j/api/EnvironmentsApi.java +++ b/src/main/java/org/gitlab4j/api/EnvironmentsApi.java @@ -55,8 +55,14 @@ public Stream getEnvironmentsStream(Object projectIdOrPath) throws * @throws GitLabApiException if any exception occurs */ public Pager getEnvironments(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Environment.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "environments")); + return (new Pager( + this, + Environment.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "environments")); } /** @@ -70,9 +76,14 @@ public Pager getEnvironments(Object projectIdOrPath, int itemsPerPa * @throws GitLabApiException if any exception occurs */ public Environment getEnvironment(Object projectIdOrPath, Long environmentId) throws GitLabApiException { - Response response = get(Response.Status.OK, null, - "projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId); - return (response.readEntity(Environment.class)); + Response response = get( + Response.Status.OK, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "environments", + environmentId); + return (response.readEntity(Environment.class)); } /** @@ -85,11 +96,11 @@ public Environment getEnvironment(Object projectIdOrPath, Long environmentId) th * @return the Environment as an Optional instance */ public Optional getOptionalEnvironment(Object projectIdOrPath, Long environmentId) { - try { - return (Optional.ofNullable(getEnvironment(projectIdOrPath, environmentId))); - } catch (GitLabApiException glae) { - return (GitLabApi.createOptionalFromException(glae)); - } + try { + return (Optional.ofNullable(getEnvironment(projectIdOrPath, environmentId))); + } catch (GitLabApiException glae) { + return (GitLabApi.createOptionalFromException(glae)); + } } /** @@ -105,7 +116,8 @@ public Optional getOptionalEnvironment(Object projectIdOrPath, Long * @deprecated use {@link #createEnvironment(Object, String, String, String)} instead */ @Deprecated - public Environment createEnvironment(Object projectIdOrPath, String name, String externalUrl) throws GitLabApiException { + public Environment createEnvironment(Object projectIdOrPath, String name, String externalUrl) + throws GitLabApiException { return createEnvironment(projectIdOrPath, name, externalUrl, null); } @@ -121,11 +133,15 @@ public Environment createEnvironment(Object projectIdOrPath, String name, String * @return the created Environment instance * @throws GitLabApiException if any exception occurs */ - public Environment createEnvironment(Object projectIdOrPath, String name, String externalUrl, String tier) throws GitLabApiException { - GitLabApiForm formData = new GitLabApiForm().withParam("name", name, true).withParam("external_url", externalUrl).withParam("tier", tier); - Response response = post(Response.Status.CREATED, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "environments"); - return (response.readEntity(Environment.class)); + public Environment createEnvironment(Object projectIdOrPath, String name, String externalUrl, String tier) + throws GitLabApiException { + GitLabApiForm formData = new GitLabApiForm() + .withParam("name", name, true) + .withParam("external_url", externalUrl) + .withParam("tier", tier); + Response response = post( + Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "environments"); + return (response.readEntity(Environment.class)); } /** @@ -142,7 +158,8 @@ public Environment createEnvironment(Object projectIdOrPath, String name, String * @deprecated use {@link #updateEnvironment(Object, Long, String, String, String)} instead */ @Deprecated - public Environment updateEnvironment(Object projectIdOrPath, Long environmentId, String name, String externalUrl) throws GitLabApiException { + public Environment updateEnvironment(Object projectIdOrPath, Long environmentId, String name, String externalUrl) + throws GitLabApiException { return updateEnvironment(projectIdOrPath, environmentId, name, externalUrl, null); } @@ -159,11 +176,22 @@ public Environment updateEnvironment(Object projectIdOrPath, Long environmentId, * @return the created Environment instance * @throws GitLabApiException if any exception occurs */ - public Environment updateEnvironment(Object projectIdOrPath, Long environmentId, String name, String externalUrl, String tier) throws GitLabApiException { - GitLabApiForm formData = new GitLabApiForm().withParam("name", name).withParam("external_url", externalUrl).withParam("tier", tier); - Response response = putWithFormData(Response.Status.OK, formData, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId); - return (response.readEntity(Environment.class)); + public Environment updateEnvironment( + Object projectIdOrPath, Long environmentId, String name, String externalUrl, String tier) + throws GitLabApiException { + GitLabApiForm formData = new GitLabApiForm() + .withParam("name", name) + .withParam("external_url", externalUrl) + .withParam("tier", tier); + Response response = putWithFormData( + Response.Status.OK, + formData, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "environments", + environmentId); + return (response.readEntity(Environment.class)); } /** @@ -177,9 +205,15 @@ public Environment updateEnvironment(Object projectIdOrPath, Long environmentId, * @throws GitLabApiException if any exception occurs */ public Environment stopEnvironment(Object projectIdOrPath, Long environmentId) throws GitLabApiException { - Response response = post(Response.Status.OK, (GitLabApiForm) null, - "projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId, "stop"); - return (response.readEntity(Environment.class)); + Response response = post( + Response.Status.OK, + (GitLabApiForm) null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "environments", + environmentId, + "stop"); + return (response.readEntity(Environment.class)); } /** @@ -192,8 +226,13 @@ public Environment stopEnvironment(Object projectIdOrPath, Long environmentId) t * @throws GitLabApiException if any exception occurs */ public void deleteEnvironment(Object projectIdOrPath, Long environmentId) throws GitLabApiException { - delete(Response.Status.OK, null, - "projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId); + delete( + Response.Status.OK, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "environments", + environmentId); } /** @@ -207,9 +246,15 @@ public void deleteEnvironment(Object projectIdOrPath, Long environmentId) throws * @throws GitLabApiException if any exception occurs */ public Environment createEnvironment(Object projectIdOrPath, Long environmentId) throws GitLabApiException { - GitLabApiForm formData = new GitLabApiForm(); - Response response = post(Response.Status.CREATED, formData, - "projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId, "stop"); - return (response.readEntity(Environment.class)); + GitLabApiForm formData = new GitLabApiForm(); + Response response = post( + Response.Status.CREATED, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "environments", + environmentId, + "stop"); + return (response.readEntity(Environment.class)); } } diff --git a/src/main/java/org/gitlab4j/api/EpicsApi.java b/src/main/java/org/gitlab4j/api/EpicsApi.java index 314f01901..009e36487 100644 --- a/src/main/java/org/gitlab4j/api/EpicsApi.java +++ b/src/main/java/org/gitlab4j/api/EpicsApi.java @@ -61,8 +61,13 @@ public List getEpics(Object groupIdOrPath) throws GitLabApiException { * @throws GitLabApiException if any exception occurs */ public List getEpics(Object groupIdOrPath, int page, int perPage) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "groups", getGroupIdOrPath(groupIdOrPath), "epics"); - return (response.readEntity(new GenericType>() { })); + Response response = get( + Response.Status.OK, + getPageQueryParams(page, perPage), + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics"); + return (response.readEntity(new GenericType>() {})); } /** @@ -76,7 +81,8 @@ public List getEpics(Object groupIdOrPath, int page, int perPage) throws G * @throws GitLabApiException if any exception occurs */ public Pager getEpics(Object groupIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Epic.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "epics")); + return (new Pager( + this, Epic.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "epics")); } /** @@ -107,9 +113,11 @@ public Stream getEpicsStream(Object groupIdOrPath) throws GitLabApiExcepti * @return a list of matching epics of the requested group and its subgroups * @throws GitLabApiException if any exception occurs */ - public List getEpics(Object groupIdOrPath, Long authorId, String labels, EpicOrderBy orderBy, - SortOrder sortOrder, String search) throws GitLabApiException { - return (getEpics(groupIdOrPath, authorId, labels, orderBy, sortOrder, search, getDefaultPerPage()).all()); + public List getEpics( + Object groupIdOrPath, Long authorId, String labels, EpicOrderBy orderBy, SortOrder sortOrder, String search) + throws GitLabApiException { + return (getEpics(groupIdOrPath, authorId, labels, orderBy, sortOrder, search, getDefaultPerPage()) + .all()); } /** @@ -129,8 +137,16 @@ public List getEpics(Object groupIdOrPath, Long authorId, String labels, E * @return a list of matching epics of the requested group and its subgroups in the specified range * @throws GitLabApiException if any exception occurs */ - public List getEpics(Object groupIdOrPath, Long authorId, String labels, - EpicOrderBy orderBy, SortOrder sortOrder, String search, int page, int perPage) throws GitLabApiException { + public List getEpics( + Object groupIdOrPath, + Long authorId, + String labels, + EpicOrderBy orderBy, + SortOrder sortOrder, + String search, + int page, + int perPage) + throws GitLabApiException { EpicFilter filter = createEpicFilter(authorId, labels, orderBy, sortOrder, search); return getEpics(groupIdOrPath, filter); } @@ -165,8 +181,15 @@ public List getEpics(Object groupIdOrPath, EpicFilter filter) throws GitLa * @return the Pager of matching epics of the requested group and its subgroups * @throws GitLabApiException if any exception occurs */ - public Pager getEpics(Object groupIdOrPath, Long authorId, String labels, - EpicOrderBy orderBy, SortOrder sortOrder, String search, int itemsPerPage) throws GitLabApiException { + public Pager getEpics( + Object groupIdOrPath, + Long authorId, + String labels, + EpicOrderBy orderBy, + SortOrder sortOrder, + String search, + int itemsPerPage) + throws GitLabApiException { EpicFilter filter = createEpicFilter(authorId, labels, orderBy, sortOrder, search); return getEpics(groupIdOrPath, itemsPerPage, filter); } @@ -183,16 +206,24 @@ public Pager getEpics(Object groupIdOrPath, Long authorId, String labels, * @throws GitLabApiException if any exception occurs */ public Pager getEpics(Object groupIdOrPath, int itemsPerPage, EpicFilter filter) throws GitLabApiException { - return (new Pager(this, Epic.class, itemsPerPage, filter.getQueryParams().asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "epics")); - } - - private EpicFilter createEpicFilter(Long authorId, String labels, EpicOrderBy orderBy, SortOrder sortOrder, String search) { + return (new Pager( + this, + Epic.class, + itemsPerPage, + filter.getQueryParams().asMap(), + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics")); + } + + private EpicFilter createEpicFilter( + Long authorId, String labels, EpicOrderBy orderBy, SortOrder sortOrder, String search) { return new EpicFilter() - .withAuthorId(authorId) - .withLabels(labels) - .withOrderBy(orderBy) - .withSortOrder(sortOrder) - .withSearch(search); + .withAuthorId(authorId) + .withLabels(labels) + .withOrderBy(orderBy) + .withSortOrder(sortOrder) + .withSearch(search); } /** @@ -210,8 +241,9 @@ private EpicFilter createEpicFilter(Long authorId, String labels, EpicOrderBy or * @return a Stream of matching epics of the requested group and its subgroups * @throws GitLabApiException if any exception occurs */ - public Stream getEpicsStream(Object groupIdOrPath, Long authorId, String labels, EpicOrderBy orderBy, - SortOrder sortOrder, String search) throws GitLabApiException { + public Stream getEpicsStream( + Object groupIdOrPath, Long authorId, String labels, EpicOrderBy orderBy, SortOrder sortOrder, String search) + throws GitLabApiException { return (getEpics(groupIdOrPath, authorId, labels, orderBy, sortOrder, search, getDefaultPerPage()).stream()); } @@ -263,8 +295,9 @@ public Optional getOptionalEpic(Object groupIdOrPath, Long epicIid) { * @deprecated use {@link #createEpic(Object, String, String, String, Date, Date, Date)} instead */ @Deprecated - public Epic createEpic(Object groupIdOrPath, String title, String labels, String description, - Date startDate, Date endDate) throws GitLabApiException { + public Epic createEpic( + Object groupIdOrPath, String title, String labels, String description, Date startDate, Date endDate) + throws GitLabApiException { return createEpic(groupIdOrPath, title, labels, description, startDate, endDate, null); } @@ -283,8 +316,15 @@ public Epic createEpic(Object groupIdOrPath, String title, String labels, String * @return an Epic instance containing info on the newly created epic * @throws GitLabApiException if any exception occurs */ - public Epic createEpic(Object groupIdOrPath, String title, String labels, String description, - Date startDate, Date endDate, Date createdAt) throws GitLabApiException { + public Epic createEpic( + Object groupIdOrPath, + String title, + String labels, + String description, + Date startDate, + Date endDate, + Date createdAt) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("title", title, true) .withParam("labels", labels) @@ -292,8 +332,8 @@ public Epic createEpic(Object groupIdOrPath, String title, String labels, String .withParam("start_date", startDate) .withParam("end_date", endDate) .withParam("created_at", createdAt); - Response response = post(Response.Status.CREATED, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "epics"); + Response response = + post(Response.Status.CREATED, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "epics"); return (response.readEntity(Epic.class)); } @@ -323,8 +363,8 @@ public Epic createEpic(Object groupIdOrPath, Epic epic) throws GitLabApiExceptio .withParam("start_date", epic.getStartDate()) .withParam("end_date", epic.getEndDate()) .withParam("created_at", epic.getCreatedAt()); - Response response = post(Response.Status.CREATED, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "epics"); + Response response = + post(Response.Status.CREATED, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "epics"); return (response.readEntity(Epic.class)); } @@ -345,11 +385,18 @@ public Epic createEpic(Object groupIdOrPath, Epic epic) throws GitLabApiExceptio * @deprecated use {@link #updateEpic(Object, Long, String, String, String, Date, Date, StateEvent, Boolean, Long)} instead */ @Deprecated - public Epic updateEpic(Object groupIdOrPath, Long epicIid, String title, String labels, String description, - Date startDate, Date endDate) throws GitLabApiException { + public Epic updateEpic( + Object groupIdOrPath, + Long epicIid, + String title, + String labels, + String description, + Date startDate, + Date endDate) + throws GitLabApiException { return updateEpic(groupIdOrPath, epicIid, title, labels, description, startDate, endDate, null, null, null); } - + /** * Updates an existing epic. * @@ -368,8 +415,18 @@ public Epic updateEpic(Object groupIdOrPath, Long epicIid, String title, String * @return an Epic instance containing info on the newly created epic * @throws GitLabApiException if any exception occurs */ - public Epic updateEpic(Object groupIdOrPath, Long epicIid, String title, String labels, String description, - Date startDate, Date endDate, StateEvent stateEvent, Boolean confidential, Long parentId) throws GitLabApiException { + public Epic updateEpic( + Object groupIdOrPath, + Long epicIid, + String title, + String labels, + String description, + Date startDate, + Date endDate, + StateEvent stateEvent, + Boolean confidential, + Long parentId) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("title", title, true) .withParam("labels", labels) @@ -379,8 +436,8 @@ public Epic updateEpic(Object groupIdOrPath, Long epicIid, String title, String .withParam("state_event", stateEvent) .withParam("confidential", confidential) .withParam("parent_id", parentId); - Response response = put(Response.Status.OK, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid); + Response response = + put(Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid); return (response.readEntity(Epic.class)); } @@ -410,8 +467,8 @@ public Epic updateEpic(Object groupIdOrPath, Long epicIid, Epic epic) throws Git .withParam("start_date", epic.getStartDate()) .withParam("end_date", epic.getEndDate()) .withParam("parent_id", epic.getParentId()); - Response response = put(Response.Status.OK, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid); + Response response = + put(Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid); return (response.readEntity(Epic.class)); } @@ -455,9 +512,17 @@ public List getEpicIssues(Object groupIdOrPath, Long epicIid) throws * @return a list of all issues belonging to the specified epic in the specified range * @throws GitLabApiException if any exception occurs */ - public List getEpicIssues(Object groupIdOrPath, Long epicIid, int page, int perPage) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "issues"); - return (response.readEntity(new GenericType>() { })); + public List getEpicIssues(Object groupIdOrPath, Long epicIid, int page, int perPage) + throws GitLabApiException { + Response response = get( + Response.Status.OK, + getPageQueryParams(page, perPage), + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics", + epicIid, + "issues"); + return (response.readEntity(new GenericType>() {})); } /** @@ -471,8 +536,18 @@ public List getEpicIssues(Object groupIdOrPath, Long epicIid, int pag * @return the Pager of all issues belonging to the specified epic * @throws GitLabApiException if any exception occurs */ - public Pager getEpicIssues(Object groupIdOrPath, Long epicIid, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, EpicIssue.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "issues")); + public Pager getEpicIssues(Object groupIdOrPath, Long epicIid, int itemsPerPage) + throws GitLabApiException { + return (new Pager( + this, + EpicIssue.class, + itemsPerPage, + null, + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics", + epicIid, + "issues")); } /** @@ -502,8 +577,15 @@ public Stream getEpicIssuesStream(Object groupIdOrPath, Long epicIid) * @throws GitLabApiException if any exception occurs */ public EpicIssue assignIssue(Object groupIdOrPath, Long epicIid, Long issueId) throws GitLabApiException { - Response response = post(Response.Status.CREATED, (Form)null, - "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "issues", issueId); + Response response = post( + Response.Status.CREATED, + (Form) null, + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics", + epicIid, + "issues", + issueId); return (response.readEntity(EpicIssue.class)); } @@ -519,8 +601,15 @@ public EpicIssue assignIssue(Object groupIdOrPath, Long epicIid, Long issueId) t * @throws GitLabApiException if any exception occurs */ public EpicIssueLink removeIssue(Object groupIdOrPath, Long epicIid, Long epicIssueId) throws GitLabApiException { - Response response = delete(Response.Status.OK, null, - "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "issues", epicIssueId); + Response response = delete( + Response.Status.OK, + null, + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics", + epicIid, + "issues", + epicIssueId); return (response.readEntity(EpicIssueLink.class)); } @@ -537,12 +626,20 @@ public EpicIssueLink removeIssue(Object groupIdOrPath, Long epicIid, Long epicIs * @return a list of all issues belonging to the specified epic * @throws GitLabApiException if any exception occurs */ - public List updateIssue(Object groupIdOrPath, Long epicIid, Long epicIssueId, Long moveBeforeId, Long moveAfterId) throws GitLabApiException { - GitLabApiForm form = new GitLabApiForm() - .withParam("move_before_id", moveBeforeId) - .withParam("move_after_id", moveAfterId); - Response response = put(Response.Status.OK, form, - "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "issues", epicIssueId); + public List updateIssue( + Object groupIdOrPath, Long epicIid, Long epicIssueId, Long moveBeforeId, Long moveAfterId) + throws GitLabApiException { + GitLabApiForm form = + new GitLabApiForm().withParam("move_before_id", moveBeforeId).withParam("move_after_id", moveAfterId); + Response response = put( + Response.Status.OK, + form, + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics", + epicIid, + "issues", + epicIssueId); return response.readEntity(new GenericType>() {}); } @@ -571,8 +668,18 @@ public List getChildEpics(Object groupIdOrPath, Long epicIid) throws * @return the Pager of all child epics of the specified epic * @throws GitLabApiException if any exception occurs */ - public Pager getChildEpics(Object groupIdOrPath, Long epicIid, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, ChildEpic.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "epics")); + public Pager getChildEpics(Object groupIdOrPath, Long epicIid, int itemsPerPage) + throws GitLabApiException { + return (new Pager( + this, + ChildEpic.class, + itemsPerPage, + null, + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics", + epicIid, + "epics")); } /** @@ -601,8 +708,15 @@ public Stream getChildEpicsStream(Object groupIdOrPath, Long epicIid) * @throws GitLabApiException if any exception occurs */ public ChildEpic assignChildEpic(Object groupIdOrPath, Long epicIid, Long childEpicId) throws GitLabApiException { - Response response = post(Response.Status.CREATED, (Form)null, - "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "epics", childEpicId); + Response response = post( + Response.Status.CREATED, + (Form) null, + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics", + epicIid, + "epics", + childEpicId); return (response.readEntity(ChildEpic.class)); } @@ -618,12 +732,17 @@ public ChildEpic assignChildEpic(Object groupIdOrPath, Long epicIid, Long childE * @return an ChildEpic instance containing info on the newly created and assigned child epic * @throws GitLabApiException if any exception occurs */ - public CreatedChildEpic createAndAssignChildEpic(Object groupIdOrPath, Long epicIid, String title, Boolean confidential) throws GitLabApiException { - Form formData = new GitLabApiForm() - .withParam("title", title, true) - .withParam("confidential", confidential); - Response response = post(Response.Status.CREATED, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "epics"); + public CreatedChildEpic createAndAssignChildEpic( + Object groupIdOrPath, Long epicIid, String title, Boolean confidential) throws GitLabApiException { + Form formData = new GitLabApiForm().withParam("title", title, true).withParam("confidential", confidential); + Response response = post( + Response.Status.CREATED, + formData.asMap(), + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics", + epicIid, + "epics"); return (response.readEntity(CreatedChildEpic.class)); } @@ -640,12 +759,20 @@ public CreatedChildEpic createAndAssignChildEpic(Object groupIdOrPath, Long epic * @return a list of all child epics of the specified epic * @throws GitLabApiException if any exception occurs */ - public List reOrderChildEpic(Object groupIdOrPath, Long epicIid, Long childEpicId, Long moveBeforeId, Long moveAfterId) throws GitLabApiException { - GitLabApiForm form = new GitLabApiForm() - .withParam("move_before_id", moveBeforeId) - .withParam("move_after_id", moveAfterId); - Response response = put(Response.Status.OK, form.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "epics", childEpicId); + public List reOrderChildEpic( + Object groupIdOrPath, Long epicIid, Long childEpicId, Long moveBeforeId, Long moveAfterId) + throws GitLabApiException { + GitLabApiForm form = + new GitLabApiForm().withParam("move_before_id", moveBeforeId).withParam("move_after_id", moveAfterId); + Response response = put( + Response.Status.OK, + form.asMap(), + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics", + epicIid, + "epics", + childEpicId); return response.readEntity(new GenericType>() {}); } @@ -661,8 +788,15 @@ public List reOrderChildEpic(Object groupIdOrPath, Long epicIid, Long * @throws GitLabApiException if any exception occurs */ public ChildEpic unassignChildEpic(Object groupIdOrPath, Long epicIid, Long childEpicId) throws GitLabApiException { - Response response = delete(Response.Status.OK, null, - "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "epics", childEpicId); + Response response = delete( + Response.Status.OK, + null, + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics", + epicIid, + "epics", + childEpicId); return (response.readEntity(ChildEpic.class)); } @@ -691,8 +825,18 @@ public List getRelatedEpics(Object groupIdOrPath, Long epicIid) thr * @return the Pager of all related epics of the specified epic * @throws GitLabApiException if any exception occurs */ - public Pager getRelatedEpics(Object groupIdOrPath, Long epicIid, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, RelatedEpic.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "related_epics")); + public Pager getRelatedEpics(Object groupIdOrPath, Long epicIid, int itemsPerPage) + throws GitLabApiException { + return (new Pager( + this, + RelatedEpic.class, + itemsPerPage, + null, + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics", + epicIid, + "related_epics")); } /** @@ -722,13 +866,21 @@ public Stream getRelatedEpicsStream(Object groupIdOrPath, Long epic * @return an RelatedEpic instance containing info on the newly assigned child epic * @throws GitLabApiException if any exception occurs */ - public RelatedEpicLink createRelatedEpicLink(Object groupIdOrPath, Long epicIid, Object targetGroupIdOrPath, Long targetEpicIid, LinkType linkType) throws GitLabApiException { + public RelatedEpicLink createRelatedEpicLink( + Object groupIdOrPath, Long epicIid, Object targetGroupIdOrPath, Long targetEpicIid, LinkType linkType) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("target_group_id", getGroupIdOrPath(targetGroupIdOrPath), true) .withParam("target_epic_iid", targetEpicIid, true) .withParam("link_type", linkType); - Response response = post(Response.Status.CREATED, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "related_epics"); + Response response = post( + Response.Status.CREATED, + formData.asMap(), + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics", + epicIid, + "related_epics"); return (response.readEntity(RelatedEpicLink.class)); } @@ -743,10 +895,17 @@ public RelatedEpicLink createRelatedEpicLink(Object groupIdOrPath, Long epicIid, * @return an RelatedEpicLink instance containing info on the removed related epic * @throws GitLabApiException if any exception occurs */ - public RelatedEpicLink deleteRelatedEpicLink(Object groupIdOrPath, Long epicIid, Long relatedEpicLinkId) throws GitLabApiException { - Response response = delete(Response.Status.OK, null, - "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "related_epics", relatedEpicLinkId); + public RelatedEpicLink deleteRelatedEpicLink(Object groupIdOrPath, Long epicIid, Long relatedEpicLinkId) + throws GitLabApiException { + Response response = delete( + Response.Status.OK, + null, + "groups", + getGroupIdOrPath(groupIdOrPath), + "epics", + epicIid, + "related_epics", + relatedEpicLinkId); return (response.readEntity(RelatedEpicLink.class)); } - } diff --git a/src/main/java/org/gitlab4j/api/EventsApi.java b/src/main/java/org/gitlab4j/api/EventsApi.java index cea0e62e5..022b1a66f 100644 --- a/src/main/java/org/gitlab4j/api/EventsApi.java +++ b/src/main/java/org/gitlab4j/api/EventsApi.java @@ -31,9 +31,11 @@ public EventsApi(GitLabApi gitLabApi) { * @return a list of events for the authenticated user and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public List getAuthenticatedUserEvents(ActionType action, TargetType targetType, - Date before, Date after, SortOrder sortOrder) throws GitLabApiException { - return (getAuthenticatedUserEvents(action, targetType, before, after, sortOrder, getDefaultPerPage()).all()); + public List getAuthenticatedUserEvents( + ActionType action, TargetType targetType, Date before, Date after, SortOrder sortOrder) + throws GitLabApiException { + return (getAuthenticatedUserEvents(action, targetType, before, after, sortOrder, getDefaultPerPage()) + .all()); } /** @@ -49,9 +51,12 @@ public List getAuthenticatedUserEvents(ActionType action, TargetType targ * @return a list of events for the authenticated user and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public List getAllAuthenticatedUserEvents(ActionType action, TargetType targetType, - Date before, Date after, SortOrder sortOrder) throws GitLabApiException { - return (getAuthenticatedUserEvents(action, targetType, before, after, sortOrder, getDefaultPerPage(), EventScope.ALL).all()); + public List getAllAuthenticatedUserEvents( + ActionType action, TargetType targetType, Date before, Date after, SortOrder sortOrder) + throws GitLabApiException { + return (getAuthenticatedUserEvents( + action, targetType, before, after, sortOrder, getDefaultPerPage(), EventScope.ALL) + .all()); } /** @@ -69,8 +74,15 @@ public List getAllAuthenticatedUserEvents(ActionType action, TargetType t * @return a list of events for the authenticated user and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public List getAuthenticatedUserEvents(ActionType action, TargetType targetType, - Date before, Date after, SortOrder sortOrder, int page, int perPage) throws GitLabApiException { + public List getAuthenticatedUserEvents( + ActionType action, + TargetType targetType, + Date before, + Date after, + SortOrder sortOrder, + int page, + int perPage) + throws GitLabApiException { return (getAuthenticatedUserEvents(action, targetType, before, after, sortOrder, page, perPage, null)); } @@ -86,20 +98,29 @@ public List getAuthenticatedUserEvents(ActionType action, TargetType targ * @param sortOrder sort events in ASC or DESC order by created_at. Default is DESC, optional * @param page the page to get * @param perPage the number of projects per page - * @param scope include all events across a user’s projects, optional + * @param scope include all events across a user’s projects, optional * @return a list of events for the authenticated user and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public List getAuthenticatedUserEvents(ActionType action, TargetType targetType, - Date before, Date after, SortOrder sortOrder, int page, int perPage, EventScope scope) throws GitLabApiException { + public List getAuthenticatedUserEvents( + ActionType action, + TargetType targetType, + Date before, + Date after, + SortOrder sortOrder, + int page, + int perPage, + EventScope scope) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("action", action) - .withParam("target_type", targetType != null ? targetType.toValue().toLowerCase() : null) + .withParam( + "target_type", targetType != null ? targetType.toValue().toLowerCase() : null) .withParam("before", before) .withParam("after", after) .withParam("sort", sortOrder) - .withParam(PAGE_PARAM, page) + .withParam(PAGE_PARAM, page) .withParam(PER_PAGE_PARAM, perPage) .withParam("scope", scope != null ? scope.toValue().toLowerCase() : null); @@ -121,8 +142,9 @@ public List getAuthenticatedUserEvents(ActionType action, TargetType targ * @return a Pager of events for the authenticated user and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public Pager getAuthenticatedUserEvents(ActionType action, TargetType targetType, Date before, Date after, - SortOrder sortOrder, int itemsPerPage) throws GitLabApiException { + public Pager getAuthenticatedUserEvents( + ActionType action, TargetType targetType, Date before, Date after, SortOrder sortOrder, int itemsPerPage) + throws GitLabApiException { return (getAuthenticatedUserEvents(action, targetType, before, after, sortOrder, itemsPerPage, null)); } @@ -137,16 +159,24 @@ public Pager getAuthenticatedUserEvents(ActionType action, TargetType tar * @param after include only events created after a particular date, optional * @param sortOrder sort events in ASC or DESC order by created_at. Default is DESC, optional * @param itemsPerPage the number of Event instances that will be fetched per page - * @param scope include all events across a user’s projects, optional + * @param scope include all events across a user’s projects, optional * @return a Pager of events for the authenticated user and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public Pager getAuthenticatedUserEvents(ActionType action, TargetType targetType, Date before, Date after, - SortOrder sortOrder, int itemsPerPage, EventScope scope) throws GitLabApiException { + public Pager getAuthenticatedUserEvents( + ActionType action, + TargetType targetType, + Date before, + Date after, + SortOrder sortOrder, + int itemsPerPage, + EventScope scope) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("action", action) - .withParam("target_type", targetType != null ? targetType.toValue().toLowerCase() : null) + .withParam( + "target_type", targetType != null ? targetType.toValue().toLowerCase() : null) .withParam("before", before) .withParam("after", after) .withParam("sort", sortOrder) @@ -168,9 +198,11 @@ public Pager getAuthenticatedUserEvents(ActionType action, TargetType tar * @return a Stream of events for the authenticated user and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public Stream getAuthenticatedUserEventsStream(ActionType action, TargetType targetType, - Date before, Date after, SortOrder sortOrder) throws GitLabApiException { - return (getAuthenticatedUserEvents(action, targetType, before, after, sortOrder, getDefaultPerPage(), null).stream()); + public Stream getAuthenticatedUserEventsStream( + ActionType action, TargetType targetType, Date before, Date after, SortOrder sortOrder) + throws GitLabApiException { + return (getAuthenticatedUserEvents(action, targetType, before, after, sortOrder, getDefaultPerPage(), null) + .stream()); } /** @@ -186,9 +218,12 @@ public Stream getAuthenticatedUserEventsStream(ActionType action, TargetT * @return a Stream of events for the authenticated user and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public Stream getAllAuthenticatedUserEventsStream(ActionType action, TargetType targetType, - Date before, Date after, SortOrder sortOrder) throws GitLabApiException { - return (getAuthenticatedUserEvents(action, targetType, before, after, sortOrder, getDefaultPerPage(), EventScope.ALL).stream()); + public Stream getAllAuthenticatedUserEventsStream( + ActionType action, TargetType targetType, Date before, Date after, SortOrder sortOrder) + throws GitLabApiException { + return (getAuthenticatedUserEvents( + action, targetType, before, after, sortOrder, getDefaultPerPage(), EventScope.ALL) + .stream()); } /** @@ -205,9 +240,16 @@ public Stream getAllAuthenticatedUserEventsStream(ActionType action, Targ * @return a list of events for the specified user and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public List getUserEvents(Object userIdOrUsername, ActionType action, TargetType targetType, - Date before, Date after, SortOrder sortOrder) throws GitLabApiException { - return (getUserEvents(userIdOrUsername, action, targetType, before, after, sortOrder, getDefaultPerPage()).all()); + public List getUserEvents( + Object userIdOrUsername, + ActionType action, + TargetType targetType, + Date before, + Date after, + SortOrder sortOrder) + throws GitLabApiException { + return (getUserEvents(userIdOrUsername, action, targetType, before, after, sortOrder, getDefaultPerPage()) + .all()); } /** @@ -226,20 +268,29 @@ public List getUserEvents(Object userIdOrUsername, ActionType action, Tar * @return a list of events for the specified user and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public List getUserEvents(Object userIdOrUsername, ActionType action, TargetType targetType, - Date before, Date after, SortOrder sortOrder, int page, int perPage) throws GitLabApiException { + public List getUserEvents( + Object userIdOrUsername, + ActionType action, + TargetType targetType, + Date before, + Date after, + SortOrder sortOrder, + int page, + int perPage) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("action", action) - .withParam("target_type", targetType != null ? targetType.toValue().toLowerCase() : null) + .withParam( + "target_type", targetType != null ? targetType.toValue().toLowerCase() : null) .withParam("before", before) .withParam("after", after) .withParam("sort", sortOrder) - .withParam(PAGE_PARAM, page) + .withParam(PAGE_PARAM, page) .withParam(PER_PAGE_PARAM, perPage); - Response response = get(Response.Status.OK, formData.asMap(), - "users", getUserIdOrUsername(userIdOrUsername), "events"); + Response response = + get(Response.Status.OK, formData.asMap(), "users", getUserIdOrUsername(userIdOrUsername), "events"); return (response.readEntity(new GenericType>() {})); } @@ -258,18 +309,32 @@ public List getUserEvents(Object userIdOrUsername, ActionType action, Tar * @return a Pager of events for the specified user and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public Pager getUserEvents(Object userIdOrUsername, ActionType action, TargetType targetType, Date before, Date after, - SortOrder sortOrder, int itemsPerPage) throws GitLabApiException { + public Pager getUserEvents( + Object userIdOrUsername, + ActionType action, + TargetType targetType, + Date before, + Date after, + SortOrder sortOrder, + int itemsPerPage) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("action", action) - .withParam("target_type", targetType != null ? targetType.toValue().toLowerCase() : null) + .withParam( + "target_type", targetType != null ? targetType.toValue().toLowerCase() : null) .withParam("before", before) .withParam("after", after) .withParam("sort", sortOrder); - return (new Pager(this, Event.class, itemsPerPage, formData.asMap(), - "users", getUserIdOrUsername(userIdOrUsername), "events")); + return (new Pager( + this, + Event.class, + itemsPerPage, + formData.asMap(), + "users", + getUserIdOrUsername(userIdOrUsername), + "events")); } /** @@ -286,9 +351,16 @@ public Pager getUserEvents(Object userIdOrUsername, ActionType action, Ta * @return a Stream of events for the specified user and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public Stream getUserEventsStream(Object userIdOrUsername, ActionType action, TargetType targetType, - Date before, Date after, SortOrder sortOrder) throws GitLabApiException { - return (getUserEvents(userIdOrUsername, action, targetType, before, after, sortOrder, getDefaultPerPage()).stream()); + public Stream getUserEventsStream( + Object userIdOrUsername, + ActionType action, + TargetType targetType, + Date before, + Date after, + SortOrder sortOrder) + throws GitLabApiException { + return (getUserEvents(userIdOrUsername, action, targetType, before, after, sortOrder, getDefaultPerPage()) + .stream()); } /** @@ -305,9 +377,16 @@ public Stream getUserEventsStream(Object userIdOrUsername, ActionType act * @return a list of events for the specified project and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public List getProjectEvents(Object projectIdOrPath, ActionType action, TargetType targetType, - Date before, Date after, SortOrder sortOrder) throws GitLabApiException { - return (getProjectEvents(projectIdOrPath, action, targetType, before, after, sortOrder, getDefaultPerPage()).all()); + public List getProjectEvents( + Object projectIdOrPath, + ActionType action, + TargetType targetType, + Date before, + Date after, + SortOrder sortOrder) + throws GitLabApiException { + return (getProjectEvents(projectIdOrPath, action, targetType, before, after, sortOrder, getDefaultPerPage()) + .all()); } /** @@ -326,20 +405,29 @@ public List getProjectEvents(Object projectIdOrPath, ActionType action, T * @return a list of events for the specified project and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public List getProjectEvents(Object projectIdOrPath, ActionType action, TargetType targetType, - Date before, Date after, SortOrder sortOrder, int page, int perPage) throws GitLabApiException { + public List getProjectEvents( + Object projectIdOrPath, + ActionType action, + TargetType targetType, + Date before, + Date after, + SortOrder sortOrder, + int page, + int perPage) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("action", action) - .withParam("target_type", targetType != null ? targetType.toValue().toLowerCase() : null) + .withParam( + "target_type", targetType != null ? targetType.toValue().toLowerCase() : null) .withParam("before", before) .withParam("after", after) .withParam("sort", sortOrder) - .withParam(PAGE_PARAM, page) + .withParam(PAGE_PARAM, page) .withParam(PER_PAGE_PARAM, perPage); - Response response = get(Response.Status.OK, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "events"); + Response response = + get(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "events"); return (response.readEntity(new GenericType>() {})); } @@ -358,18 +446,32 @@ public List getProjectEvents(Object projectIdOrPath, ActionType action, T * @return a Pager of events for the specified project and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public Pager getProjectEvents(Object projectIdOrPath, ActionType action, TargetType targetType, Date before, Date after, - SortOrder sortOrder, int itemsPerPage) throws GitLabApiException { + public Pager getProjectEvents( + Object projectIdOrPath, + ActionType action, + TargetType targetType, + Date before, + Date after, + SortOrder sortOrder, + int itemsPerPage) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("action", action) - .withParam("target_type", targetType != null ? targetType.toValue().toLowerCase() : null) + .withParam( + "target_type", targetType != null ? targetType.toValue().toLowerCase() : null) .withParam("before", before) .withParam("after", after) .withParam("sort", sortOrder); - return (new Pager(this, Event.class, itemsPerPage, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "events")); + return (new Pager( + this, + Event.class, + itemsPerPage, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "events")); } /** @@ -386,8 +488,15 @@ public Pager getProjectEvents(Object projectIdOrPath, ActionType action, * @return a Stream of events for the specified project and matching the supplied parameters * @throws GitLabApiException if any exception occurs */ - public Stream getProjectEventsStream(Object projectIdOrPath, ActionType action, TargetType targetType, - Date before, Date after, SortOrder sortOrder) throws GitLabApiException { - return (getProjectEvents(projectIdOrPath, action, targetType, before, after, sortOrder, getDefaultPerPage()).stream()); + public Stream getProjectEventsStream( + Object projectIdOrPath, + ActionType action, + TargetType targetType, + Date before, + Date after, + SortOrder sortOrder) + throws GitLabApiException { + return (getProjectEvents(projectIdOrPath, action, targetType, before, after, sortOrder, getDefaultPerPage()) + .stream()); } } diff --git a/src/main/java/org/gitlab4j/api/ExternalStatusCheckApi.java b/src/main/java/org/gitlab4j/api/ExternalStatusCheckApi.java index e0d04a26d..b883a0112 100644 --- a/src/main/java/org/gitlab4j/api/ExternalStatusCheckApi.java +++ b/src/main/java/org/gitlab4j/api/ExternalStatusCheckApi.java @@ -46,9 +46,16 @@ public List getExternalStatusChecks(Object projectIdOrPath) * @return the Pager of ExternalStatusCheck instances * @throws GitLabApiException if any exception occurs */ - public Pager getExternalStatusChecks(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, ExternalStatusCheck.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "external_status_checks")); + public Pager getExternalStatusChecks(Object projectIdOrPath, int itemsPerPage) + throws GitLabApiException { + return (new Pager( + this, + ExternalStatusCheck.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "external_status_checks")); } /** @@ -76,13 +83,19 @@ public Stream getExternalStatusChecksStream(Object projectI * @return an ExternalStatusCheck instance containing info on the newly created externalStatusCheck * @throws GitLabApiException if any exception occurs */ - public ExternalStatusCheck createExternalStatusCheck(Object projectIdOrPath, String name, String externalUrl, List protectedBranchIds) throws GitLabApiException { + public ExternalStatusCheck createExternalStatusCheck( + Object projectIdOrPath, String name, String externalUrl, List protectedBranchIds) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("name", name, true) .withParam("external_url", externalUrl, true) .withParam("protected_branch_ids", protectedBranchIds); - Response response = post(Response.Status.CREATED, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "external_status_checks"); + Response response = post( + Response.Status.CREATED, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "external_status_checks"); return (response.readEntity(ExternalStatusCheck.class)); } @@ -102,19 +115,26 @@ public ExternalStatusCheck createExternalStatusCheck(Object projectIdOrPath, Str * @return an ExternalStatusCheck instance containing info on the newly created externalStatusCheck * @throws GitLabApiException if any exception occurs */ - public ExternalStatusCheck createExternalStatusCheck(Object projectIdOrPath, ExternalStatusCheck externalStatusCheck) throws GitLabApiException { + public ExternalStatusCheck createExternalStatusCheck( + Object projectIdOrPath, ExternalStatusCheck externalStatusCheck) throws GitLabApiException { List protectedBranchIds; - if(externalStatusCheck.getProtectedBranches() == null) { + if (externalStatusCheck.getProtectedBranches() == null) { protectedBranchIds = null; } else { - protectedBranchIds = externalStatusCheck.getProtectedBranches().stream().map(ExternalStatusCheckProtectedBranch::getId).collect(Collectors.toList()); + protectedBranchIds = externalStatusCheck.getProtectedBranches().stream() + .map(ExternalStatusCheckProtectedBranch::getId) + .collect(Collectors.toList()); } Form formData = new GitLabApiForm() .withParam("name", externalStatusCheck.getName(), true) .withParam("external_url", externalStatusCheck.getExternalUrl(), true) .withParam("protected_branch_ids", protectedBranchIds); - Response response = post(Response.Status.CREATED, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "external_status_checks"); + Response response = post( + Response.Status.CREATED, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "external_status_checks"); return (response.readEntity(ExternalStatusCheck.class)); } @@ -131,13 +151,20 @@ public ExternalStatusCheck createExternalStatusCheck(Object projectIdOrPath, Ext * @return an ExternalStatusCheck instance containing info on the newly created ExternalStatusCheck * @throws GitLabApiException if any exception occurs */ - public ExternalStatusCheck updateExternalStatusCheck(Object projectIdOrPath, Long checkId, String name, String externalUrl, List protectedBranchIds) throws GitLabApiException { + public ExternalStatusCheck updateExternalStatusCheck( + Object projectIdOrPath, Long checkId, String name, String externalUrl, List protectedBranchIds) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("name", name) .withParam("external_url", externalUrl) .withParam("protected_branch_ids", protectedBranchIds); - Response response = put(Response.Status.OK, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "external_status_checks", checkId); + Response response = put( + Response.Status.OK, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "external_status_checks", + checkId); return (response.readEntity(ExternalStatusCheck.class)); } @@ -157,7 +184,8 @@ public ExternalStatusCheck updateExternalStatusCheck(Object projectIdOrPath, Lon * @return an ExternalStatusCheck instance containing info on the updated ExternalStatusCheck * @throws GitLabApiException if any exception occurs */ - public ExternalStatusCheck updateExternalStatusCheck(Object projectIdOrPath, ExternalStatusCheck externalStatusCheck) throws GitLabApiException { + public ExternalStatusCheck updateExternalStatusCheck( + Object projectIdOrPath, ExternalStatusCheck externalStatusCheck) throws GitLabApiException { if (externalStatusCheck == null || externalStatusCheck.getId() == null) { throw new GitLabApiException("the specified external status check is null or has no id"); } @@ -166,16 +194,23 @@ public ExternalStatusCheck updateExternalStatusCheck(Object projectIdOrPath, Ext .withParam("name", externalStatusCheck.getName()) .withParam("external_url", externalStatusCheck.getExternalUrl()) .withParam("protected_branch_ids", protectedBranchIds); - Response response = put(Response.Status.OK, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "external_status_checks", externalStatusCheck.getId()); + Response response = put( + Response.Status.OK, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "external_status_checks", + externalStatusCheck.getId()); return (response.readEntity(ExternalStatusCheck.class)); } private List getProtectedBranchIds(ExternalStatusCheck externalStatusCheck) { - if(externalStatusCheck.getProtectedBranches() == null) { + if (externalStatusCheck.getProtectedBranches() == null) { return null; } - return externalStatusCheck.getProtectedBranches().stream().map(ExternalStatusCheckProtectedBranch::getId).collect(Collectors.toList()); + return externalStatusCheck.getProtectedBranches().stream() + .map(ExternalStatusCheckProtectedBranch::getId) + .collect(Collectors.toList()); } /** @@ -188,7 +223,13 @@ private List getProtectedBranchIds(ExternalStatusCheck externalStatusCheck * @throws GitLabApiException if any exception occurs */ public void deleteExternalStatusCheck(Object projectIdOrPath, Long checkId) throws GitLabApiException { - delete(Response.Status.NO_CONTENT, null, "projects", getProjectIdOrPath(projectIdOrPath), "external_status_checks", checkId); + delete( + Response.Status.NO_CONTENT, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "external_status_checks", + checkId); } /** @@ -201,8 +242,10 @@ public void deleteExternalStatusCheck(Object projectIdOrPath, Long checkId) thro * @return a List of ExternalStatusCheckStatus * @throws GitLabApiException if any exception occurs */ - public List getExternalStatusCheckStatuses(Object projectIdOrPath, Long mergeRequestIid) throws GitLabApiException { - return (getExternalStatusCheckStatuses(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).all()); + public List getExternalStatusCheckStatuses(Object projectIdOrPath, Long mergeRequestIid) + throws GitLabApiException { + return (getExternalStatusCheckStatuses(projectIdOrPath, mergeRequestIid, getDefaultPerPage()) + .all()); } /** @@ -216,9 +259,18 @@ public List getExternalStatusCheckStatuses(Object pro * @return the Pager of ExternalStatusCheckStatus instances * @throws GitLabApiException if any exception occurs */ - public Pager getExternalStatusCheckStatuses(Object projectIdOrPath, Long mergeRequestIid, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, ExternalStatusCheckStatus.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "status_checks")); + public Pager getExternalStatusCheckStatuses( + Object projectIdOrPath, Long mergeRequestIid, int itemsPerPage) throws GitLabApiException { + return (new Pager( + this, + ExternalStatusCheckStatus.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "status_checks")); } /** @@ -231,7 +283,8 @@ public Pager getExternalStatusCheckStatuses(Object pr * @return a Stream of ExternalStatusCheckStatus * @throws GitLabApiException if any exception occurs */ - public Stream getExternalStatusCheckStatusesStream(Object projectIdOrPath, Long mergeRequestIid) throws GitLabApiException { + public Stream getExternalStatusCheckStatusesStream( + Object projectIdOrPath, Long mergeRequestIid) throws GitLabApiException { return (getExternalStatusCheckStatuses(projectIdOrPath, mergeRequestIid, getDefaultPerPage()).stream()); } @@ -248,13 +301,21 @@ public Stream getExternalStatusCheckStatusesStream(Ob * @return an ExternalStatusCheckResult instance containing info on the newly created status * @throws GitLabApiException if any exception occurs */ - public ExternalStatusCheckResult setStatusOfExternalStatusCheck(Object projectIdOrPath, Long mergeRequestIid, String sha, Long externalStatusCheckId, Status status) throws GitLabApiException { + public ExternalStatusCheckResult setStatusOfExternalStatusCheck( + Object projectIdOrPath, Long mergeRequestIid, String sha, Long externalStatusCheckId, Status status) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("sha", sha) .withParam("external_status_check_id", externalStatusCheckId) .withParam("status", status); - Response response = post(Response.Status.CREATED, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "status_check_responses"); + Response response = post( + Response.Status.CREATED, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "status_check_responses"); return (response.readEntity(ExternalStatusCheckResult.class)); } @@ -268,8 +329,17 @@ public ExternalStatusCheckResult setStatusOfExternalStatusCheck(Object projectId * @param externalStatusCheckId ID of an external status check * @throws GitLabApiException if any exception occurs */ - public void retryExternalStatusCheck(Object projectIdOrPath, Long mergeRequestIid, Long externalStatusCheckId) throws GitLabApiException { - post(Response.Status.ACCEPTED, (Form)null, "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "status_checks", externalStatusCheckId, "retry"); + public void retryExternalStatusCheck(Object projectIdOrPath, Long mergeRequestIid, Long externalStatusCheckId) + throws GitLabApiException { + post( + Response.Status.ACCEPTED, + (Form) null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests", + mergeRequestIid, + "status_checks", + externalStatusCheckId, + "retry"); } - } diff --git a/src/main/java/org/gitlab4j/api/GitLabApi.java b/src/main/java/org/gitlab4j/api/GitLabApi.java index a9cc3f924..4a3847af6 100644 --- a/src/main/java/org/gitlab4j/api/GitLabApi.java +++ b/src/main/java/org/gitlab4j/api/GitLabApi.java @@ -26,14 +26,15 @@ */ public class GitLabApi implements AutoCloseable { - private final static Logger LOGGER = Logger.getLogger(GitLabApi.class.getName()); + private static final Logger LOGGER = Logger.getLogger(GitLabApi.class.getName()); /** GitLab4J default per page. GitLab will ignore anything over 100. */ public static final int DEFAULT_PER_PAGE = 96; /** Specifies the version of the GitLab API to communicate with. */ public enum ApiVersion { - V3, V4; + V3, + V4; public String getApiNamespace() { return ("/api/" + name().toLowerCase()); @@ -85,7 +86,7 @@ public String getApiNamespace() { private PipelineApi pipelineApi; private ProjectApi projectApi; private ProtectedBranchesApi protectedBranchesApi; - private ReleaseLinksApi releaseLinksApi; + private ReleaseLinksApi releaseLinksApi; private ReleasesApi releasesApi; private RepositoryApi repositoryApi; private RepositoryFileApi repositoryFileApi; @@ -178,7 +179,9 @@ public static GitLabApi oauth2Login(String url, String username, char[] password * @return new {@code GitLabApi} instance configured for a user-specific token * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public static GitLabApi oauth2Login(String url, String username, CharSequence password, boolean ignoreCertificateErrors) throws GitLabApiException { + public static GitLabApi oauth2Login( + String url, String username, CharSequence password, boolean ignoreCertificateErrors) + throws GitLabApiException { return (GitLabApi.oauth2Login(ApiVersion.V4, url, username, password, null, null, ignoreCertificateErrors)); } @@ -193,10 +196,12 @@ public static GitLabApi oauth2Login(String url, String username, CharSequence pa * @return new {@code GitLabApi} instance configured for a user-specific token * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public static GitLabApi oauth2Login(String url, String username, char[] password, boolean ignoreCertificateErrors) throws GitLabApiException { + public static GitLabApi oauth2Login(String url, String username, char[] password, boolean ignoreCertificateErrors) + throws GitLabApiException { try (SecretString secretPassword = new SecretString(password)) { - return (GitLabApi.oauth2Login(ApiVersion.V4, url, username, secretPassword, null, null, ignoreCertificateErrors)); + return (GitLabApi.oauth2Login( + ApiVersion.V4, url, username, secretPassword, null, null, ignoreCertificateErrors)); } } @@ -213,9 +218,16 @@ public static GitLabApi oauth2Login(String url, String username, char[] password * @return new {@code GitLabApi} instance configured for a user-specific token * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public static GitLabApi oauth2Login(String url, String username, CharSequence password, String secretToken, - Map clientConfigProperties, boolean ignoreCertificateErrors) throws GitLabApiException { - return (GitLabApi.oauth2Login(ApiVersion.V4, url, username, password, secretToken, clientConfigProperties, ignoreCertificateErrors)); + public static GitLabApi oauth2Login( + String url, + String username, + CharSequence password, + String secretToken, + Map clientConfigProperties, + boolean ignoreCertificateErrors) + throws GitLabApiException { + return (GitLabApi.oauth2Login( + ApiVersion.V4, url, username, password, secretToken, clientConfigProperties, ignoreCertificateErrors)); } /** @@ -231,12 +243,24 @@ public static GitLabApi oauth2Login(String url, String username, CharSequence pa * @return new {@code GitLabApi} instance configured for a user-specific token * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public static GitLabApi oauth2Login(String url, String username, char[] password, String secretToken, - Map clientConfigProperties, boolean ignoreCertificateErrors) throws GitLabApiException { + public static GitLabApi oauth2Login( + String url, + String username, + char[] password, + String secretToken, + Map clientConfigProperties, + boolean ignoreCertificateErrors) + throws GitLabApiException { try (SecretString secretPassword = new SecretString(password)) { - return (GitLabApi.oauth2Login(ApiVersion.V4, url, username, secretPassword, - secretToken, clientConfigProperties, ignoreCertificateErrors)); + return (GitLabApi.oauth2Login( + ApiVersion.V4, + url, + username, + secretPassword, + secretToken, + clientConfigProperties, + ignoreCertificateErrors)); } } @@ -254,12 +278,25 @@ public static GitLabApi oauth2Login(String url, String username, char[] password * @return new {@code GitLabApi} instance configured for a user-specific token * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public static GitLabApi oauth2Login(ApiVersion apiVersion, String url, String username, char[] password, String secretToken, - Map clientConfigProperties, boolean ignoreCertificateErrors) throws GitLabApiException { + public static GitLabApi oauth2Login( + ApiVersion apiVersion, + String url, + String username, + char[] password, + String secretToken, + Map clientConfigProperties, + boolean ignoreCertificateErrors) + throws GitLabApiException { try (SecretString secretPassword = new SecretString(password)) { - return (GitLabApi.oauth2Login(apiVersion, url, username, secretPassword, - secretToken, clientConfigProperties, ignoreCertificateErrors)); + return (GitLabApi.oauth2Login( + apiVersion, + url, + username, + secretPassword, + secretToken, + clientConfigProperties, + ignoreCertificateErrors)); } } @@ -277,15 +314,22 @@ public static GitLabApi oauth2Login(ApiVersion apiVersion, String url, String us * @return new {@code GitLabApi} instance configured for a user-specific token * @throws GitLabApiException GitLabApiException if any exception occurs during execution */ - public static GitLabApi oauth2Login(ApiVersion apiVersion, String url, String username, CharSequence password, - String secretToken, Map clientConfigProperties, boolean ignoreCertificateErrors) throws GitLabApiException { + public static GitLabApi oauth2Login( + ApiVersion apiVersion, + String url, + String username, + CharSequence password, + String secretToken, + Map clientConfigProperties, + boolean ignoreCertificateErrors) + throws GitLabApiException { if (username == null || username.trim().length() == 0) { throw new IllegalArgumentException("both username and email cannot be empty or null"); } // Create a GitLabApi instance set up to be used to do an OAUTH2 login. - GitLabApi gitLabApi = new GitLabApi(apiVersion, url, (String)null); + GitLabApi gitLabApi = new GitLabApi(apiVersion, url, (String) null); gitLabApi.apiClient.setHostUrlToBaseUrl(); if (ignoreCertificateErrors) { @@ -300,9 +344,16 @@ class Oauth2Api extends AbstractApi { try (Oauth2LoginStreamingOutput stream = new Oauth2LoginStreamingOutput(username, password)) { - Response response = new Oauth2Api(gitLabApi).post(Response.Status.OK, stream, MediaType.APPLICATION_JSON, "oauth", "token"); + Response response = new Oauth2Api(gitLabApi) + .post(Response.Status.OK, stream, MediaType.APPLICATION_JSON, "oauth", "token"); OauthTokenResponse oauthToken = response.readEntity(OauthTokenResponse.class); - gitLabApi = new GitLabApi(apiVersion, url, TokenType.OAUTH2_ACCESS, oauthToken.getAccessToken(), secretToken, clientConfigProperties); + gitLabApi = new GitLabApi( + apiVersion, + url, + TokenType.OAUTH2_ACCESS, + oauthToken.getAccessToken(), + secretToken, + clientConfigProperties); if (ignoreCertificateErrors) { gitLabApi.setIgnoreCertificateErrors(true); } @@ -391,7 +442,12 @@ public GitLabApi(String hostUrl, TokenType tokenType, String authToken, String s * @param secretToken use this token to validate received payloads * @param clientConfigProperties Map instance with additional properties for the Jersey client connection */ - public GitLabApi(ApiVersion apiVersion, String hostUrl, String personalAccessToken, String secretToken, Map clientConfigProperties) { + public GitLabApi( + ApiVersion apiVersion, + String hostUrl, + String personalAccessToken, + String secretToken, + Map clientConfigProperties) { this(apiVersion, hostUrl, TokenType.PRIVATE, personalAccessToken, secretToken, clientConfigProperties); } @@ -404,11 +460,16 @@ public GitLabApi(ApiVersion apiVersion, String hostUrl, String personalAccessTok * @param secretToken use this token to validate received payloads * @param clientConfigProperties Map instance with additional properties for the Jersey client connection */ - public GitLabApi(String hostUrl, TokenType tokenType, String authToken, String secretToken, Map clientConfigProperties) { + public GitLabApi( + String hostUrl, + TokenType tokenType, + String authToken, + String secretToken, + Map clientConfigProperties) { this(ApiVersion.V4, hostUrl, tokenType, authToken, secretToken, clientConfigProperties); } - /** + /** * Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4. * * @param hostUrl the URL of the GitLab server @@ -416,20 +477,24 @@ public GitLabApi(String hostUrl, TokenType tokenType, String authToken, String s * @param secretToken use this token to validate received payloads * @param clientConfigProperties Map instance with additional properties for the Jersey client connection */ - public GitLabApi(String hostUrl, String personalAccessToken, String secretToken, Map clientConfigProperties) { + public GitLabApi( + String hostUrl, + String personalAccessToken, + String secretToken, + Map clientConfigProperties) { this(ApiVersion.V4, hostUrl, TokenType.PRIVATE, personalAccessToken, secretToken, clientConfigProperties); } /** - * Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4. - * - * @param hostUrl the URL of the GitLab server - * @param personalAccessToken the private token to use for access to the API - * @param clientConfigProperties Map instance with additional properties for the Jersey client connection - */ - public GitLabApi(String hostUrl, String personalAccessToken, Map clientConfigProperties) { - this(ApiVersion.V4, hostUrl, TokenType.PRIVATE, personalAccessToken, null, clientConfigProperties); - } + * Constructs a GitLabApi instance set up to interact with the GitLab server using GitLab API version 4. + * + * @param hostUrl the URL of the GitLab server + * @param personalAccessToken the private token to use for access to the API + * @param clientConfigProperties Map instance with additional properties for the Jersey client connection + */ + public GitLabApi(String hostUrl, String personalAccessToken, Map clientConfigProperties) { + this(ApiVersion.V4, hostUrl, TokenType.PRIVATE, personalAccessToken, null, clientConfigProperties); + } /** * Constructs a GitLabApi instance set up to interact with the GitLab server specified by GitLab API version. @@ -441,7 +506,13 @@ public GitLabApi(String hostUrl, String personalAccessToken, Map * @param secretToken use this token to validate received payloads * @param clientConfigProperties Map instance with additional properties for the Jersey client connection */ - public GitLabApi(ApiVersion apiVersion, String hostUrl, TokenType tokenType, String authToken, String secretToken, Map clientConfigProperties) { + public GitLabApi( + ApiVersion apiVersion, + String hostUrl, + TokenType tokenType, + String authToken, + String secretToken, + Map clientConfigProperties) { this.apiVersion = apiVersion; this.gitLabServerUrl = hostUrl; this.clientConfigProperties = clientConfigProperties; @@ -456,8 +527,8 @@ public GitLabApi(ApiVersion apiVersion, String hostUrl, TokenType tokenType, Str public final GitLabApi duplicate() { Long sudoUserId = this.getSudoAsId(); - GitLabApi gitLabApi = new GitLabApi(apiVersion, gitLabServerUrl, - getTokenType(), getAuthToken(), getSecretToken(), clientConfigProperties); + GitLabApi gitLabApi = new GitLabApi( + apiVersion, gitLabServerUrl, getTokenType(), getAuthToken(), getSecretToken(), clientConfigProperties); if (sudoUserId != null) { gitLabApi.apiClient.setSudoAsId(sudoUserId); } @@ -487,7 +558,7 @@ public void close() { * @param readTimeout the per request read timeout in milliseconds, can be null to use default */ public void setRequestTimeout(Integer connectTimeout, Integer readTimeout) { - apiClient.setRequestTimeout(connectTimeout, readTimeout); + apiClient.setRequestTimeout(connectTimeout, readTimeout); } /** @@ -498,8 +569,8 @@ public void setRequestTimeout(Integer connectTimeout, Integer readTimeout) { * @return this GitLabApi instance */ public GitLabApi withRequestTimeout(Integer connectTimeout, Integer readTimeout) { - apiClient.setRequestTimeout(connectTimeout, readTimeout); - return (this); + apiClient.setRequestTimeout(connectTimeout, readTimeout); + return (this); } /** @@ -643,7 +714,8 @@ public void enableRequestResponseLogging(Level level, int maxEntitySize, List maskedHeaderNames) { + public void enableRequestResponseLogging( + Logger logger, Level level, int maxEntitySize, List maskedHeaderNames) { apiClient.enableRequestResponseLogging(logger, level, maxEntitySize, maskedHeaderNames); } @@ -1004,7 +1076,7 @@ public DeploymentsApi getDeploymentsApi() { * * @return the DeployTokensApi instance owned by this GitLabApi instance */ - public DeployTokensApi getDeployTokensApi(){ + public DeployTokensApi getDeployTokensApi() { if (deployTokensApi == null) { synchronized (this) { @@ -1126,7 +1198,6 @@ public GitLabCiYamlApi getGitLabCiYamlApi() { return gitLabCiYaml; } - /** * Gets the GroupApi instance owned by this GitLabApi instance. The GroupApi is used * to perform all group related API calls. @@ -1273,7 +1344,6 @@ public LicenseTemplatesApi getLicenseTemplatesApi() { return (licenseTemplatesApi); } - /** * Gets the MarkdownApi instance owned by this GitLabApi instance. The MarkdownApi is used * to perform all markdown related API calls. @@ -1810,7 +1880,6 @@ public MetadataApi getMetadataApi() { return metadataApi; } - /** * Create and return an Optional instance associated with a GitLabApiException. * @@ -1820,7 +1889,7 @@ public MetadataApi getMetadataApi() { */ protected static final Optional createOptionalFromException(GitLabApiException glae) { Optional optional = Optional.empty(); - optionalExceptionMap.put(System.identityHashCode(optional), glae); + optionalExceptionMap.put(System.identityHashCode(optional), glae); return (optional); } diff --git a/src/main/java/org/gitlab4j/api/GitLabApiClient.java b/src/main/java/org/gitlab4j/api/GitLabApiClient.java index ea11c8119..b1e7a0f68 100755 --- a/src/main/java/org/gitlab4j/api/GitLabApiClient.java +++ b/src/main/java/org/gitlab4j/api/GitLabApiClient.java @@ -14,6 +14,7 @@ import java.util.function.Supplier; import java.util.logging.Level; import java.util.logging.Logger; + import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; @@ -30,6 +31,7 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; + import org.gitlab4j.api.Constants.TokenType; import org.gitlab4j.api.GitLabApi.ApiVersion; import org.gitlab4j.api.utils.JacksonJson; @@ -48,15 +50,14 @@ import org.glassfish.jersey.media.multipart.file.FileDataBodyPart; import org.glassfish.jersey.media.multipart.file.StreamDataBodyPart; - /** * This class utilizes the Jersey client package to communicate with a GitLab API endpoint. */ public class GitLabApiClient implements AutoCloseable { - protected static final String PRIVATE_TOKEN_HEADER = "PRIVATE-TOKEN"; - protected static final String SUDO_HEADER = "Sudo"; - protected static final String AUTHORIZATION_HEADER = "Authorization"; + protected static final String PRIVATE_TOKEN_HEADER = "PRIVATE-TOKEN"; + protected static final String SUDO_HEADER = "Sudo"; + protected static final String AUTHORIZATION_HEADER = "Authorization"; protected static final String X_GITLAB_TOKEN_HEADER = "X-Gitlab-Token"; private ClientConfig clientConfig; @@ -144,7 +145,8 @@ public GitLabApiClient(ApiVersion apiVersion, String hostUrl, String privateToke * @param authToken the token to authenticate with * @param secretToken use this token to validate received payloads */ - public GitLabApiClient(ApiVersion apiVersion, String hostUrl, TokenType tokenType, String authToken, String secretToken) { + public GitLabApiClient( + ApiVersion apiVersion, String hostUrl, TokenType tokenType, String authToken, String secretToken) { this(apiVersion, hostUrl, tokenType, authToken, secretToken, null); } @@ -182,7 +184,8 @@ public GitLabApiClient(String hostUrl, TokenType tokenType, String authToken, St * @param secretToken use this token to validate received payloads * @param clientConfigProperties the properties given to Jersey's clientconfig */ - public GitLabApiClient(String hostUrl, String privateToken, String secretToken, Map clientConfigProperties) { + public GitLabApiClient( + String hostUrl, String privateToken, String secretToken, Map clientConfigProperties) { this(ApiVersion.V4, hostUrl, TokenType.PRIVATE, privateToken, secretToken, clientConfigProperties); } @@ -196,7 +199,12 @@ public GitLabApiClient(String hostUrl, String privateToken, String secretToken, * @param secretToken use this token to validate received payloads * @param clientConfigProperties the properties given to Jersey's clientconfig */ - public GitLabApiClient(ApiVersion apiVersion, String hostUrl, String privateToken, String secretToken, Map clientConfigProperties) { + public GitLabApiClient( + ApiVersion apiVersion, + String hostUrl, + String privateToken, + String secretToken, + Map clientConfigProperties) { this(apiVersion, hostUrl, TokenType.PRIVATE, privateToken, secretToken, clientConfigProperties); } @@ -211,7 +219,13 @@ public GitLabApiClient(ApiVersion apiVersion, String hostUrl, String privateToke * @param secretToken use this token to validate received payloads * @param clientConfigProperties the properties given to Jersey's clientconfig */ - public GitLabApiClient(ApiVersion apiVersion, String hostUrl, TokenType tokenType, String authToken, String secretToken, Map clientConfigProperties) { + public GitLabApiClient( + ApiVersion apiVersion, + String hostUrl, + TokenType tokenType, + String authToken, + String secretToken, + Map clientConfigProperties) { // Remove the trailing "/" from the hostUrl if present this.hostUrl = (hostUrl.endsWith("/") ? hostUrl.replaceAll("/$", "") : hostUrl); @@ -272,7 +286,8 @@ public void close() { */ void enableRequestResponseLogging(Logger logger, Level level, int maxEntityLength, List maskedHeaderNames) { - MaskingLoggingFilter loggingFilter = new MaskingLoggingFilter(logger, level, maxEntityLength, maskedHeaderNames); + MaskingLoggingFilter loggingFilter = + new MaskingLoggingFilter(logger, level, maxEntityLength, maskedHeaderNames); clientConfig.register(loggingFilter); // Recreate the Client instance if already created. @@ -381,12 +396,10 @@ private String appendPathArgs(String url, Object... pathArgs) { */ protected boolean validateSecretToken(Response response) { - if (this.secretToken == null) - return (true); + if (this.secretToken == null) return (true); String secretToken = response.getHeaderString(X_GITLAB_TOKEN_HEADER); - if (secretToken == null) - return (false); + if (secretToken == null) return (false); return (this.secretToken.equals(secretToken)); } @@ -427,7 +440,8 @@ protected Response get(MultivaluedMap queryParams, URL url) { * @return a ClientResponse instance with the data returned from the endpoint * @throws IOException if an error occurs while constructing the URL */ - protected Response getWithAccepts(MultivaluedMap queryParams, String accepts, Object... pathArgs) throws IOException { + protected Response getWithAccepts(MultivaluedMap queryParams, String accepts, Object... pathArgs) + throws IOException { URL url = getApiUrl(pathArgs); return (getWithAccepts(queryParams, url, accepts)); } @@ -497,7 +511,8 @@ protected Response patch(MultivaluedMap queryParams, URL url) { Entity empty = Entity.text(""); // use "X-HTTP-Method-Override" header on POST to override to unsupported PATCH return (invocation(url, queryParams) - .header("X-HTTP-Method-Override", "PATCH").post(empty)); + .header("X-HTTP-Method-Override", "PATCH") + .post(empty)); } /** @@ -538,7 +553,8 @@ protected Response post(MultivaluedMap queryParams, Object... pa */ protected Response post(Form formData, URL url) { if (formData instanceof GitLabApiForm) { - return (invocation(url, null).post(Entity.entity(formData.asMap(), MediaType.APPLICATION_FORM_URLENCODED_TYPE))); + return (invocation(url, null) + .post(Entity.entity(formData.asMap(), MediaType.APPLICATION_FORM_URLENCODED_TYPE))); } else if (formData != null) { return (invocation(url, null).post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED_TYPE))); } else { @@ -555,7 +571,8 @@ protected Response post(Form formData, URL url) { * @return a ClientResponse instance with the data returned from the endpoint */ protected Response post(MultivaluedMap queryParams, URL url) { - return (invocation(url, queryParams).post(Entity.entity(new Form(), MediaType.APPLICATION_FORM_URLENCODED_TYPE))); + return (invocation(url, queryParams) + .post(Entity.entity(new Form(), MediaType.APPLICATION_FORM_URLENCODED_TYPE))); } /** @@ -599,7 +616,8 @@ protected Response post(StreamingOutput stream, String mediaType, Object... path * @return a ClientResponse instance with the data returned from the endpoint * @throws IOException if an error occurs while constructing the URL */ - protected Response upload(String name, File fileToUpload, String mediaTypeString, Object... pathArgs) throws IOException { + protected Response upload(String name, File fileToUpload, String mediaTypeString, Object... pathArgs) + throws IOException { return upload(name, fileToUpload, mediaTypeString, null, pathArgs); } @@ -615,7 +633,8 @@ protected Response upload(String name, File fileToUpload, String mediaTypeString * @return a ClientResponse instance with the data returned from the endpoint * @throws IOException if an error occurs while constructing the URL */ - protected Response upload(String name, File fileToUpload, String mediaTypeString, Form formData, Object... pathArgs) throws IOException { + protected Response upload(String name, File fileToUpload, String mediaTypeString, Form formData, Object... pathArgs) + throws IOException { URL url = getApiUrl(pathArgs); return (upload(name, fileToUpload, mediaTypeString, formData, url)); } @@ -632,17 +651,22 @@ protected Response upload(String name, File fileToUpload, String mediaTypeString * @return a ClientResponse instance with the data returned from the endpoint * @throws IOException if an error occurs while constructing the URL */ - protected Response upload(String name, File fileToUpload, String mediaTypeString, Form formData, URL url) throws IOException { + protected Response upload(String name, File fileToUpload, String mediaTypeString, Form formData, URL url) + throws IOException { FileDataBodyPart filePart = new FileDataBodyPart(name, fileToUpload); return upload(filePart, formData, url); } - protected Response upload(String name, InputStream inputStream, String filename, String mediaTypeString, Object... pathArgs) throws IOException { + protected Response upload( + String name, InputStream inputStream, String filename, String mediaTypeString, Object... pathArgs) + throws IOException { URL url = getApiUrl(pathArgs); return (upload(name, inputStream, filename, mediaTypeString, null, url)); } - protected Response upload(String name, InputStream inputStream, String filename, String mediaTypeString, Form formData, URL url) throws IOException { + protected Response upload( + String name, InputStream inputStream, String filename, String mediaTypeString, Form formData, URL url) + throws IOException { StreamDataBodyPart streamDataBodyPart = new StreamDataBodyPart(name, inputStream, filename); return upload(streamDataBodyPart, formData, url); } @@ -684,7 +708,7 @@ protected Response putUpload(String name, File fileToUpload, Object... pathArgs) * * @param name the name for the form field that contains the file name * @param fileToUpload a File instance pointing to the file to upload - + * * @param url the fully formed path to the GitLab API endpoint * @return a ClientResponse instance with the data returned from the endpoint * @throws IOException if an error occurs while constructing the URL @@ -692,7 +716,7 @@ protected Response putUpload(String name, File fileToUpload, Object... pathArgs) protected Response putUpload(String name, File fileToUpload, URL url) throws IOException { try (MultiPart multiPart = new FormDataMultiPart()) { - if(fileToUpload == null) { + if (fileToUpload == null) { multiPart.bodyPart(new FormDataBodyPart(name, "", MediaType.APPLICATION_OCTET_STREAM_TYPE)); } else { multiPart.bodyPart(new FileDataBodyPart(name, fileToUpload, MediaType.APPLICATION_OCTET_STREAM_TYPE)); @@ -757,9 +781,9 @@ protected Response put(Form formData, Object... pathArgs) throws IOException { */ protected Response put(Form formData, URL url) { if (formData instanceof GitLabApiForm) - return (invocation(url, null).put(Entity.entity(formData.asMap(), MediaType.APPLICATION_FORM_URLENCODED_TYPE))); - else - return (invocation(url, null).put(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED_TYPE))); + return (invocation(url, null) + .put(Entity.entity(formData.asMap(), MediaType.APPLICATION_FORM_URLENCODED_TYPE))); + else return (invocation(url, null).put(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED_TYPE))); } /** @@ -847,8 +871,7 @@ protected Invocation.Builder invocation(URL url, MultivaluedMap } // If sudo as ID is set add the Sudo header - if (sudoAsId != null && sudoAsId.intValue() > 0) - builder = builder.header(SUDO_HEADER, sudoAsId); + if (sudoAsId != null && sudoAsId.intValue() > 0) builder = builder.header(SUDO_HEADER, sudoAsId); // Set the per request connect timeout if (connectTimeout != null) { @@ -918,36 +941,36 @@ public void setIgnoreCertificateErrors(boolean ignoreCertificateErrors) { private boolean setupIgnoreCertificateErrors() { // Create a TrustManager that trusts all certificates - TrustManager[] trustAllCerts = new TrustManager[] { new X509ExtendedTrustManager() { - @Override - public X509Certificate[] getAcceptedIssuers() { - return null; - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { - } - - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + TrustManager[] trustAllCerts = new TrustManager[] { + new X509ExtendedTrustManager() { + @Override + public X509Certificate[] getAcceptedIssuers() { + return null; + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {} + + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {} + + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) + throws CertificateException {} + + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) + throws CertificateException {} + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) + throws CertificateException {} + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) + throws CertificateException {} } - - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException { - } - - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException { - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException { - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException { - } - }}; + }; // Ignore differences between given hostname and certificate hostname HostnameVerifier hostnameVerifier = new HostnameVerifier() { diff --git a/src/main/java/org/gitlab4j/api/GitLabApiException.java b/src/main/java/org/gitlab4j/api/GitLabApiException.java index 084ebb443..c7a7feafe 100755 --- a/src/main/java/org/gitlab4j/api/GitLabApiException.java +++ b/src/main/java/org/gitlab4j/api/GitLabApiException.java @@ -6,13 +6,13 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.StatusType; -import javax.ws.rs.core.MultivaluedMap; -import java.util.Objects; import org.gitlab4j.api.utils.JacksonJson; import com.fasterxml.jackson.databind.JsonNode; @@ -88,7 +88,7 @@ public GitLabApiException(Response response) { StringBuilder buf = new StringBuilder(); validationErrors = new HashMap<>(); Iterator> fields = jsonMessage.fields(); - while(fields.hasNext()) { + while (fields.hasNext()) { Entry field = fields.next(); String fieldName = field.getKey(); @@ -109,14 +109,14 @@ public GitLabApiException(Response response) { } else if (jsonMessage.isArray()) { - List values = new ArrayList<>(); - for (JsonNode value : jsonMessage) { + List values = new ArrayList<>(); + for (JsonNode value : jsonMessage) { values.add(value.asText()); - } + } - if (values.size() > 0) { - this.message = String.join("\n", values); - } + if (values.size() > 0) { + this.message = String.join("\n", values); + } } else if (jsonMessage.isTextual()) { this.message = jsonMessage.asText(); @@ -242,22 +242,19 @@ public boolean equals(Object obj) { } if (message == null) { - if (other.message != null) - return false; + if (other.message != null) return false; } else if (!message.equals(other.message)) { return false; } if (statusInfo == null) { - if (other.statusInfo != null) - return false; + if (other.statusInfo != null) return false; } else if (!statusInfo.equals(other.statusInfo)) { return false; } if (validationErrors == null) { - if (other.validationErrors != null) - return false; + if (other.validationErrors != null) return false; } else if (!validationErrors.equals(other.validationErrors)) { return false; } diff --git a/src/main/java/org/gitlab4j/api/GitLabApiForm.java b/src/main/java/org/gitlab4j/api/GitLabApiForm.java index f58deeb19..7d89865ca 100644 --- a/src/main/java/org/gitlab4j/api/GitLabApiForm.java +++ b/src/main/java/org/gitlab4j/api/GitLabApiForm.java @@ -1,219 +1,220 @@ -package org.gitlab4j.api; - -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import javax.ws.rs.core.Form; -import javax.ws.rs.core.MultivaluedHashMap; - -import org.gitlab4j.api.models.AccessLevel; -import org.gitlab4j.api.models.Variable; -import org.gitlab4j.api.utils.ISO8601; - -/** - * This class extends the standard JAX-RS Form class to make it fluent. - */ -public class GitLabApiForm extends Form { - - public GitLabApiForm() { - super(); - } - - public GitLabApiForm(MultivaluedHashMap map) { - super(map); - } - - /** - * Create a GitLabApiForm instance with the "page", and "per_page" parameters preset. - * - * @param page the value for the "page" parameter - * @param perPage the value for the "per_page" parameter - */ - public GitLabApiForm(int page, int perPage) { - super(); - withParam(AbstractApi.PAGE_PARAM, page); - withParam(AbstractApi.PER_PAGE_PARAM, (Integer)perPage); - } - - /** - * Fluent method for adding query and form parameters to a get() or post() call. - * - * @param name the name of the field/attribute to add - * @param value the value of the field/attribute to add - * @return this GitLabAPiForm instance - */ - public GitLabApiForm withParam(String name, Object value) throws IllegalArgumentException { - return (withParam(name, value, false)); - } - - /** - * Fluent method for adding Date query and form parameters to a get() or post() call. - * - * @param name the name of the field/attribute to add - * @param date the value of the field/attribute to add - * @return this GitLabAPiForm instance - */ - public GitLabApiForm withParam(String name, Date date) throws IllegalArgumentException { - return (withParam(name, date, false)); - } - - /** - * Fluent method for adding Date query and form parameters to a get() or post() call. - * - * @param name the name of the field/attribute to add - * @param date the value of the field/attribute to add - * @param required the field is required flag - * @return this GitLabAPiForm instance - * @throws IllegalArgumentException if a required parameter is null or empty - */ - public GitLabApiForm withParam(String name, Date date, boolean required) throws IllegalArgumentException { - return (withParam(name, (date == null ? null : ISO8601.toString(date)), required)); - } - - /** - * Fluent method for adding AccessLevel query and form parameters to a get() or post() call. - * - * @param name the name of the field/attribute to add - * @param level the value of the field/attribute to add - * @return this GitLabAPiForm instance - */ - public GitLabApiForm withParam(String name, AccessLevel level) throws IllegalArgumentException { - return (withParam(name, level, false)); - } - - /** - * Fluent method for adding AccessLevel query and form parameters to a get() or post() call. - * - * @param name the name of the field/attribute to add - * @param level the value of the field/attribute to add - * @param required the field is required flag - * @return this GitLabAPiForm instance - * @throws IllegalArgumentException if a required parameter is null or empty - */ - public GitLabApiForm withParam(String name, AccessLevel level, boolean required) throws IllegalArgumentException { - return (withParam(name, (level == null ? null : level.toValue()), required)); - } - - /** - * Fluent method for adding a List type query and form parameters to a get() or post() call. - * - * @param the type contained by the List - * @param name the name of the field/attribute to add - * @param values a List containing the values of the field/attribute to add - * @return this GitLabAPiForm instance - */ - public GitLabApiForm withParam(String name, List values) { - return (withParam(name, values, false)); - } - - /** - * Fluent method for adding a List type query and form parameters to a get() or post() call. - * - * @param the type contained by the List - * @param name the name of the field/attribute to add - * @param values a List containing the values of the field/attribute to add - * @param required the field is required flag - * @return this GitLabAPiForm instance - * @throws IllegalArgumentException if a required parameter is null or empty - */ - public GitLabApiForm withParam(String name, List values, boolean required) throws IllegalArgumentException { - - if (values == null || values.isEmpty()) { - if (required) { - throw new IllegalArgumentException(name + " cannot be empty or null"); - } - - return (this); - } - - for (T value : values) { - if (value != null) { - this.param(name + "[]", value.toString()); - } - } - - return (this); - } - - /** - * Fluent method for adding an array of hash type query and form parameters to a get() or post() call. - * - * @param name the name of the field/attribute to add - * @param variables a Map containing array of hashes - * @param required the field is required flag - * @return this GitLabAPiForm instance - * @throws IllegalArgumentException if a required parameter is null or empty - */ - public GitLabApiForm withParam(String name, Map variables, boolean required) throws IllegalArgumentException { - - if (variables == null || variables.isEmpty()) { - if (required) { - throw new IllegalArgumentException(name + " cannot be empty or null"); - } - - return (this); - } - - for (Entry variable : variables.entrySet()) { - Object value = variable.getValue(); - if (value != null) { - this.param(name + "[" + variable.getKey() + "]", value.toString()); - } - } - - return (this); - } - - /** - * Fluent method for adding query and form parameters to a get() or post() call. - * If required is true and value is null, will throw an IllegalArgumentException. - * - * @param name the name of the field/attribute to add - * @param value the value of the field/attribute to add - * @param required the field is required flag - * @return this GitLabAPiForm instance - * @throws IllegalArgumentException if a required parameter is null or empty - */ - public GitLabApiForm withParam(String name, Object value, boolean required) throws IllegalArgumentException { - - if (value == null) { - if (required) { - throw new IllegalArgumentException(name + " cannot be empty or null"); - } - - return (this); - } - - String stringValue = value.toString(); - if (required && stringValue.trim().length() == 0) { - throw new IllegalArgumentException(name + " cannot be empty or null"); - } - - this.param(name.trim(), stringValue); - return (this); - } - - /** - * Fluent method for adding a List<Variable> type query and form parameters to a get(), post(), or put() call. - * - * @param variables the List of Variable to add - * @return this GitLabAPiForm instance - */ - public GitLabApiForm withParam(List variables) { - - if (variables == null || variables.isEmpty()) { - return (this); - } - - variables.forEach(v -> { - String value = v.getValue(); - if (value != null) { - this.param("variables[" + v.getKey() + "]", value); - } - }); - - return (this); - } -} \ No newline at end of file +package org.gitlab4j.api; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.ws.rs.core.Form; +import javax.ws.rs.core.MultivaluedHashMap; + +import org.gitlab4j.api.models.AccessLevel; +import org.gitlab4j.api.models.Variable; +import org.gitlab4j.api.utils.ISO8601; + +/** + * This class extends the standard JAX-RS Form class to make it fluent. + */ +public class GitLabApiForm extends Form { + + public GitLabApiForm() { + super(); + } + + public GitLabApiForm(MultivaluedHashMap map) { + super(map); + } + + /** + * Create a GitLabApiForm instance with the "page", and "per_page" parameters preset. + * + * @param page the value for the "page" parameter + * @param perPage the value for the "per_page" parameter + */ + public GitLabApiForm(int page, int perPage) { + super(); + withParam(AbstractApi.PAGE_PARAM, page); + withParam(AbstractApi.PER_PAGE_PARAM, (Integer) perPage); + } + + /** + * Fluent method for adding query and form parameters to a get() or post() call. + * + * @param name the name of the field/attribute to add + * @param value the value of the field/attribute to add + * @return this GitLabAPiForm instance + */ + public GitLabApiForm withParam(String name, Object value) throws IllegalArgumentException { + return (withParam(name, value, false)); + } + + /** + * Fluent method for adding Date query and form parameters to a get() or post() call. + * + * @param name the name of the field/attribute to add + * @param date the value of the field/attribute to add + * @return this GitLabAPiForm instance + */ + public GitLabApiForm withParam(String name, Date date) throws IllegalArgumentException { + return (withParam(name, date, false)); + } + + /** + * Fluent method for adding Date query and form parameters to a get() or post() call. + * + * @param name the name of the field/attribute to add + * @param date the value of the field/attribute to add + * @param required the field is required flag + * @return this GitLabAPiForm instance + * @throws IllegalArgumentException if a required parameter is null or empty + */ + public GitLabApiForm withParam(String name, Date date, boolean required) throws IllegalArgumentException { + return (withParam(name, (date == null ? null : ISO8601.toString(date)), required)); + } + + /** + * Fluent method for adding AccessLevel query and form parameters to a get() or post() call. + * + * @param name the name of the field/attribute to add + * @param level the value of the field/attribute to add + * @return this GitLabAPiForm instance + */ + public GitLabApiForm withParam(String name, AccessLevel level) throws IllegalArgumentException { + return (withParam(name, level, false)); + } + + /** + * Fluent method for adding AccessLevel query and form parameters to a get() or post() call. + * + * @param name the name of the field/attribute to add + * @param level the value of the field/attribute to add + * @param required the field is required flag + * @return this GitLabAPiForm instance + * @throws IllegalArgumentException if a required parameter is null or empty + */ + public GitLabApiForm withParam(String name, AccessLevel level, boolean required) throws IllegalArgumentException { + return (withParam(name, (level == null ? null : level.toValue()), required)); + } + + /** + * Fluent method for adding a List type query and form parameters to a get() or post() call. + * + * @param the type contained by the List + * @param name the name of the field/attribute to add + * @param values a List containing the values of the field/attribute to add + * @return this GitLabAPiForm instance + */ + public GitLabApiForm withParam(String name, List values) { + return (withParam(name, values, false)); + } + + /** + * Fluent method for adding a List type query and form parameters to a get() or post() call. + * + * @param the type contained by the List + * @param name the name of the field/attribute to add + * @param values a List containing the values of the field/attribute to add + * @param required the field is required flag + * @return this GitLabAPiForm instance + * @throws IllegalArgumentException if a required parameter is null or empty + */ + public GitLabApiForm withParam(String name, List values, boolean required) throws IllegalArgumentException { + + if (values == null || values.isEmpty()) { + if (required) { + throw new IllegalArgumentException(name + " cannot be empty or null"); + } + + return (this); + } + + for (T value : values) { + if (value != null) { + this.param(name + "[]", value.toString()); + } + } + + return (this); + } + + /** + * Fluent method for adding an array of hash type query and form parameters to a get() or post() call. + * + * @param name the name of the field/attribute to add + * @param variables a Map containing array of hashes + * @param required the field is required flag + * @return this GitLabAPiForm instance + * @throws IllegalArgumentException if a required parameter is null or empty + */ + public GitLabApiForm withParam(String name, Map variables, boolean required) + throws IllegalArgumentException { + + if (variables == null || variables.isEmpty()) { + if (required) { + throw new IllegalArgumentException(name + " cannot be empty or null"); + } + + return (this); + } + + for (Entry variable : variables.entrySet()) { + Object value = variable.getValue(); + if (value != null) { + this.param(name + "[" + variable.getKey() + "]", value.toString()); + } + } + + return (this); + } + + /** + * Fluent method for adding query and form parameters to a get() or post() call. + * If required is true and value is null, will throw an IllegalArgumentException. + * + * @param name the name of the field/attribute to add + * @param value the value of the field/attribute to add + * @param required the field is required flag + * @return this GitLabAPiForm instance + * @throws IllegalArgumentException if a required parameter is null or empty + */ + public GitLabApiForm withParam(String name, Object value, boolean required) throws IllegalArgumentException { + + if (value == null) { + if (required) { + throw new IllegalArgumentException(name + " cannot be empty or null"); + } + + return (this); + } + + String stringValue = value.toString(); + if (required && stringValue.trim().length() == 0) { + throw new IllegalArgumentException(name + " cannot be empty or null"); + } + + this.param(name.trim(), stringValue); + return (this); + } + + /** + * Fluent method for adding a List<Variable> type query and form parameters to a get(), post(), or put() call. + * + * @param variables the List of Variable to add + * @return this GitLabAPiForm instance + */ + public GitLabApiForm withParam(List variables) { + + if (variables == null || variables.isEmpty()) { + return (this); + } + + variables.forEach(v -> { + String value = v.getValue(); + if (value != null) { + this.param("variables[" + v.getKey() + "]", value); + } + }); + + return (this); + } +} diff --git a/src/main/java/org/gitlab4j/api/GitLabCiYamlApi.java b/src/main/java/org/gitlab4j/api/GitLabCiYamlApi.java index a21084e60..5cb007739 100644 --- a/src/main/java/org/gitlab4j/api/GitLabCiYamlApi.java +++ b/src/main/java/org/gitlab4j/api/GitLabCiYamlApi.java @@ -1,6 +1,7 @@ package org.gitlab4j.api; import java.util.List; + import javax.ws.rs.core.GenericType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; @@ -45,5 +46,4 @@ public GitLabCiTemplate getSingleGitLabCiYamlTemplate(String key) throws GitLabA Response response = get(Status.OK, null, "templates", "gitlab_ci_ymls", key); return (response.readEntity(GitLabCiTemplate.class)); } - } diff --git a/src/main/java/org/gitlab4j/api/GroupApi.java b/src/main/java/org/gitlab4j/api/GroupApi.java index d7d66ca27..3404e8886 100644 --- a/src/main/java/org/gitlab4j/api/GroupApi.java +++ b/src/main/java/org/gitlab4j/api/GroupApi.java @@ -7,7 +7,6 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.ws.rs.core.Form; @@ -27,7 +26,6 @@ import org.gitlab4j.api.models.GroupFilter; import org.gitlab4j.api.models.GroupParams; import org.gitlab4j.api.models.GroupProjectsFilter; -import org.gitlab4j.api.models.ImpersonationToken; import org.gitlab4j.api.models.ImpersonationToken.Scope; import org.gitlab4j.api.models.Iteration; import org.gitlab4j.api.models.IterationFilter; @@ -69,8 +67,9 @@ public List getGroups() throws GitLabApiException { String url = this.gitLabApi.getGitLabServerUrl(); if (url.startsWith("https://gitlab.com")) { - GitLabApi.getLogger().warning("Fetching all groups from " + url + - " may take many minutes to complete, use Pager getGroups(int) instead."); + GitLabApi.getLogger() + .warning("Fetching all groups from " + url + + " may take many minutes to complete, use Pager getGroups(int) instead."); } return (getGroups(getDefaultPerPage()).all()); @@ -137,7 +136,10 @@ public List getGroups(String search) throws GitLabApiException { * @throws GitLabApiException if any exception occurs */ public List getGroups(String search, int page, int perPage) throws GitLabApiException { - Form formData = new GitLabApiForm().withParam("search", search).withParam(PAGE_PARAM, page).withParam(PER_PAGE_PARAM, perPage); + Form formData = new GitLabApiForm() + .withParam("search", search) + .withParam(PAGE_PARAM, page) + .withParam(PER_PAGE_PARAM, perPage); Response response = get(Response.Status.OK, formData.asMap(), "groups"); return (response.readEntity(new GenericType>() {})); } @@ -233,7 +235,8 @@ public List getSubGroups(Object groupIdOrPath) throws GitLabApiException * @since GitLab 10.3.0 */ public Pager getSubGroups(Object groupIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Group.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "subgroups")); + return (new Pager( + this, Group.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "subgroups")); } /** @@ -267,9 +270,27 @@ public Stream getSubGroupsStream(Object groupIdOrPath) throws GitLabApiEx * @throws GitLabApiException if any exception occurs * @since GitLab 10.3.0 */ - public List getSubGroups(Object groupIdOrPath, List skipGroups, Boolean allAvailable, String search, - GroupOrderBy orderBy, SortOrder sortOrder, Boolean statistics, Boolean owned) throws GitLabApiException { - return (getSubGroups(groupIdOrPath, skipGroups, allAvailable, search, orderBy, sortOrder, statistics, owned, getDefaultPerPage()).all()); + public List getSubGroups( + Object groupIdOrPath, + List skipGroups, + Boolean allAvailable, + String search, + GroupOrderBy orderBy, + SortOrder sortOrder, + Boolean statistics, + Boolean owned) + throws GitLabApiException { + return (getSubGroups( + groupIdOrPath, + skipGroups, + allAvailable, + search, + orderBy, + sortOrder, + statistics, + owned, + getDefaultPerPage()) + .all()); } /** @@ -291,8 +312,17 @@ public List getSubGroups(Object groupIdOrPath, List skipGroups, * @throws GitLabApiException if any exception occurs * @since GitLab 10.3.0 */ - public List getSubGroups(Object groupIdOrPath, List skipGroups, Boolean allAvailable, String search, - GroupOrderBy orderBy, SortOrder sortOrder, Boolean statistics, Boolean owned, int page, int perPage) + public List getSubGroups( + Object groupIdOrPath, + List skipGroups, + Boolean allAvailable, + String search, + GroupOrderBy orderBy, + SortOrder sortOrder, + Boolean statistics, + Boolean owned, + int page, + int perPage) throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("skip_groups", skipGroups) @@ -304,7 +334,8 @@ public List getSubGroups(Object groupIdOrPath, List skipGroups, .withParam("owned", owned) .withParam(PAGE_PARAM, page) .withParam(PER_PAGE_PARAM, perPage); - Response response = get(Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "subgroups"); + Response response = + get(Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "subgroups"); return (response.readEntity(new GenericType>() {})); } @@ -326,8 +357,17 @@ public List getSubGroups(Object groupIdOrPath, List skipGroups, * @throws GitLabApiException if any exception occurs * @since GitLab 10.3.0 */ - public Pager getSubGroups(Object groupIdOrPath, List skipGroups, Boolean allAvailable, String search, - GroupOrderBy orderBy, SortOrder sortOrder, Boolean statistics, Boolean owned, int itemsPerPage) throws GitLabApiException { + public Pager getSubGroups( + Object groupIdOrPath, + List skipGroups, + Boolean allAvailable, + String search, + GroupOrderBy orderBy, + SortOrder sortOrder, + Boolean statistics, + Boolean owned, + int itemsPerPage) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("skip_groups", skipGroups) .withParam("all_available", allAvailable) @@ -336,7 +376,14 @@ public Pager getSubGroups(Object groupIdOrPath, List skipGroups, .withParam("sort_order", sortOrder) .withParam("statistics", statistics) .withParam("owned", owned); - return (new Pager(this, Group.class, itemsPerPage, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "subgroups")); + return (new Pager( + this, + Group.class, + itemsPerPage, + formData.asMap(), + "groups", + getGroupIdOrPath(groupIdOrPath), + "subgroups")); } /** @@ -356,9 +403,27 @@ public Pager getSubGroups(Object groupIdOrPath, List skipGroups, * @throws GitLabApiException if any exception occurs * @since GitLab 10.3.0 */ - public Stream getSubGroupsStream(Object groupIdOrPath, List skipGroups, Boolean allAvailable, String search, - GroupOrderBy orderBy, SortOrder sortOrder, Boolean statistics, Boolean owned) throws GitLabApiException { - return (getSubGroups(groupIdOrPath, skipGroups, allAvailable, search, orderBy, sortOrder, statistics, owned, getDefaultPerPage()).stream()); + public Stream getSubGroupsStream( + Object groupIdOrPath, + List skipGroups, + Boolean allAvailable, + String search, + GroupOrderBy orderBy, + SortOrder sortOrder, + Boolean statistics, + Boolean owned) + throws GitLabApiException { + return (getSubGroups( + groupIdOrPath, + skipGroups, + allAvailable, + search, + orderBy, + sortOrder, + statistics, + owned, + getDefaultPerPage()) + .stream()); } /** @@ -386,9 +451,17 @@ public List getDescendantGroups(Object groupIdOrPath, GroupFilter filter) * @return a Pager containing matching Group instances * @throws GitLabApiException if any exception occurs */ - public Pager getDescendantGroups(Object groupIdOrPath, GroupFilter filter, int itemsPerPage) throws GitLabApiException { + public Pager getDescendantGroups(Object groupIdOrPath, GroupFilter filter, int itemsPerPage) + throws GitLabApiException { GitLabApiForm formData = filter.getQueryParams(); - return (new Pager(this, Group.class, itemsPerPage, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "descendant_groups")); + return (new Pager( + this, + Group.class, + itemsPerPage, + formData.asMap(), + "groups", + getGroupIdOrPath(groupIdOrPath), + "descendant_groups")); } /** @@ -430,9 +503,17 @@ public List getProjects(Object groupIdOrPath, GroupProjectsFilter filte * @return a Pager containing Project instances that belong to the group and match the provided filter * @throws GitLabApiException if any exception occurs */ - public Pager getProjects(Object groupIdOrPath, GroupProjectsFilter filter, int itemsPerPage) throws GitLabApiException { + public Pager getProjects(Object groupIdOrPath, GroupProjectsFilter filter, int itemsPerPage) + throws GitLabApiException { GitLabApiForm formData = filter.getQueryParams(); - return (new Pager(this, Project.class, itemsPerPage, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "projects")); + return (new Pager( + this, + Project.class, + itemsPerPage, + formData.asMap(), + "groups", + getGroupIdOrPath(groupIdOrPath), + "projects")); } /** @@ -445,7 +526,8 @@ public Pager getProjects(Object groupIdOrPath, GroupProjectsFilter filt * @return a Stream containing Project instances that belong to the group and match the provided filter * @throws GitLabApiException if any exception occurs */ - public Stream getProjectsStream(Object groupIdOrPath, GroupProjectsFilter filter) throws GitLabApiException { + public Stream getProjectsStream(Object groupIdOrPath, GroupProjectsFilter filter) + throws GitLabApiException { return (getProjects(groupIdOrPath, filter, getDefaultPerPage()).stream()); } @@ -474,7 +556,12 @@ public List getProjects(Object groupIdOrPath) throws GitLabApiException * @throws GitLabApiException if any exception occurs */ public List getProjects(Object groupIdOrPath, int page, int perPage) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "groups", getGroupIdOrPath(groupIdOrPath), "projects"); + Response response = get( + Response.Status.OK, + getPageQueryParams(page, perPage), + "groups", + getGroupIdOrPath(groupIdOrPath), + "projects"); return (response.readEntity(new GenericType>() {})); } @@ -489,7 +576,8 @@ public List getProjects(Object groupIdOrPath, int page, int perPage) th * @throws GitLabApiException if any exception occurs */ public Pager getProjects(Object groupIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Project.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "projects")); + return (new Pager( + this, Project.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "projects")); } /** @@ -515,8 +603,8 @@ public Stream getProjectsStream(Object groupIdOrPath) throws GitLabApiE * @throws GitLabApiException if any exception occurs */ public Group getGroup(Object groupIdOrPath) throws GitLabApiException { - Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath)); - return (response.readEntity(Group.class)); + Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath)); + return (response.readEntity(Group.class)); } /** @@ -560,8 +648,8 @@ public Group createGroup(GroupParams params) throws GitLabApiException { * @throws GitLabApiException at any exception */ public Group updateGroup(Object groupIdOrPath, GroupParams params) throws GitLabApiException { - Response response = putWithFormData(Response.Status.OK, - params.getForm(false), "groups", getGroupIdOrPath(groupIdOrPath)); + Response response = + putWithFormData(Response.Status.OK, params.getForm(false), "groups", getGroupIdOrPath(groupIdOrPath)); return (response.readEntity(Group.class)); } @@ -612,8 +700,15 @@ public Group addGroup(Group group) throws GitLabApiException { * @return the created Group instance * @throws GitLabApiException if any exception occurs */ - public Group addGroup(String name, String path, String description, Visibility visibility, - Boolean lfsEnabled, Boolean requestAccessEnabled, Long parentId) throws GitLabApiException { + public Group addGroup( + String name, + String path, + String description, + Visibility visibility, + Boolean lfsEnabled, + Boolean requestAccessEnabled, + Long parentId) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("name", name, true) @@ -665,8 +760,16 @@ public Group updateGroup(Group group) throws GitLabApiException { * @return the updated Group instance * @throws GitLabApiException if any exception occurs */ - public Group updateGroup(Object groupIdOrPath, String name, String path, String description, Visibility visibility, - Boolean lfsEnabled, Boolean requestAccessEnabled, Long parentId) throws GitLabApiException { + public Group updateGroup( + Object groupIdOrPath, + String name, + String path, + String description, + Visibility visibility, + Boolean lfsEnabled, + Boolean requestAccessEnabled, + Long parentId) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("name", name) @@ -701,9 +804,18 @@ public Group updateGroup(Object groupIdOrPath, String name, String path, String * Boolean, Boolean, Long)} */ @Deprecated - public Group addGroup(String name, String path, String description, Boolean membershipLock, - Boolean shareWithGroupLock, Visibility visibility, Boolean lfsEnabled, Boolean requestAccessEnabled, - Long parentId, Integer sharedRunnersMinutesLimit) throws GitLabApiException { + public Group addGroup( + String name, + String path, + String description, + Boolean membershipLock, + Boolean shareWithGroupLock, + Visibility visibility, + Boolean lfsEnabled, + Boolean requestAccessEnabled, + Long parentId, + Integer sharedRunnersMinutesLimit) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("name", name) @@ -742,9 +854,19 @@ public Group addGroup(String name, String path, String description, Boolean memb * Visibility, Boolean, Boolean, Long)} */ @Deprecated - public Group updateGroup(Object groupIdOrPath, String name, String path, String description, Boolean membershipLock, - Boolean shareWithGroupLock, Visibility visibility, Boolean lfsEnabled, Boolean requestAccessEnabled, - Long parentId, Integer sharedRunnersMinutesLimit) throws GitLabApiException { + public Group updateGroup( + Object groupIdOrPath, + String name, + String path, + String description, + Boolean membershipLock, + Boolean shareWithGroupLock, + Visibility visibility, + Boolean lfsEnabled, + Boolean requestAccessEnabled, + Long parentId, + Integer sharedRunnersMinutesLimit) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("name", name) @@ -770,7 +892,8 @@ public Group updateGroup(Object groupIdOrPath, String name, String path, String * @throws GitLabApiException if any exception occurs */ public void deleteGroup(Object groupIdOrPath) throws GitLabApiException { - Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT); + Response.Status expectedStatus = + (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT); delete(expectedStatus, null, "groups", getGroupIdOrPath(groupIdOrPath)); } @@ -799,7 +922,12 @@ public List getMembers(Object groupIdOrPath) throws GitLabApiException { * @throws GitLabApiException if any exception occurs */ public List getMembers(Object groupIdOrPath, int page, int perPage) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "groups", getGroupIdOrPath(groupIdOrPath), "members"); + Response response = get( + Response.Status.OK, + getPageQueryParams(page, perPage), + "groups", + getGroupIdOrPath(groupIdOrPath), + "members"); return (response.readEntity(new GenericType>() {})); } @@ -814,7 +942,8 @@ public List getMembers(Object groupIdOrPath, int page, int perPage) thro * @throws GitLabApiException if any exception occurs */ public Pager getMembers(Object groupIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Member.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "members")); + return (new Pager( + this, Member.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "members")); } /** @@ -841,7 +970,7 @@ public Stream getMembersStream(Object groupIdOrPath) throws GitLabApiExc * @throws GitLabApiException if any exception occurs */ public Member getMember(Object groupIdOrPath, long userId) throws GitLabApiException { - return (getMember(groupIdOrPath, userId, false)); + return (getMember(groupIdOrPath, userId, false)); } /** @@ -875,7 +1004,8 @@ public Optional getOptionalMember(Object groupIdOrPath, long userId) { public Member getMember(Object groupIdOrPath, Long userId, Boolean includeInherited) throws GitLabApiException { Response response; if (includeInherited) { - response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "members", "all", userId); + response = + get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "members", "all", userId); } else { response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "members", userId); } @@ -892,7 +1022,7 @@ public Member getMember(Object groupIdOrPath, Long userId, Boolean includeInheri * @param includeInherited if true will the member even if inherited thru an ancestor group * @return the member specified by the group ID/user ID pair as the value of an Optional */ - public Optional getOptionalMember(Object groupIdOrPath, Long userId, Boolean includeInherited) { + public Optional getOptionalMember(Object groupIdOrPath, Long userId, Boolean includeInherited) { try { return (Optional.ofNullable(getMember(groupIdOrPath, userId, includeInherited))); } catch (GitLabApiException glae) { @@ -933,8 +1063,13 @@ public List getAllMembers(Object groupIdOrPath) throws GitLabApiExceptio */ @Deprecated public List getAllMembers(Object groupIdOrPath, int page, int perPage) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), - "groups", getGroupIdOrPath(groupIdOrPath), "members", "all"); + Response response = get( + Response.Status.OK, + getPageQueryParams(page, perPage), + "groups", + getGroupIdOrPath(groupIdOrPath), + "members", + "all"); return (response.readEntity(new GenericType>() {})); } @@ -971,7 +1106,6 @@ public Stream getAllMembersStream(Object groupIdOrPath) throws GitLabApi return (getAllMembersStream(groupIdOrPath, null, null)); } - /** * Gets a list of group members viewable by the authenticated user, including inherited members * through ancestor groups. Returns multiple times the same user (with different member attributes) @@ -985,8 +1119,10 @@ public Stream getAllMembersStream(Object groupIdOrPath) throws GitLabApi * @return the group members viewable by the authenticated user, including inherited members through ancestor groups * @throws GitLabApiException if any exception occurs */ - public List getAllMembers(Object groupIdOrPath, String query, List userIds) throws GitLabApiException { - return (getAllMembers(groupIdOrPath, query, userIds, getDefaultPerPage()).all()); + public List getAllMembers(Object groupIdOrPath, String query, List userIds) + throws GitLabApiException { + return (getAllMembers(groupIdOrPath, query, userIds, getDefaultPerPage()) + .all()); } /** @@ -1004,10 +1140,18 @@ public List getAllMembers(Object groupIdOrPath, String query, List * including inherited members through ancestor groups * @throws GitLabApiException if any exception occurs */ - public Pager getAllMembers(Object groupIdOrPath, String query, List userIds, int itemsPerPage) throws GitLabApiException { + public Pager getAllMembers(Object groupIdOrPath, String query, List userIds, int itemsPerPage) + throws GitLabApiException { GitLabApiForm form = new GitLabApiForm().withParam("query", query).withParam("user_ids", userIds); - return (new Pager(this, Member.class, itemsPerPage, form.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "members", "all")); + return (new Pager( + this, + Member.class, + itemsPerPage, + form.asMap(), + "groups", + getGroupIdOrPath(groupIdOrPath), + "members", + "all")); } /** @@ -1024,7 +1168,8 @@ public Pager getAllMembers(Object groupIdOrPath, String query, List getAllMembersStream(Object groupIdOrPath, String query, List userIds) throws GitLabApiException { + public Stream getAllMembersStream(Object groupIdOrPath, String query, List userIds) + throws GitLabApiException { return (getAllMembers(groupIdOrPath, query, userIds, getDefaultPerPage()).stream()); } @@ -1070,7 +1215,8 @@ public Member addMember(Object groupIdOrPath, Long userId, AccessLevel accessLev * @return a Member instance for the added user * @throws GitLabApiException if any exception occurs */ - public Member addMember(Object groupIdOrPath, Long userId, AccessLevel accessLevel, Date expiresAt) throws GitLabApiException { + public Member addMember(Object groupIdOrPath, Long userId, AccessLevel accessLevel, Date expiresAt) + throws GitLabApiException { return (addMember(groupIdOrPath, userId, accessLevel.toValue(), expiresAt)); } @@ -1086,13 +1232,15 @@ public Member addMember(Object groupIdOrPath, Long userId, AccessLevel accessLev * @return a Member instance for the added user * @throws GitLabApiException if any exception occurs */ - public Member addMember(Object groupIdOrPath, Long userId, Integer accessLevel, Date expiresAt) throws GitLabApiException { + public Member addMember(Object groupIdOrPath, Long userId, Integer accessLevel, Date expiresAt) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("user_id", userId, true) .withParam("access_level", accessLevel, true) - .withParam("expires_at", expiresAt, false); - Response response = post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "members"); + .withParam("expires_at", expiresAt, false); + Response response = + post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "members"); return (response.readEntity(Member.class)); } @@ -1138,7 +1286,8 @@ public Member updateMember(Object groupIdOrPath, Long userId, AccessLevel access * @return the updated member * @throws GitLabApiException if any exception occurs */ - public Member updateMember(Object groupIdOrPath, Long userId, AccessLevel accessLevel, Date expiresAt) throws GitLabApiException { + public Member updateMember(Object groupIdOrPath, Long userId, AccessLevel accessLevel, Date expiresAt) + throws GitLabApiException { return (updateMember(groupIdOrPath, userId, accessLevel.toValue(), expiresAt)); } @@ -1154,11 +1303,13 @@ public Member updateMember(Object groupIdOrPath, Long userId, AccessLevel access * @return the updated member * @throws GitLabApiException if any exception occurs */ - public Member updateMember(Object groupIdOrPath, Long userId, Integer accessLevel, Date expiresAt) throws GitLabApiException { + public Member updateMember(Object groupIdOrPath, Long userId, Integer accessLevel, Date expiresAt) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("access_level", accessLevel, true) - .withParam("expires_at", expiresAt, false); - Response response = put(Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "members", userId); + .withParam("expires_at", expiresAt, false); + Response response = + put(Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "members", userId); return (response.readEntity(Member.class)); } @@ -1172,7 +1323,8 @@ public Member updateMember(Object groupIdOrPath, Long userId, Integer accessLeve * @throws GitLabApiException if any exception occurs */ public void removeMember(Object groupIdOrPath, Long userId) throws GitLabApiException { - Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT); + Response.Status expectedStatus = + (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT); delete(expectedStatus, null, "groups", getGroupIdOrPath(groupIdOrPath), "members", userId); } @@ -1185,7 +1337,7 @@ public void removeMember(Object groupIdOrPath, Long userId) throws GitLabApiExce * @throws GitLabApiException if any exception occurs */ public void ldapSync(Object groupIdOrPath) throws GitLabApiException { - post(Response.Status.NO_CONTENT, (Form)null, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_sync"); + post(Response.Status.NO_CONTENT, (Form) null, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_sync"); } /** @@ -1198,8 +1350,9 @@ public void ldapSync(Object groupIdOrPath) throws GitLabApiException { * @throws GitLabApiException if any exception occurs */ public List getLdapGroupLinks(Object groupIdOrPath) throws GitLabApiException { - Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_group_links"); - return (response.readEntity(new GenericType>() {})); + Response response = + get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_group_links"); + return (response.readEntity(new GenericType>() {})); } /** @@ -1213,7 +1366,8 @@ public List getLdapGroupLinks(Object groupIdOrPath) throws GitLab * @param provider the LDAP provider for the LDAP group * @throws GitLabApiException if any exception occurs */ - public void addLdapGroupLink(Object groupIdOrPath, String cn, AccessLevel groupAccess, String provider) throws GitLabApiException { + public void addLdapGroupLink(Object groupIdOrPath, String cn, AccessLevel groupAccess, String provider) + throws GitLabApiException { if (groupAccess == null) { throw new RuntimeException("groupAccess cannot be null or empty"); @@ -1233,11 +1387,12 @@ public void addLdapGroupLink(Object groupIdOrPath, String cn, AccessLevel groupA * @param provider the LDAP provider for the LDAP group * @throws GitLabApiException if any exception occurs */ - public void addLdapGroupLink(Object groupIdOrPath, String cn, Integer groupAccess, String provider) throws GitLabApiException { + public void addLdapGroupLink(Object groupIdOrPath, String cn, Integer groupAccess, String provider) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() - .withParam("cn", cn, true) + .withParam("cn", cn, true) .withParam("group_access", groupAccess, true) - .withParam("provider", provider, true); + .withParam("provider", provider, true); post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_group_links"); } @@ -1292,7 +1447,8 @@ public void deleteLdapGroupLink(Object groupIdOrPath, String cn, String provider * @throws GitLabApiException if any exception occurs */ public List getSamlGroupLinks(Object groupIdOrPath) throws GitLabApiException { - Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "saml_group_links"); + Response response = + get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "saml_group_links"); return (response.readEntity(new GenericType>() {})); } @@ -1306,7 +1462,8 @@ public List getSamlGroupLinks(Object groupIdOrPath) throws GitLab * @param groupAccess the minimum access level for members of the SAML group * @throws GitLabApiException if any exception occurs */ - public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessLevel groupAccess) throws GitLabApiException { + public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessLevel groupAccess) + throws GitLabApiException { if (groupAccess == null) { throw new RuntimeException("groupAccess cannot be null or empty"); @@ -1315,7 +1472,7 @@ public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessL addSamlGroupLink(groupIdOrPath, samlGroupName, groupAccess.toValue()); } - /** + /** * Adds an SAML group link. * *
GitLab Endpoint: POST /groups/:id/saml_group_links
@@ -1326,7 +1483,8 @@ public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessL * @param memberRoleId the id of the custom member role to assign * @throws GitLabApiException if any exception occurs */ - public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessLevel groupAccess, int memberRoleId) throws GitLabApiException { + public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessLevel groupAccess, int memberRoleId) + throws GitLabApiException { if (groupAccess == null) { throw new RuntimeException("groupAccess cannot be null or empty"); @@ -1345,7 +1503,8 @@ public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, AccessL * @param groupAccess the minimum access level for members of the SAML group * @throws GitLabApiException if any exception occurs */ - public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, Integer groupAccess) throws GitLabApiException { + public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, Integer groupAccess) + throws GitLabApiException { addSamlGroupLink(groupIdOrPath, samlGroupName, groupAccess, null); } @@ -1360,11 +1519,12 @@ public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, Integer * @param memberRoleId the id of the custom member role to assign * @throws GitLabApiException if any exception occurs */ - public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, Integer groupAccess, Integer memberRoleId) throws GitLabApiException { + public void addSamlGroupLink(Object groupIdOrPath, String samlGroupName, Integer groupAccess, Integer memberRoleId) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() - .withParam("saml_group_name", samlGroupName, true) - .withParam("access_level", groupAccess, true) - .withParam("member_role_id", memberRoleId); + .withParam("saml_group_name", samlGroupName, true) + .withParam("access_level", groupAccess, true) + .withParam("member_role_id", memberRoleId); post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "saml_group_links"); } @@ -1411,7 +1571,12 @@ public List getVariables(Object groupIdOrPath) throws GitLabApiExcepti * @throws GitLabApiException if any exception occurs */ public List getVariables(Object groupIdOrPath, int page, int perPage) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "groups", getGroupIdOrPath(groupIdOrPath), "variables"); + Response response = get( + Response.Status.OK, + getPageQueryParams(page, perPage), + "groups", + getGroupIdOrPath(groupIdOrPath), + "variables"); return (response.readEntity(new GenericType>() {})); } @@ -1426,7 +1591,8 @@ public List getVariables(Object groupIdOrPath, int page, int perPage) * @throws GitLabApiException if any exception occurs */ public Pager getVariables(Object groupIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Variable.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "variables")); + return (new Pager( + this, Variable.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "variables")); } /** @@ -1453,8 +1619,8 @@ public Stream getVariablesStream(Object groupIdOrPath) throws GitLabAp * @throws GitLabApiException if any exception occurs */ public Variable getVariable(Object groupIdOrPath, String key) throws GitLabApiException { - Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "variables", key); - return (response.readEntity(Variable.class)); + Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "variables", key); + return (response.readEntity(Variable.class)); } /** @@ -1486,7 +1652,8 @@ public Optional getOptionalVariable(Object groupIdOrPath, String key) * @return a Variable instance with the newly created variable * @throws GitLabApiException if any exception occurs during execution */ - public Variable createVariable(Object groupIdOrPath, String key, String value, Boolean isProtected) throws GitLabApiException { + public Variable createVariable(Object groupIdOrPath, String key, String value, Boolean isProtected) + throws GitLabApiException { return createVariable(groupIdOrPath, key, value, isProtected, false); } @@ -1504,14 +1671,16 @@ public Variable createVariable(Object groupIdOrPath, String key, String value, B * @return a Variable instance with the newly created variable * @throws GitLabApiException if any exception occurs during execution */ - public Variable createVariable(Object groupIdOrPath, String key, String value, Boolean isProtected, Boolean masked) throws GitLabApiException { + public Variable createVariable(Object groupIdOrPath, String key, String value, Boolean isProtected, Boolean masked) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("key", key, true) .withParam("value", value, true) .withParam("masked", masked) .withParam("protected", isProtected); - Response response = post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "variables"); + Response response = + post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "variables"); return (response.readEntity(Variable.class)); } @@ -1527,7 +1696,8 @@ public Variable createVariable(Object groupIdOrPath, String key, String value, B * @return a Variable instance with the updated variable * @throws GitLabApiException if any exception occurs during execution */ - public Variable updateVariable(Object groupIdOrPath, String key, String value, Boolean isProtected) throws GitLabApiException { + public Variable updateVariable(Object groupIdOrPath, String key, String value, Boolean isProtected) + throws GitLabApiException { return updateVariable(groupIdOrPath, key, value, isProtected, false); } @@ -1545,13 +1715,15 @@ public Variable updateVariable(Object groupIdOrPath, String key, String value, B * @return a Variable instance with the updated variable * @throws GitLabApiException if any exception occurs during execution */ - public Variable updateVariable(Object groupIdOrPath, String key, String value, Boolean isProtected, Boolean masked) throws GitLabApiException { + public Variable updateVariable(Object groupIdOrPath, String key, String value, Boolean isProtected, Boolean masked) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("value", value, true) .withParam("masked", masked) .withParam("protected", isProtected); - Response response = putWithFormData(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "variables", key); + Response response = putWithFormData( + Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "variables", key); return (response.readEntity(Variable.class)); } @@ -1579,8 +1751,13 @@ public void deleteVariable(Object groupIdOrPath, String key) throws GitLabApiExc * @throws GitLabApiException if any exception occurs during execution */ public Project transferProject(Object groupIdOrPath, Object projectIdOrPath) throws GitLabApiException { - Response response = post(Response.Status.CREATED, (Form)null, "groups", getGroupIdOrPath(groupIdOrPath), - "projects", getProjectIdOrPath(projectIdOrPath)); + Response response = post( + Response.Status.CREATED, + (Form) null, + "groups", + getGroupIdOrPath(groupIdOrPath), + "projects", + getProjectIdOrPath(projectIdOrPath)); return (response.readEntity(Project.class)); } @@ -1595,8 +1772,10 @@ public Project transferProject(Object groupIdOrPath, Object projectIdOrPath) thr * @return a List of group Audit events * @throws GitLabApiException if any exception occurs */ - public List getAuditEvents(Object groupIdOrPath, Date created_after, Date created_before) throws GitLabApiException { - return (getAuditEvents(groupIdOrPath, created_after, created_before, getDefaultPerPage()).all()); + public List getAuditEvents(Object groupIdOrPath, Date created_after, Date created_before) + throws GitLabApiException { + return (getAuditEvents(groupIdOrPath, created_after, created_before, getDefaultPerPage()) + .all()); } /** @@ -1611,12 +1790,19 @@ public List getAuditEvents(Object groupIdOrPath, Date created_after, * @return a Pager of group Audit events * @throws GitLabApiException if any exception occurs */ - public Pager getAuditEvents(Object groupIdOrPath, Date created_after, Date created_before, int itemsPerPage) throws GitLabApiException { + public Pager getAuditEvents( + Object groupIdOrPath, Date created_after, Date created_before, int itemsPerPage) throws GitLabApiException { Form form = new GitLabApiForm() .withParam("created_before", ISO8601.toString(created_after, false)) .withParam("created_after", ISO8601.toString(created_before, false)); - return (new Pager(this, AuditEvent.class, itemsPerPage, form.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "audit_events")); + return (new Pager( + this, + AuditEvent.class, + itemsPerPage, + form.asMap(), + "groups", + getGroupIdOrPath(groupIdOrPath), + "audit_events")); } /** @@ -1630,7 +1816,8 @@ public Pager getAuditEvents(Object groupIdOrPath, Date created_after * @return a Stream of group Audit events * @throws GitLabApiException if any exception occurs */ - public Stream getAuditEventsStream(Object groupIdOrPath, Date created_after, Date created_before) throws GitLabApiException { + public Stream getAuditEventsStream(Object groupIdOrPath, Date created_after, Date created_before) + throws GitLabApiException { return (getAuditEvents(groupIdOrPath, created_after, created_before, getDefaultPerPage()).stream()); } @@ -1645,7 +1832,8 @@ public Stream getAuditEventsStream(Object groupIdOrPath, Date create * @throws GitLabApiException if any exception occurs */ public AuditEvent getAuditEvent(Object groupIdOrPath, Long auditEventId) throws GitLabApiException { - Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "audit_events", auditEventId); + Response response = + get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "audit_events", auditEventId); return (response.readEntity(AuditEvent.class)); } @@ -1673,8 +1861,14 @@ public List getAccessRequests(Object groupIdOrPath) throws GitLab * @throws GitLabApiException if any exception occurs */ public Pager getAccessRequests(Object groupIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, AccessRequest.class, itemsPerPage, null, - "groups", getGroupIdOrPath(groupIdOrPath), "access_requests")); + return (new Pager( + this, + AccessRequest.class, + itemsPerPage, + null, + "groups", + getGroupIdOrPath(groupIdOrPath), + "access_requests")); } /** @@ -1687,7 +1881,7 @@ public Pager getAccessRequests(Object groupIdOrPath, int itemsPer * @throws GitLabApiException if any exception occurs */ public Stream getAccessRequestsStream(Object groupIdOrPath) throws GitLabApiException { - return (getAccessRequests(groupIdOrPath, getDefaultPerPage()).stream()); + return (getAccessRequests(groupIdOrPath, getDefaultPerPage()).stream()); } /** @@ -1700,7 +1894,8 @@ public Stream getAccessRequestsStream(Object groupIdOrPath) throw * @throws GitLabApiException if any exception occurs */ public AccessRequest requestAccess(Object groupIdOrPath) throws GitLabApiException { - Response response = post(Response.Status.CREATED, (Form)null, "groups", getGroupIdOrPath(groupIdOrPath), "access_requests"); + Response response = post( + Response.Status.CREATED, (Form) null, "groups", getGroupIdOrPath(groupIdOrPath), "access_requests"); return (response.readEntity(AccessRequest.class)); } @@ -1715,10 +1910,17 @@ public AccessRequest requestAccess(Object groupIdOrPath) throws GitLabApiExcepti * @return the approved AccessRequest instance * @throws GitLabApiException if any exception occurs */ - public AccessRequest approveAccessRequest(Object groupIdOrPath, Long userId, AccessLevel accessLevel) throws GitLabApiException { + public AccessRequest approveAccessRequest(Object groupIdOrPath, Long userId, AccessLevel accessLevel) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm().withParam("access_level", accessLevel); - Response response = this.putWithFormData(Response.Status.CREATED, formData, - "groups", getGroupIdOrPath(groupIdOrPath), "access_requests", userId, "approve"); + Response response = this.putWithFormData( + Response.Status.CREATED, + formData, + "groups", + getGroupIdOrPath(groupIdOrPath), + "access_requests", + userId, + "approve"); return (response.readEntity(AccessRequest.class)); } @@ -1732,8 +1934,7 @@ public AccessRequest approveAccessRequest(Object groupIdOrPath, Long userId, Acc * @throws GitLabApiException if any exception occurs */ public void denyAccessRequest(Object groupIdOrPath, Long userId) throws GitLabApiException { - delete(Response.Status.NO_CONTENT, null, - "groups", getGroupIdOrPath(groupIdOrPath), "access_requests", userId); + delete(Response.Status.NO_CONTENT, null, "groups", getGroupIdOrPath(groupIdOrPath), "access_requests", userId); } /** @@ -1746,7 +1947,7 @@ public void denyAccessRequest(Object groupIdOrPath, Long userId) throws GitLabAp * @throws GitLabApiException if any exception occurs */ public List getBadges(Object groupIdOrPath) throws GitLabApiException { - return getBadges(groupIdOrPath, null); + return getBadges(groupIdOrPath, null); } /** @@ -1760,9 +1961,10 @@ public List getBadges(Object groupIdOrPath) throws GitLabApiException { * @throws GitLabApiException If any problem is encountered */ public List getBadges(Object groupIdOrPath, String badgeName) throws GitLabApiException { - Form queryParam = new GitLabApiForm().withParam("name", badgeName); - Response response = get(Response.Status.OK, queryParam.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "badges"); - return (response.readEntity(new GenericType>() {})); + Form queryParam = new GitLabApiForm().withParam("name", badgeName); + Response response = + get(Response.Status.OK, queryParam.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "badges"); + return (response.readEntity(new GenericType>() {})); } /** @@ -1776,8 +1978,8 @@ public List getBadges(Object groupIdOrPath, String badgeName) throws GitL * @throws GitLabApiException if any exception occurs */ public Badge getBadge(Object groupIdOrPath, Long badgeId) throws GitLabApiException { - Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "badges", badgeId); - return (response.readEntity(Badge.class)); + Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "badges", badgeId); + return (response.readEntity(Badge.class)); } /** @@ -1790,11 +1992,11 @@ public Badge getBadge(Object groupIdOrPath, Long badgeId) throws GitLabApiExcept * @return an Optional instance with the specified badge as the value */ public Optional getOptionalBadge(Object groupIdOrPath, Long badgeId) { - try { - return (Optional.ofNullable(getBadge(groupIdOrPath, badgeId))); - } catch (GitLabApiException glae) { - return (GitLabApi.createOptionalFromException(glae)); - } + try { + return (Optional.ofNullable(getBadge(groupIdOrPath, badgeId))); + } catch (GitLabApiException glae) { + return (GitLabApi.createOptionalFromException(glae)); + } } /** @@ -1809,7 +2011,7 @@ public Optional getOptionalBadge(Object groupIdOrPath, Long badgeId) { * @throws GitLabApiException if any exception occurs */ public Badge addBadge(Object groupIdOrPath, String linkUrl, String imageUrl) throws GitLabApiException { - return addBadge(groupIdOrPath, null, linkUrl, imageUrl); + return addBadge(groupIdOrPath, null, linkUrl, imageUrl); } /** @@ -1824,13 +2026,14 @@ public Badge addBadge(Object groupIdOrPath, String linkUrl, String imageUrl) thr * @return A Badge instance for the added badge * @throws GitLabApiException if any exception occurs */ - public Badge addBadge(Object groupIdOrPath, String name, String linkUrl, String imageUrl) throws GitLabApiException { - GitLabApiForm formData = new GitLabApiForm() - .withParam("name", name, false) - .withParam("link_url", linkUrl, true) - .withParam("image_url", imageUrl, true); - Response response = post(Response.Status.OK, formData, "groups", getGroupIdOrPath(groupIdOrPath), "badges"); - return (response.readEntity(Badge.class)); + public Badge addBadge(Object groupIdOrPath, String name, String linkUrl, String imageUrl) + throws GitLabApiException { + GitLabApiForm formData = new GitLabApiForm() + .withParam("name", name, false) + .withParam("link_url", linkUrl, true) + .withParam("image_url", imageUrl, true); + Response response = post(Response.Status.OK, formData, "groups", getGroupIdOrPath(groupIdOrPath), "badges"); + return (response.readEntity(Badge.class)); } /** @@ -1845,8 +2048,9 @@ public Badge addBadge(Object groupIdOrPath, String name, String linkUrl, String * @return a Badge instance for the editted badge * @throws GitLabApiException if any exception occurs */ - public Badge editBadge(Object groupIdOrPath, Long badgeId, String linkUrl, String imageUrl) throws GitLabApiException { - return (editBadge(groupIdOrPath, badgeId, null, linkUrl, imageUrl)); + public Badge editBadge(Object groupIdOrPath, Long badgeId, String linkUrl, String imageUrl) + throws GitLabApiException { + return (editBadge(groupIdOrPath, badgeId, null, linkUrl, imageUrl)); } /** @@ -1862,13 +2066,15 @@ public Badge editBadge(Object groupIdOrPath, Long badgeId, String linkUrl, Strin * @return a Badge instance for the edited badge * @throws GitLabApiException if any exception occurs */ - public Badge editBadge(Object groupIdOrPath, Long badgeId, String name, String linkUrl, String imageUrl) throws GitLabApiException { - GitLabApiForm formData = new GitLabApiForm() - .withParam("name", name, false) - .withParam("link_url", linkUrl, false) - .withParam("image_url", imageUrl, false); - Response response = putWithFormData(Response.Status.OK, formData, "groups", getGroupIdOrPath(groupIdOrPath), "badges", badgeId); - return (response.readEntity(Badge.class)); + public Badge editBadge(Object groupIdOrPath, Long badgeId, String name, String linkUrl, String imageUrl) + throws GitLabApiException { + GitLabApiForm formData = new GitLabApiForm() + .withParam("name", name, false) + .withParam("link_url", linkUrl, false) + .withParam("image_url", imageUrl, false); + Response response = putWithFormData( + Response.Status.OK, formData, "groups", getGroupIdOrPath(groupIdOrPath), "badges", badgeId); + return (response.readEntity(Badge.class)); } /** @@ -1881,7 +2087,7 @@ public Badge editBadge(Object groupIdOrPath, Long badgeId, String name, String l * @throws GitLabApiException if any exception occurs */ public void removeBadge(Object groupIdOrPath, Long badgeId) throws GitLabApiException { - delete(Response.Status.NO_CONTENT, null, "groups", getGroupIdOrPath(groupIdOrPath), "badges", badgeId); + delete(Response.Status.NO_CONTENT, null, "groups", getGroupIdOrPath(groupIdOrPath), "badges", badgeId); } /** @@ -1895,12 +2101,12 @@ public void removeBadge(Object groupIdOrPath, Long badgeId) throws GitLabApiExce * @return a Badge instance for the rendered badge * @throws GitLabApiException if any exception occurs */ - public Badge previewBadge(Object groupIdOrPath, String linkUrl, String imageUrl) throws GitLabApiException { - GitLabApiForm formData = new GitLabApiForm() - .withParam("link_url", linkUrl, true) - .withParam("image_url", imageUrl, true); - Response response = get(Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "badges", "render"); - return (response.readEntity(Badge.class)); + public Badge previewBadge(Object groupIdOrPath, String linkUrl, String imageUrl) throws GitLabApiException { + GitLabApiForm formData = + new GitLabApiForm().withParam("link_url", linkUrl, true).withParam("image_url", imageUrl, true); + Response response = get( + Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "badges", "render"); + return (response.readEntity(Badge.class)); } /** @@ -1914,8 +2120,8 @@ public Badge previewBadge(Object groupIdOrPath, String linkUrl, String imageUrl * @throws GitLabApiException if any exception occurs */ public Group setGroupAvatar(Object groupIdOrPath, File avatarFile) throws GitLabApiException { - Response response = putUpload(Response.Status.OK, - "avatar", avatarFile, "groups", getGroupIdOrPath(groupIdOrPath)); + Response response = + putUpload(Response.Status.OK, "avatar", avatarFile, "groups", getGroupIdOrPath(groupIdOrPath)); return (response.readEntity(Group.class)); } @@ -1931,10 +2137,14 @@ public Group setGroupAvatar(Object groupIdOrPath, File avatarFile) throws GitLab */ public InputStream getAvatar(Object groupIdOrPath) throws GitLabApiException { - Response response = getWithAccepts(Response.Status.OK, null, MediaType.MEDIA_TYPE_WILDCARD, - "groups", getGroupIdOrPath(groupIdOrPath), "avatar"); + Response response = getWithAccepts( + Response.Status.OK, + null, + MediaType.MEDIA_TYPE_WILDCARD, + "groups", + getGroupIdOrPath(groupIdOrPath), + "avatar"); return (response.readEntity(InputStream.class)); - } /** @@ -1949,13 +2159,14 @@ public InputStream getAvatar(Object groupIdOrPath) throws GitLabApiException { * @return a Group instance holding the details of the shared group * @throws GitLabApiException if any exception occurs */ - public Group shareGroup(Object groupIdOrPath, Long shareWithGroupId, AccessLevel groupAccess, Date expiresAt) throws GitLabApiException { - GitLabApiForm formData = new GitLabApiForm() - .withParam("group_id", shareWithGroupId, true) - .withParam("group_access", groupAccess, true) - .withParam("expires_at", expiresAt); - Response response = post(Response.Status.OK, formData, "groups", getGroupIdOrPath(groupIdOrPath), "share"); - return (response.readEntity(Group.class)); + public Group shareGroup(Object groupIdOrPath, Long shareWithGroupId, AccessLevel groupAccess, Date expiresAt) + throws GitLabApiException { + GitLabApiForm formData = new GitLabApiForm() + .withParam("group_id", shareWithGroupId, true) + .withParam("group_access", groupAccess, true) + .withParam("expires_at", expiresAt); + Response response = post(Response.Status.OK, formData, "groups", getGroupIdOrPath(groupIdOrPath), "share"); + return (response.readEntity(Group.class)); } /** @@ -1968,8 +2179,7 @@ public Group shareGroup(Object groupIdOrPath, Long shareWithGroupId, AccessLevel * @throws GitLabApiException if any exception occurs */ public void unshareGroup(Object groupIdOrPath, Long sharedWithGroupId) throws GitLabApiException { - delete(Response.Status.NO_CONTENT, null, - "groups", getGroupIdOrPath(groupIdOrPath), "share", sharedWithGroupId); + delete(Response.Status.NO_CONTENT, null, "groups", getGroupIdOrPath(groupIdOrPath), "share", sharedWithGroupId); } /** @@ -1995,9 +2205,16 @@ public List getCustomAttributes(final Object groupIdOrPath) thr * @return a Pager of group's custom attributes * @throws GitLabApiException if any exception occurs */ - public Pager getCustomAttributes(final Object groupIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, CustomAttribute.class, itemsPerPage, null, - "groups", getGroupIdOrPath(groupIdOrPath), "custom_attributes")); + public Pager getCustomAttributes(final Object groupIdOrPath, int itemsPerPage) + throws GitLabApiException { + return (new Pager( + this, + CustomAttribute.class, + itemsPerPage, + null, + "groups", + getGroupIdOrPath(groupIdOrPath), + "custom_attributes")); } /** @@ -2024,8 +2241,8 @@ public Stream getCustomAttributesStream(final Object groupIdOrP * @throws GitLabApiException if any exception occurs */ public CustomAttribute getCustomAttribute(final Object groupIdOrPath, final String key) throws GitLabApiException { - Response response = get(Response.Status.OK, null, - "groups", getGroupIdOrPath(groupIdOrPath), "custom_attributes", key); + Response response = + get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "custom_attributes", key); return (response.readEntity(CustomAttribute.class)); } @@ -2058,7 +2275,8 @@ public Optional geOptionalCustomAttribute(final Object groupIdO * @return a CustomAttribute instance for the updated or created custom attribute * @throws GitLabApiException if any exception occurs */ - public CustomAttribute setCustomAttribute(final Object groupIdOrPath, final String key, final String value) throws GitLabApiException { + public CustomAttribute setCustomAttribute(final Object groupIdOrPath, final String key, final String value) + throws GitLabApiException { if (Objects.isNull(key) || key.trim().isEmpty()) { throw new IllegalArgumentException("Key cannot be null or empty"); @@ -2068,8 +2286,8 @@ public CustomAttribute setCustomAttribute(final Object groupIdOrPath, final Stri } GitLabApiForm formData = new GitLabApiForm().withParam("value", value); - Response response = putWithFormData(Response.Status.OK, formData, - "groups", getGroupIdOrPath(groupIdOrPath), "custom_attributes", key); + Response response = putWithFormData( + Response.Status.OK, formData, "groups", getGroupIdOrPath(groupIdOrPath), "custom_attributes", key); return (response.readEntity(CustomAttribute.class)); } @@ -2102,9 +2320,11 @@ public void deleteCustomAttribute(final Object groupIdOrPath, final String key) * @throws GitLabApiException if any exception occurs */ public List listGroupIterations(Object groupIdOrPath, IterationFilter filter) throws GitLabApiException { - MultivaluedMap queryParams = (filter == null) ? null : filter.getQueryParams().asMap(); - Response response = get(Response.Status.OK, queryParams, "groups", getGroupIdOrPath(groupIdOrPath), "iterations"); - return (response.readEntity(new GenericType>() { })); + MultivaluedMap queryParams = + (filter == null) ? null : filter.getQueryParams().asMap(); + Response response = + get(Response.Status.OK, queryParams, "groups", getGroupIdOrPath(groupIdOrPath), "iterations"); + return (response.readEntity(new GenericType>() {})); } /** @@ -2118,7 +2338,7 @@ public List listGroupIterations(Object groupIdOrPath, IterationFilter */ public List getGroupAccessTokens(Object groupIdOrPath) throws GitLabApiException { Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "access_tokens"); - return (response.readEntity(new GenericType>() { })); + return (response.readEntity(new GenericType>() {})); } /** @@ -2132,7 +2352,8 @@ public List getGroupAccessTokens(Object groupIdOrPath) throws * @throws GitLabApiException if any exception occurs */ public GroupAccessToken getGroupAccessToken(Object groupIdOrPath, Long tokenId) throws GitLabApiException { - Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "access_tokens", tokenId); + Response response = + get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "access_tokens", tokenId); return (response.readEntity(GroupAccessToken.class)); } @@ -2149,7 +2370,9 @@ public GroupAccessToken getGroupAccessToken(Object groupIdOrPath, Long tokenId) * @return the created GroupAccessToken instance * @throws GitLabApiException if any exception occurs */ - public GroupAccessToken createGroupAccessToken(Object groupIdOrPath, String name, Date expiresAt, Scope[] scopes, AccessLevel accessLevel) throws GitLabApiException { + public GroupAccessToken createGroupAccessToken( + Object groupIdOrPath, String name, Date expiresAt, Scope[] scopes, AccessLevel accessLevel) + throws GitLabApiException { if (scopes == null || scopes.length == 0) { throw new RuntimeException("scopes cannot be null or empty"); } @@ -2160,7 +2383,8 @@ public GroupAccessToken createGroupAccessToken(Object groupIdOrPath, String name .withParam("expires_at", ISO8601.dateOnly(expiresAt)) .withParam("access_level", accessLevel); - Response response = post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "access_tokens"); + Response response = + post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "access_tokens"); return (response.readEntity(GroupAccessToken.class)); } @@ -2178,7 +2402,6 @@ public GroupAccessToken rotateGroupAccessToken(Object groupIdOrPath, Long tokenI return rotateGroupAccessToken(groupIdOrPath, tokenId, null); } - /** * Rotate a group access token. Revokes the previous token and creates a new token that expires in one week. * @@ -2190,15 +2413,21 @@ public GroupAccessToken rotateGroupAccessToken(Object groupIdOrPath, Long tokenI * @return the updated GroupAccessToken instance * @throws GitLabApiException if any exception occurs */ - public GroupAccessToken rotateGroupAccessToken(Object groupIdOrPath, Long tokenId, Date expiresAt) throws GitLabApiException { - GitLabApiForm formData = new GitLabApiForm() - .withParam("expires_at", ISO8601.dateOnly(expiresAt)); - - Response response = post(Response.Status.OK, formData, "groups", getGroupIdOrPath(groupIdOrPath), "access_tokens", tokenId, "rotate"); + public GroupAccessToken rotateGroupAccessToken(Object groupIdOrPath, Long tokenId, Date expiresAt) + throws GitLabApiException { + GitLabApiForm formData = new GitLabApiForm().withParam("expires_at", ISO8601.dateOnly(expiresAt)); + + Response response = post( + Response.Status.OK, + formData, + "groups", + getGroupIdOrPath(groupIdOrPath), + "access_tokens", + tokenId, + "rotate"); return (response.readEntity(GroupAccessToken.class)); } - /** * Revoke a group access token. * diff --git a/src/main/java/org/gitlab4j/api/HealthCheckApi.java b/src/main/java/org/gitlab4j/api/HealthCheckApi.java index 104f8d9d2..9a39778ae 100644 --- a/src/main/java/org/gitlab4j/api/HealthCheckApi.java +++ b/src/main/java/org/gitlab4j/api/HealthCheckApi.java @@ -1,11 +1,12 @@ package org.gitlab4j.api; -import org.gitlab4j.api.models.HealthCheckInfo; - -import javax.ws.rs.core.Response; import java.io.IOException; import java.net.URL; +import javax.ws.rs.core.Response; + +import org.gitlab4j.api.models.HealthCheckInfo; + public class HealthCheckApi extends AbstractApi { public HealthCheckApi(GitLabApi gitLabApi) { diff --git a/src/main/java/org/gitlab4j/api/HookManager.java b/src/main/java/org/gitlab4j/api/HookManager.java index e3c098879..d56a6c0f9 100644 --- a/src/main/java/org/gitlab4j/api/HookManager.java +++ b/src/main/java/org/gitlab4j/api/HookManager.java @@ -1,66 +1,65 @@ - -package org.gitlab4j.api; - -import javax.servlet.http.HttpServletRequest; - -/** - * This interface provides a base class handler for processing GitLab Web Hook and System Hook callouts. - */ -public interface HookManager { - - /** - * Get the secret token that received hook events should be validated against. - * - * @return the secret token that received hook events should be validated against - */ - String getSecretToken(); - - /** - * Set the secret token that received hook events should be validated against. - * - * @param secretToken the secret token to verify against - */ - void setSecretToken(String secretToken); - - /** - * Validate the provided secret token against the reference secret token. Returns true if - * the secret token is valid or there is no reference secret token to validate against, - * otherwise returns false. - * - * @param secretToken the token to validate - * @return true if the secret token is valid or there is no reference secret token to validate against - */ - default public boolean isValidSecretToken(String secretToken) { - String ourSecretToken = getSecretToken(); - return (ourSecretToken == null || - ourSecretToken.trim().isEmpty() || - ourSecretToken.equals(secretToken) ? true : false); - } - - /** - * Validate the provided secret token found in the HTTP header against the reference secret token. - * Returns true if the secret token is valid or there is no reference secret token to validate - * against, otherwise returns false. - * - * @param request the HTTP request to verify the secret token - * @return true if the secret token is valid or there is no reference secret token to validate against - */ - default public boolean isValidSecretToken(HttpServletRequest request) { - - if (getSecretToken() != null) { - String secretToken = request.getHeader("X-Gitlab-Token"); - return (isValidSecretToken(secretToken)); - } - - return (true); - } - - /** - * Parses and verifies an Event instance from the HTTP request and - * fires it off to the registered listeners. - * - * @param request the HttpServletRequest to read the Event instance from - * @throws GitLabApiException if the parsed event is not supported - */ - public void handleEvent(HttpServletRequest request) throws GitLabApiException; -} \ No newline at end of file +package org.gitlab4j.api; + +import javax.servlet.http.HttpServletRequest; + +/** + * This interface provides a base class handler for processing GitLab Web Hook and System Hook callouts. + */ +public interface HookManager { + + /** + * Get the secret token that received hook events should be validated against. + * + * @return the secret token that received hook events should be validated against + */ + String getSecretToken(); + + /** + * Set the secret token that received hook events should be validated against. + * + * @param secretToken the secret token to verify against + */ + void setSecretToken(String secretToken); + + /** + * Validate the provided secret token against the reference secret token. Returns true if + * the secret token is valid or there is no reference secret token to validate against, + * otherwise returns false. + * + * @param secretToken the token to validate + * @return true if the secret token is valid or there is no reference secret token to validate against + */ + public default boolean isValidSecretToken(String secretToken) { + String ourSecretToken = getSecretToken(); + return (ourSecretToken == null || ourSecretToken.trim().isEmpty() || ourSecretToken.equals(secretToken) + ? true + : false); + } + + /** + * Validate the provided secret token found in the HTTP header against the reference secret token. + * Returns true if the secret token is valid or there is no reference secret token to validate + * against, otherwise returns false. + * + * @param request the HTTP request to verify the secret token + * @return true if the secret token is valid or there is no reference secret token to validate against + */ + public default boolean isValidSecretToken(HttpServletRequest request) { + + if (getSecretToken() != null) { + String secretToken = request.getHeader("X-Gitlab-Token"); + return (isValidSecretToken(secretToken)); + } + + return (true); + } + + /** + * Parses and verifies an Event instance from the HTTP request and + * fires it off to the registered listeners. + * + * @param request the HttpServletRequest to read the Event instance from + * @throws GitLabApiException if the parsed event is not supported + */ + public void handleEvent(HttpServletRequest request) throws GitLabApiException; +} diff --git a/src/main/java/org/gitlab4j/api/ImportExportApi.java b/src/main/java/org/gitlab4j/api/ImportExportApi.java index 2b5c34014..b45ee7fd4 100644 --- a/src/main/java/org/gitlab4j/api/ImportExportApi.java +++ b/src/main/java/org/gitlab4j/api/ImportExportApi.java @@ -65,8 +65,13 @@ public void scheduleExport(Object projectIdOrPath, String description) throws Gi * Only PUT and POST methods allowed. Default is PUT * @throws GitLabApiException if any exception occurs */ - public void scheduleExport(Object projectIdOrPath, String description, - Map upload, String uploadUrl, String uploadHttpMethod) throws GitLabApiException { + public void scheduleExport( + Object projectIdOrPath, + String description, + Map upload, + String uploadUrl, + String uploadHttpMethod) + throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("description", description) @@ -118,8 +123,14 @@ public File downloadExport(Object projectIdOrPath, File directory) throws GitLab */ public File downloadExport(Object projectIdOrPath, File directory, String filename) throws GitLabApiException { - Response response = getWithAccepts(Response.Status.OK, null, MediaType.MEDIA_TYPE_WILDCARD, - "projects", getProjectIdOrPath(projectIdOrPath), "export", "download"); + Response response = getWithAccepts( + Response.Status.OK, + null, + MediaType.MEDIA_TYPE_WILDCARD, + "projects", + getProjectIdOrPath(projectIdOrPath), + "export", + "download"); if (directory == null) { directory = new File(System.getProperty("java.io.tmpdir")); @@ -135,15 +146,15 @@ public File downloadExport(Object projectIdOrPath, File directory, String filena String name = null; if (projectIdOrPath instanceof Project) { name = ((Project) projectIdOrPath).getPathWithNamespace().replace('/', '_'); - } else if(projectIdOrPath instanceof String) { - name = (String)projectIdOrPath; - } else if(projectIdOrPath instanceof Integer) { + } else if (projectIdOrPath instanceof String) { + name = (String) projectIdOrPath; + } else if (projectIdOrPath instanceof Integer) { name = "projectid-" + projectIdOrPath; } // template = "YYYY-MM-DD_HH-MM-SS_{name}_export.tar.gz" final String template = "%1$tY-%1$tm-%1$td_%1$tH-%1$tM-%1$tS_%2$s_export.tar.gz"; - filename = String.format(template, new Date(), name); + filename = String.format(template, new Date(), name); } else { filename = disposition.replaceFirst("(?i)^.*filename=\"?([^\"]+)\"?.*$", "$1"); @@ -200,7 +211,9 @@ public File downloadExport(Object projectIdOrPath, File directory, String filena * @return an Importstatus instance with info for the project being imported to * @throws GitLabApiException if any exception occurs */ - public ImportStatus startImport(Object namespaceIdOrPath, File exportFile, String path, Boolean overwrite, Project overrideParams) throws GitLabApiException { + public ImportStatus startImport( + Object namespaceIdOrPath, File exportFile, String path, Boolean overwrite, Project overrideParams) + throws GitLabApiException { URL url; try { @@ -216,31 +229,36 @@ public ImportStatus startImport(Object namespaceIdOrPath, File exportFile, Strin if (overrideParams != null) { formData.withParam("default_branch", overrideParams.getDefaultBranch()) - .withParam("description", overrideParams.getDescription()) - .withParam("issues_enabled", overrideParams.getIssuesEnabled()) - .withParam("merge_method", overrideParams.getMergeMethod()) - .withParam("merge_requests_enabled", overrideParams.getMergeRequestsEnabled()) - .withParam("jobs_enabled", overrideParams.getJobsEnabled()) - .withParam("wiki_enabled", overrideParams.getWikiEnabled()) - .withParam("container_registry_enabled", overrideParams.getContainerRegistryEnabled()) - .withParam("snippets_enabled", overrideParams.getSnippetsEnabled()) - .withParam("shared_runners_enabled", overrideParams.getSharedRunnersEnabled()) - .withParam("public_jobs", overrideParams.getPublicJobs()) - .withParam("visibility_level", overrideParams.getVisibilityLevel()) - .withParam("only_allow_merge_if_pipeline_succeeds", overrideParams.getOnlyAllowMergeIfPipelineSucceeds()) - .withParam("only_allow_merge_if_all_discussions_are_resolved", overrideParams.getOnlyAllowMergeIfAllDiscussionsAreResolved()) - .withParam("lfs_enabled", overrideParams.getLfsEnabled()) - .withParam("request_access_enabled", overrideParams.getRequestAccessEnabled()) - .withParam("repository_storage", overrideParams.getRepositoryStorage()) - .withParam("approvals_before_merge", overrideParams.getApprovalsBeforeMerge()) - .withParam("printing_merge_request_link_enabled", overrideParams.getPrintingMergeRequestLinkEnabled()) - .withParam("resolve_outdated_diff_discussions", overrideParams.getResolveOutdatedDiffDiscussions()) - .withParam("initialize_with_readme", overrideParams.getInitializeWithReadme()) - .withParam("packages_enabled", overrideParams.getPackagesEnabled()) - .withParam("build_git_strategy", overrideParams.getBuildGitStrategy()) - .withParam("build_coverage_regex", overrideParams.getBuildCoverageRegex()) - .withParam("squash_option", overrideParams.getSquashOption()) - .withParam("name", overrideParams.getName()); + .withParam("description", overrideParams.getDescription()) + .withParam("issues_enabled", overrideParams.getIssuesEnabled()) + .withParam("merge_method", overrideParams.getMergeMethod()) + .withParam("merge_requests_enabled", overrideParams.getMergeRequestsEnabled()) + .withParam("jobs_enabled", overrideParams.getJobsEnabled()) + .withParam("wiki_enabled", overrideParams.getWikiEnabled()) + .withParam("container_registry_enabled", overrideParams.getContainerRegistryEnabled()) + .withParam("snippets_enabled", overrideParams.getSnippetsEnabled()) + .withParam("shared_runners_enabled", overrideParams.getSharedRunnersEnabled()) + .withParam("public_jobs", overrideParams.getPublicJobs()) + .withParam("visibility_level", overrideParams.getVisibilityLevel()) + .withParam( + "only_allow_merge_if_pipeline_succeeds", + overrideParams.getOnlyAllowMergeIfPipelineSucceeds()) + .withParam( + "only_allow_merge_if_all_discussions_are_resolved", + overrideParams.getOnlyAllowMergeIfAllDiscussionsAreResolved()) + .withParam("lfs_enabled", overrideParams.getLfsEnabled()) + .withParam("request_access_enabled", overrideParams.getRequestAccessEnabled()) + .withParam("repository_storage", overrideParams.getRepositoryStorage()) + .withParam("approvals_before_merge", overrideParams.getApprovalsBeforeMerge()) + .withParam( + "printing_merge_request_link_enabled", overrideParams.getPrintingMergeRequestLinkEnabled()) + .withParam("resolve_outdated_diff_discussions", overrideParams.getResolveOutdatedDiffDiscussions()) + .withParam("initialize_with_readme", overrideParams.getInitializeWithReadme()) + .withParam("packages_enabled", overrideParams.getPackagesEnabled()) + .withParam("build_git_strategy", overrideParams.getBuildGitStrategy()) + .withParam("build_coverage_regex", overrideParams.getBuildCoverageRegex()) + .withParam("squash_option", overrideParams.getSquashOption()) + .withParam("name", overrideParams.getName()); } Response response = upload(Response.Status.CREATED, "file", exportFile, null, formData, url); diff --git a/src/main/java/org/gitlab4j/api/IssuesApi.java b/src/main/java/org/gitlab4j/api/IssuesApi.java index 3b35c3320..65571c896 100644 --- a/src/main/java/org/gitlab4j/api/IssuesApi.java +++ b/src/main/java/org/gitlab4j/api/IssuesApi.java @@ -111,7 +111,12 @@ public List getIssues(Object projectIdOrPath) throws GitLabApiException { * @throws GitLabApiException if any exception occurs */ public List getIssues(Object projectIdOrPath, int page, int perPage) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "projects", getProjectIdOrPath(projectIdOrPath), "issues"); + Response response = get( + Response.Status.OK, + getPageQueryParams(page, perPage), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues"); return (response.readEntity(new GenericType>() {})); } @@ -126,7 +131,8 @@ public List getIssues(Object projectIdOrPath, int page, int perPage) thro * @throws GitLabApiException if any exception occurs */ public Pager getIssues(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Issue.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "issues")); + return (new Pager( + this, Issue.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "issues")); } /** @@ -168,9 +174,11 @@ public List getIssues(Object projectIdOrPath, IssueFilter filter) throws * @return the list of issues in the specified range. * @throws GitLabApiException if any exception occurs */ - public List getIssues(Object projectIdOrPath, IssueFilter filter, int page, int perPage) throws GitLabApiException { + public List getIssues(Object projectIdOrPath, IssueFilter filter, int page, int perPage) + throws GitLabApiException { GitLabApiForm formData = filter.getQueryParams(page, perPage); - Response response = get(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "issues"); + Response response = + get(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "issues"); return (response.readEntity(new GenericType>() {})); } @@ -185,9 +193,17 @@ public List getIssues(Object projectIdOrPath, IssueFilter filter, int pag * @return the Pager of issues in the specified range. * @throws GitLabApiException if any exception occurs */ - public Pager getIssues(Object projectIdOrPath, IssueFilter filter, int itemsPerPage) throws GitLabApiException { + public Pager getIssues(Object projectIdOrPath, IssueFilter filter, int itemsPerPage) + throws GitLabApiException { GitLabApiForm formData = filter.getQueryParams(); - return (new Pager(this, Issue.class, itemsPerPage, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "issues")); + return (new Pager( + this, + Issue.class, + itemsPerPage, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues")); } /** @@ -249,7 +265,7 @@ public List getIssues(IssueFilter filter, int page, int perPage) throws G */ public Pager getIssues(IssueFilter filter, int itemsPerPage) throws GitLabApiException { GitLabApiForm formData = filter.getQueryParams(); - return (new Pager(this, Issue.class, itemsPerPage, formData.asMap(), "issues")); + return (new Pager(this, Issue.class, itemsPerPage, formData.asMap(), "issues")); } /** @@ -276,7 +292,7 @@ public Stream getIssuesStream(IssueFilter filter) throws GitLabApiExcepti * @throws GitLabApiException if any exception occurs */ public List getGroupIssues(Object groupIdOrPath) throws GitLabApiException { - return (getGroupIssues(groupIdOrPath, null, getDefaultPerPage()).all()); + return (getGroupIssues(groupIdOrPath, null, getDefaultPerPage()).all()); } /** @@ -303,7 +319,7 @@ public Pager getGroupIssues(Object groupIdOrPath, int itemsPerPage) throw * @throws GitLabApiException if any exception occurs */ public Stream getGroupIssuesStream(Object groupIdOrPath) throws GitLabApiException { - return (getGroupIssues(groupIdOrPath, null, getDefaultPerPage()).stream()); + return (getGroupIssues(groupIdOrPath, null, getDefaultPerPage()).stream()); } /** @@ -317,7 +333,7 @@ public Stream getGroupIssuesStream(Object groupIdOrPath) throws GitLabApi * @throws GitLabApiException if any exception occurs */ public List getGroupIssues(Object groupIdOrPath, IssueFilter filter) throws GitLabApiException { - return (getGroupIssues(groupIdOrPath, filter, getDefaultPerPage()).all()); + return (getGroupIssues(groupIdOrPath, filter, getDefaultPerPage()).all()); } /** @@ -331,10 +347,17 @@ public List getGroupIssues(Object groupIdOrPath, IssueFilter filter) thro * @return the Pager of issues for the specified group and filter * @throws GitLabApiException if any exception occurs */ - public Pager getGroupIssues(Object groupIdOrPath, IssueFilter filter, int itemsPerPage) throws GitLabApiException { + public Pager getGroupIssues(Object groupIdOrPath, IssueFilter filter, int itemsPerPage) + throws GitLabApiException { GitLabApiForm formData = (filter != null ? filter.getQueryParams() : new GitLabApiForm()); - return (new Pager(this, Issue.class, itemsPerPage, formData.asMap(), - "groups", getGroupIdOrPath(groupIdOrPath), "issues")); + return (new Pager( + this, + Issue.class, + itemsPerPage, + formData.asMap(), + "groups", + getGroupIdOrPath(groupIdOrPath), + "issues")); } /** @@ -348,7 +371,7 @@ public Pager getGroupIssues(Object groupIdOrPath, IssueFilter filter, int * @throws GitLabApiException if any exception occurs */ public Stream getGroupIssuesStream(Object groupIdOrPath, IssueFilter filter) throws GitLabApiException { - return (getGroupIssues(groupIdOrPath, filter, getDefaultPerPage()).stream()); + return (getGroupIssues(groupIdOrPath, filter, getDefaultPerPage()).stream()); } /** @@ -362,8 +385,13 @@ public Stream getGroupIssuesStream(Object groupIdOrPath, IssueFilter filt * @throws GitLabApiException if any exception occurs */ public Issue getIssue(Object projectIdOrPath, Long issueIid) throws GitLabApiException { - Response response = get(Response.Status.OK, getDefaultPerPageParam(), - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid); + Response response = get( + Response.Status.OK, + getDefaultPerPageParam(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid); return (response.readEntity(Issue.class)); } @@ -420,10 +448,33 @@ public Issue createIssue(Object projectIdOrPath, String title, String descriptio * @return an instance of Issue * @throws GitLabApiException if any exception occurs */ - public Issue createIssue(Object projectIdOrPath, String title, String description, Boolean confidential, List assigneeIds, Long milestoneId, String labels, - Date createdAt, Date dueDate, Long mergeRequestToResolveId, Long discussionToResolveId) throws GitLabApiException { - - return (createIssue(projectIdOrPath, title, description, confidential, assigneeIds, milestoneId, labels, createdAt, dueDate, mergeRequestToResolveId, discussionToResolveId, null)); + public Issue createIssue( + Object projectIdOrPath, + String title, + String description, + Boolean confidential, + List assigneeIds, + Long milestoneId, + String labels, + Date createdAt, + Date dueDate, + Long mergeRequestToResolveId, + Long discussionToResolveId) + throws GitLabApiException { + + return (createIssue( + projectIdOrPath, + title, + description, + confidential, + assigneeIds, + milestoneId, + labels, + createdAt, + dueDate, + mergeRequestToResolveId, + discussionToResolveId, + null)); } /** @@ -448,22 +499,35 @@ public Issue createIssue(Object projectIdOrPath, String title, String descriptio * @return an instance of Issue * @throws GitLabApiException if any exception occurs */ - public Issue createIssue(Object projectIdOrPath, String title, String description, Boolean confidential, List assigneeIds, Long milestoneId, String labels, - Date createdAt, Date dueDate, Long mergeRequestToResolveId, Long discussionToResolveId, String iterationTitle) throws GitLabApiException { + public Issue createIssue( + Object projectIdOrPath, + String title, + String description, + Boolean confidential, + List assigneeIds, + Long milestoneId, + String labels, + Date createdAt, + Date dueDate, + Long mergeRequestToResolveId, + Long discussionToResolveId, + String iterationTitle) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() - .withParam("title", title, true) - .withParam("description", description) - .withParam("confidential", confidential) - .withParam("assignee_ids", assigneeIds) - .withParam("milestone_id", milestoneId) - .withParam("labels", labels) - .withParam("created_at", createdAt) - .withParam("due_date", dueDate) - .withParam("merge_request_to_resolve_discussions_of", mergeRequestToResolveId) - .withParam("discussion_to_resolve", discussionToResolveId) - .withParam("iteration_title", iterationTitle); - Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "issues"); + .withParam("title", title, true) + .withParam("description", description) + .withParam("confidential", confidential) + .withParam("assignee_ids", assigneeIds) + .withParam("milestone_id", milestoneId) + .withParam("labels", labels) + .withParam("created_at", createdAt) + .withParam("due_date", dueDate) + .withParam("merge_request_to_resolve_discussions_of", mergeRequestToResolveId) + .withParam("discussion_to_resolve", discussionToResolveId) + .withParam("iteration_title", iterationTitle); + Response response = + post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "issues"); return (response.readEntity(Issue.class)); } @@ -484,7 +548,13 @@ public Issue closeIssue(Object projectIdOrPath, Long issueIid) throws GitLabApiE } GitLabApiForm formData = new GitLabApiForm().withParam("state_event", StateEvent.CLOSE); - Response response = put(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid); + Response response = put( + Response.Status.OK, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid); return (response.readEntity(Issue.class)); } @@ -505,7 +575,13 @@ public Issue reopenIssue(Object projectIdOrPath, Long issueIid) throws GitLabApi } GitLabApiForm formData = new GitLabApiForm().withParam("state_event", StateEvent.REOPEN); - Response response = put(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid); + Response response = put( + Response.Status.OK, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid); return (response.readEntity(Issue.class)); } @@ -528,8 +604,19 @@ public Issue reopenIssue(Object projectIdOrPath, Long issueIid) throws GitLabApi * @return an instance of the updated Issue * @throws GitLabApiException if any exception occurs */ - public Issue updateIssue(Object projectIdOrPath, Long issueIid, String title, String description, Boolean confidential, List assigneeIds, - Long milestoneId, String labels, StateEvent stateEvent, Date updatedAt, Date dueDate) throws GitLabApiException { + public Issue updateIssue( + Object projectIdOrPath, + Long issueIid, + String title, + String description, + Boolean confidential, + List assigneeIds, + Long milestoneId, + String labels, + StateEvent stateEvent, + Date updatedAt, + Date dueDate) + throws GitLabApiException { if (issueIid == null) { throw new RuntimeException("issue IID cannot be null"); @@ -545,7 +632,13 @@ public Issue updateIssue(Object projectIdOrPath, Long issueIid, String title, St .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); + Response response = put( + Response.Status.OK, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid); return (response.readEntity(Issue.class)); } @@ -587,7 +680,13 @@ public Issue assignIssue(Object projectIdOrPath, Long issueIid, List assig } GitLabApiForm formData = new GitLabApiForm().withParam("assignee_ids", assigneeIds); - Response response = put(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid); + Response response = put( + Response.Status.OK, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid); return (response.readEntity(Issue.class)); } @@ -606,8 +705,15 @@ public void deleteIssue(Object projectIdOrPath, Long issueIid) throws GitLabApiE 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); + Response.Status expectedStatus = + (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT); + delete( + expectedStatus, + getDefaultPerPageParam(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid); } /** @@ -660,8 +766,14 @@ public TimeStats estimateTime(Object projectIdOrPath, Long issueIid, Duration du String durationString = (duration != null ? DurationUtils.toString(duration.getSeconds(), false) : null); GitLabApiForm formData = new GitLabApiForm().withParam("duration", durationString, true); - Response response = post(Response.Status.OK, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "time_estimate"); + Response response = post( + Response.Status.OK, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "time_estimate"); return (response.readEntity(TimeStats.class)); } @@ -681,8 +793,14 @@ public TimeStats resetEstimatedTime(Object projectIdOrPath, Long issueIid) throw throw new RuntimeException("issue IID cannot be null"); } - Response response = post(Response.Status.OK, new GitLabApiForm().asMap(), "projects", - getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "reset_time_estimate"); + Response response = post( + Response.Status.OK, + new GitLabApiForm().asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "reset_time_estimate"); return (response.readEntity(TimeStats.class)); } @@ -736,8 +854,14 @@ public TimeStats addSpentTime(Object projectIdOrPath, Long issueIid, Duration du String durationString = (duration != null ? DurationUtils.toString(duration.getSeconds(), false) : null); GitLabApiForm formData = new GitLabApiForm().withParam("duration", durationString, true); - Response response = post(Response.Status.CREATED, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "add_spent_time"); + Response response = post( + Response.Status.CREATED, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "add_spent_time"); return (response.readEntity(TimeStats.class)); } @@ -757,8 +881,14 @@ public TimeStats resetSpentTime(Object projectIdOrPath, Long issueIid) throws Gi 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"); + Response response = post( + Response.Status.OK, + new GitLabApiForm().asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "reset_spent_time"); return (response.readEntity(TimeStats.class)); } @@ -778,8 +908,14 @@ public TimeStats getTimeTrackingStats(Object projectIdOrPath, Long issueIid) thr throw new RuntimeException("issue IID cannot be null"); } - Response response = get(Response.Status.OK, new GitLabApiForm().asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "time_stats"); + Response response = get( + Response.Status.OK, + new GitLabApiForm().asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "time_stats"); return (response.readEntity(TimeStats.class)); } @@ -810,8 +946,10 @@ public Optional getOptionalTimeTrackingStats(Object projectIdOrPath, * @return a List containing all the merge requests what will close the issue when merged. * @throws GitLabApiException if any exception occurs */ - public List getClosedByMergeRequests(Object projectIdOrPath, Long issueIid) throws GitLabApiException { - return (getClosedByMergeRequests(projectIdOrPath, issueIid, getDefaultPerPage()).all()); + public List getClosedByMergeRequests(Object projectIdOrPath, Long issueIid) + throws GitLabApiException { + return (getClosedByMergeRequests(projectIdOrPath, issueIid, getDefaultPerPage()) + .all()); } /** @@ -826,10 +964,17 @@ public List getClosedByMergeRequests(Object projectIdOrPath, Long * @return a List containing all the merge requests what will close the issue when merged. * @throws GitLabApiException if any exception occurs */ - public List getClosedByMergeRequests(Object projectIdOrPath, Long issueIid, int page, int perPage) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "closed_by"); - return (response.readEntity(new GenericType>() { })); + public List getClosedByMergeRequests(Object projectIdOrPath, Long issueIid, int page, int perPage) + throws GitLabApiException { + Response response = get( + Response.Status.OK, + getPageQueryParams(page, perPage), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "closed_by"); + return (response.readEntity(new GenericType>() {})); } /** @@ -843,9 +988,18 @@ public List getClosedByMergeRequests(Object projectIdOrPath, Long * @return a Pager containing all the issues that would be closed by merging the provided merge request * @throws GitLabApiException if any exception occurs */ - public Pager getClosedByMergeRequests(Object projectIdOrPath, Long issueIid, int itemsPerPage) throws GitLabApiException { - return new Pager(this, MergeRequest.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "closed_by"); + public Pager getClosedByMergeRequests(Object projectIdOrPath, Long issueIid, int itemsPerPage) + throws GitLabApiException { + return new Pager( + this, + MergeRequest.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "closed_by"); } /** @@ -858,7 +1012,8 @@ public Pager getClosedByMergeRequests(Object projectIdOrPath, Long * @return a List containing all the merge requests what will close the issue when merged. * @throws GitLabApiException if any exception occurs */ - public Stream getClosedByMergeRequestsStream(Object projectIdOrPath, Long issueIid) throws GitLabApiException { + public Stream getClosedByMergeRequestsStream(Object projectIdOrPath, Long issueIid) + throws GitLabApiException { return (getClosedByMergeRequests(projectIdOrPath, issueIid, getDefaultPerPage()).stream()); } @@ -893,9 +1048,18 @@ public List getIssueLinks(Object projectIdOrPath, Long issueIid) throws G * @return a Pager of related issues of a given issue, sorted by the relationship creation datetime (ascending) * @throws GitLabApiException if any exception occurs */ - public Pager getIssueLinks(Object projectIdOrPath, Long issueIid, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Issue.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "links")); + public Pager getIssueLinks(Object projectIdOrPath, Long issueIid, int itemsPerPage) + throws GitLabApiException { + return (new Pager( + this, + Issue.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "links")); } /** @@ -929,8 +1093,9 @@ public Stream getIssueLinksStream(Object projectIdOrPath, Long issueIid) * @return an instance of IssueLink holding the link relationship * @throws GitLabApiException if any exception occurs */ - public IssueLink createIssueLink(Object projectIdOrPath, Long issueIid, - Object targetProjectIdOrPath, Long targetIssueIid) throws GitLabApiException { + public IssueLink createIssueLink( + Object projectIdOrPath, Long issueIid, Object targetProjectIdOrPath, Long targetIssueIid) + throws GitLabApiException { return createIssueLink(projectIdOrPath, issueIid, targetProjectIdOrPath, targetIssueIid, null); } @@ -949,16 +1114,23 @@ public IssueLink createIssueLink(Object projectIdOrPath, Long issueIid, * @return an instance of IssueLink holding the link relationship * @throws GitLabApiException if any exception occurs */ - public IssueLink createIssueLink(Object projectIdOrPath, Long issueIid, - Object targetProjectIdOrPath, Long targetIssueIid, LinkType linkType) throws GitLabApiException { + public IssueLink createIssueLink( + Object projectIdOrPath, Long issueIid, Object targetProjectIdOrPath, Long targetIssueIid, LinkType linkType) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("target_project_id", getProjectIdOrPath(targetProjectIdOrPath), true) .withParam("target_issue_iid", targetIssueIid, true) .withParam("link_type", linkType, false); - Response response = post(Response.Status.OK, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "links"); + Response response = post( + Response.Status.OK, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "links"); return (response.readEntity(IssueLink.class)); } @@ -975,9 +1147,17 @@ public IssueLink createIssueLink(Object projectIdOrPath, Long issueIid, * @return an instance of IssueLink holding the deleted link relationship * @throws GitLabApiException if any exception occurs */ - public IssueLink deleteIssueLink(Object projectIdOrPath, Long issueIid, Long issueLinkId) throws GitLabApiException { - Response response = delete(Response.Status.OK, null, - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "links", issueLinkId); + public IssueLink deleteIssueLink(Object projectIdOrPath, Long issueIid, Long issueLinkId) + throws GitLabApiException { + Response response = delete( + Response.Status.OK, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "links", + issueLinkId); return (response.readEntity(IssueLink.class)); } @@ -1007,10 +1187,17 @@ public List getParticipants(Object projectIdOrPath, Long issueIid) * @return a List containing all participants for the specified issue * @throws GitLabApiException if any exception occurs */ - public List getParticipants(Object projectIdOrPath, Long issueIid, int page, int perPage) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "participants"); - return (response.readEntity(new GenericType>() { })); + public List getParticipants(Object projectIdOrPath, Long issueIid, int page, int perPage) + throws GitLabApiException { + Response response = get( + Response.Status.OK, + getPageQueryParams(page, perPage), + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "participants"); + return (response.readEntity(new GenericType>() {})); } /** @@ -1024,9 +1211,18 @@ public List getParticipants(Object projectIdOrPath, Long issueIid, * @return a Pager containing all participants for the specified issue * @throws GitLabApiException if any exception occurs */ - public Pager getParticipants(Object projectIdOrPath, Long issueIid, int itemsPerPage) throws GitLabApiException { - return new Pager(this, Participant.class, itemsPerPage, null, - "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "participants"); + public Pager getParticipants(Object projectIdOrPath, Long issueIid, int itemsPerPage) + throws GitLabApiException { + return new Pager( + this, + Participant.class, + itemsPerPage, + null, + "projects", + getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "participants"); } /** @@ -1069,9 +1265,15 @@ public IssuesStatistics getIssuesStatistics(IssuesStatisticsFilter filter) throw * @return an IssuesStatistics instance with the statistics for the matched issues * @throws GitLabApiException if any exception occurs */ - public IssuesStatistics getGroupIssuesStatistics(Object groupIdOrPath, IssuesStatisticsFilter filter) throws GitLabApiException { + public IssuesStatistics getGroupIssuesStatistics(Object groupIdOrPath, IssuesStatisticsFilter filter) + throws GitLabApiException { GitLabApiForm formData = filter.getQueryParams(); - Response response = get(Response.Status.OK, formData.asMap(), "groups", this.getGroupIdOrPath(groupIdOrPath), "issues_statistics"); + Response response = get( + Response.Status.OK, + formData.asMap(), + "groups", + this.getGroupIdOrPath(groupIdOrPath), + "issues_statistics"); return (response.readEntity(IssuesStatistics.class)); } @@ -1085,9 +1287,15 @@ public IssuesStatistics getGroupIssuesStatistics(Object groupIdOrPath, IssuesSta * @return an IssuesStatistics instance with the statistics for the matched issues * @throws GitLabApiException if any exception occurs */ - public IssuesStatistics geProjectIssuesStatistics(Object projectIdOrPath, IssuesStatisticsFilter filter) throws GitLabApiException { + public IssuesStatistics geProjectIssuesStatistics(Object projectIdOrPath, IssuesStatisticsFilter filter) + throws GitLabApiException { GitLabApiForm formData = filter.getQueryParams(); - Response response = get(Response.Status.OK, formData.asMap(), "projects", this.getProjectIdOrPath(projectIdOrPath), "issues_statistics"); + Response response = get( + Response.Status.OK, + formData.asMap(), + "projects", + this.getProjectIdOrPath(projectIdOrPath), + "issues_statistics"); return (response.readEntity(IssuesStatistics.class)); } @@ -1108,9 +1316,15 @@ public IssuesStatistics geProjectIssuesStatistics(Object projectIdOrPath, Issues * @throws GitLabApiException if any exception occurs */ public Issue moveIssue(Object projectIdOrPath, Long issueIid, Object toProjectId) throws GitLabApiException { - GitLabApiForm formData = new GitLabApiForm().withParam("to_project_id", toProjectId, true); - Response response = post(Response.Status.OK, formData, - "projects", this.getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "move"); + GitLabApiForm formData = new GitLabApiForm().withParam("to_project_id", toProjectId, true); + Response response = post( + Response.Status.OK, + formData, + "projects", + this.getProjectIdOrPath(projectIdOrPath), + "issues", + issueIid, + "move"); return (response.readEntity(Issue.class)); } } diff --git a/src/main/java/org/gitlab4j/api/JobApi.java b/src/main/java/org/gitlab4j/api/JobApi.java index 46f1499ca..416336041 100644 --- a/src/main/java/org/gitlab4j/api/JobApi.java +++ b/src/main/java/org/gitlab4j/api/JobApi.java @@ -9,11 +9,13 @@ import java.util.List; import java.util.Optional; import java.util.stream.Stream; + import javax.ws.rs.core.Form; import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; + import org.gitlab4j.api.models.ArtifactsFile; import org.gitlab4j.api.models.Job; import org.gitlab4j.api.models.JobAttributes; @@ -52,7 +54,12 @@ public List getJobs(Object projectIdOrPath) throws GitLabApiException { * @throws GitLabApiException if any exception occurs during execution */ public List getJobs(Object projectIdOrPath, int page, int perPage) throws GitLabApiException { - Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "projects", getProjectIdOrPath(projectIdOrPath), "jobs"); + Response response = get( + Response.Status.OK, + getPageQueryParams(page, perPage), + "projects", + getProjectIdOrPath(projectIdOrPath), + "jobs"); return (response.readEntity(new GenericType>() {})); } @@ -67,7 +74,8 @@ public List getJobs(Object projectIdOrPath, int page, int perPage) throws G * @throws GitLabApiException if any exception occurs during execution */ public Pager getJobs(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { - return (new Pager(this, Job.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "jobs")); + return (new Pager( + this, Job.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "jobs")); } /** @@ -110,8 +118,14 @@ public List getJobs(Object projectIdOrPath, JobScope scope) throws GitLabAp */ public Pager getJobs(Object projectIdOrPath, JobScope scope, int itemsPerPage) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm().withParam("scope", scope); - return (new Pager(this, Job.class, itemsPerPage, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "jobs")); + return (new Pager( + this, + Job.class, + itemsPerPage, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "jobs")); } /** @@ -153,7 +167,8 @@ public List getJobsForPipeline(Object projectIdOrPath, long pipelineId) thr * @return a list containing the jobs for the specified project ID and pipeline ID * @throws GitLabApiException if any exception occurs during execution */ - public List getJobsForPipeline(Object projectIdOrPath, long pipelineId, Boolean includeRetried) throws GitLabApiException { + public List getJobsForPipeline(Object projectIdOrPath, long pipelineId, Boolean includeRetried) + throws GitLabApiException { return getJobsForPipeline(projectIdOrPath, pipelineId, null, includeRetried); } @@ -168,7 +183,8 @@ public List getJobsForPipeline(Object projectIdOrPath, long pipelineId, Boo * @return a list containing the jobs for the specified project ID and pipeline ID * @throws GitLabApiException if any exception occurs during execution */ - public List getJobsForPipeline(Object projectIdOrPath, long pipelineId, JobScope scope) throws GitLabApiException { + public List getJobsForPipeline(Object projectIdOrPath, long pipelineId, JobScope scope) + throws GitLabApiException { return getJobsForPipeline(projectIdOrPath, pipelineId, scope, false); } @@ -184,12 +200,20 @@ public List getJobsForPipeline(Object projectIdOrPath, long pipelineId, Job * @return a list containing the jobs for the specified project ID and pipeline ID * @throws GitLabApiException if any exception occurs during execution */ - public List getJobsForPipeline(Object projectIdOrPath, long pipelineId, JobScope scope, Boolean includeRetried) throws GitLabApiException { + public List getJobsForPipeline(Object projectIdOrPath, long pipelineId, JobScope scope, Boolean includeRetried) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("scope", scope) .withParam("include_retried", includeRetried) .withParam(PER_PAGE_PARAM, getDefaultPerPage()); - Response response = get(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "pipelines", pipelineId, "jobs"); + Response response = get( + Response.Status.OK, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "pipelines", + pipelineId, + "jobs"); return (response.readEntity(new GenericType>() {})); } @@ -204,7 +228,8 @@ public List getJobsForPipeline(Object projectIdOrPath, long pipelineId, Job * @return a list containing the jobs for the specified project ID and pipeline ID * @throws GitLabApiException if any exception occurs during execution */ - public Pager getJobsForPipeline(Object projectIdOrPath, long pipelineId, int itemsPerPage) throws GitLabApiException { + public Pager getJobsForPipeline(Object projectIdOrPath, long pipelineId, int itemsPerPage) + throws GitLabApiException { return getJobsForPipeline(projectIdOrPath, pipelineId, itemsPerPage, null); } @@ -220,12 +245,22 @@ public Pager getJobsForPipeline(Object projectIdOrPath, long pipelineId, in * @return a list containing the jobs for the specified project ID and pipeline ID * @throws GitLabApiException if any exception occurs during execution */ - public Pager getJobsForPipeline(Object projectIdOrPath, long pipelineId, int itemsPerPage, Boolean includeRetried) throws GitLabApiException { + public Pager getJobsForPipeline( + Object projectIdOrPath, long pipelineId, int itemsPerPage, Boolean includeRetried) + throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() - .withParam("include_retried", includeRetried) - .withParam(PER_PAGE_PARAM, getDefaultPerPage()); - return (new Pager(this, Job.class, itemsPerPage, formData.asMap(), - "projects", getProjectIdOrPath(projectIdOrPath), "pipelines", pipelineId, "jobs")); + .withParam("include_retried", includeRetried) + .withParam(PER_PAGE_PARAM, getDefaultPerPage()); + return (new Pager( + this, + Job.class, + itemsPerPage, + formData.asMap(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "pipelines", + pipelineId, + "jobs")); } /** @@ -251,7 +286,8 @@ public Stream getJobsStream(Object projectIdOrPath, long pipelineId) throws * @return a Stream containing the jobs for the specified project ID * @throws GitLabApiException if any exception occurs during execution */ - public Stream getJobsStream(Object projectIdOrPath, long pipelineId, Boolean includeRetried) throws GitLabApiException { + public Stream getJobsStream(Object projectIdOrPath, long pipelineId, Boolean includeRetried) + throws GitLabApiException { return (getJobsForPipeline(projectIdOrPath, pipelineId, getDefaultPerPage(), includeRetried).stream()); } @@ -266,7 +302,8 @@ public Stream getJobsStream(Object projectIdOrPath, long pipelineId, Boolea * @throws GitLabApiException if any exception occurs during execution */ public Job getJob(Object projectIdOrPath, Long jobId) throws GitLabApiException { - Response response = get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId); + Response response = + get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId); return (response.readEntity(Job.class)); } @@ -301,16 +338,24 @@ public Optional getOptionalJob(Object projectIdOrPath, Long jobId) { * @return a File instance pointing to the download of the specified artifacts file * @throws GitLabApiException if any exception occurs */ - public File downloadArtifactsFile(Object projectIdOrPath, String ref, String jobName, File directory) throws GitLabApiException { + public File downloadArtifactsFile(Object projectIdOrPath, String ref, String jobName, File directory) + 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", urlEncode(ref), "download"); + Response response = getWithAccepts( + Response.Status.OK, + formData.asMap(), + MediaType.MEDIA_TYPE_WILDCARD, + "projects", + getProjectIdOrPath(projectIdOrPath), + "jobs", + "artifacts", + urlEncode(ref), + "download"); try { - if (directory == null) - directory = new File(System.getProperty("java.io.tmpdir")); + if (directory == null) directory = new File(System.getProperty("java.io.tmpdir")); String filename = jobName + "-artifacts.zip"; File file = new File(directory, filename); @@ -337,10 +382,19 @@ public File downloadArtifactsFile(Object projectIdOrPath, String ref, String job * @return an InputStream to read the specified artifacts file from * @throws GitLabApiException if any exception occurs */ - public InputStream downloadArtifactsFile(Object projectIdOrPath, String ref, String jobName) throws GitLabApiException { + 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", urlEncode(ref), "download"); + Response response = getWithAccepts( + Response.Status.OK, + formData.asMap(), + MediaType.MEDIA_TYPE_WILDCARD, + "projects", + getProjectIdOrPath(projectIdOrPath), + "jobs", + "artifacts", + urlEncode(ref), + "download"); return (response.readEntity(InputStream.class)); } @@ -359,12 +413,18 @@ public InputStream downloadArtifactsFile(Object projectIdOrPath, String ref, Str */ public File downloadArtifactsFile(Object projectIdOrPath, Long jobId, File directory) throws GitLabApiException { - Response response = getWithAccepts(Response.Status.OK, null, MediaType.MEDIA_TYPE_WILDCARD, - "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "artifacts"); + Response response = getWithAccepts( + Response.Status.OK, + null, + MediaType.MEDIA_TYPE_WILDCARD, + "projects", + getProjectIdOrPath(projectIdOrPath), + "jobs", + jobId, + "artifacts"); try { - if (directory == null) - directory = new File(System.getProperty("java.io.tmpdir")); + if (directory == null) directory = new File(System.getProperty("java.io.tmpdir")); String filename = "job-" + jobId + "-artifacts.zip"; File file = new File(directory, filename); @@ -389,8 +449,15 @@ public File downloadArtifactsFile(Object projectIdOrPath, Long jobId, File direc * @throws GitLabApiException if any exception occurs */ public InputStream downloadArtifactsFile(Object projectIdOrPath, Long jobId) throws GitLabApiException { - Response response = getWithAccepts(Response.Status.OK, null, MediaType.MEDIA_TYPE_WILDCARD, - "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "artifacts"); + Response response = getWithAccepts( + Response.Status.OK, + null, + MediaType.MEDIA_TYPE_WILDCARD, + "projects", + getProjectIdOrPath(projectIdOrPath), + "jobs", + jobId, + "artifacts"); return (response.readEntity(InputStream.class)); } @@ -408,14 +475,21 @@ public InputStream downloadArtifactsFile(Object projectIdOrPath, Long jobId) thr * @return a File instance pointing to the download of the specified artifacts file * @throws GitLabApiException if any exception occurs */ - public File downloadArtifactsFile(Object projectIdOrPath, Long jobId, ArtifactsFile artifactsFile, File directory) throws GitLabApiException { - - Response response = get(Response.Status.OK, getDefaultPerPageParam(), - "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "artifacts", artifactsFile.getFilename()); + public File downloadArtifactsFile(Object projectIdOrPath, Long jobId, ArtifactsFile artifactsFile, File directory) + throws GitLabApiException { + + Response response = get( + Response.Status.OK, + getDefaultPerPageParam(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "jobs", + jobId, + "artifacts", + artifactsFile.getFilename()); try { - if (directory == null) - directory = new File(System.getProperty("java.io.tmpdir")); + if (directory == null) directory = new File(System.getProperty("java.io.tmpdir")); String filename = artifactsFile.getFilename(); File file = new File(directory, filename); @@ -442,9 +516,17 @@ public File downloadArtifactsFile(Object projectIdOrPath, Long jobId, ArtifactsF * @return an InputStream to read the specified artifacts file from * @throws GitLabApiException if any exception occurs */ - public InputStream downloadArtifactsFile(Object projectIdOrPath, Long jobId, ArtifactsFile artifactsFile) throws GitLabApiException { - Response response = get(Response.Status.OK, getDefaultPerPageParam(), - "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "artifacts", artifactsFile.getFilename()); + public InputStream downloadArtifactsFile(Object projectIdOrPath, Long jobId, ArtifactsFile artifactsFile) + throws GitLabApiException { + Response response = get( + Response.Status.OK, + getDefaultPerPageParam(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "jobs", + jobId, + "artifacts", + artifactsFile.getFilename()); return (response.readEntity(InputStream.class)); } @@ -462,15 +544,22 @@ public InputStream downloadArtifactsFile(Object projectIdOrPath, Long jobId, Art * @return a File instance pointing to the download of the specified artifacts file * @throws GitLabApiException if any exception occurs */ - public File downloadSingleArtifactsFile(Object projectIdOrPath, Long jobId, Path artifactPath, File directory) throws GitLabApiException { + public File downloadSingleArtifactsFile(Object projectIdOrPath, Long jobId, Path artifactPath, File directory) + throws GitLabApiException { String path = artifactPath.toString().replace("\\", "/"); - Response response = get(Response.Status.OK, getDefaultPerPageParam(), - "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "artifacts", path); + Response response = get( + Response.Status.OK, + getDefaultPerPageParam(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "jobs", + jobId, + "artifacts", + path); try { - if (directory == null) - directory = new File(System.getProperty("java.io.tmpdir")); + if (directory == null) directory = new File(System.getProperty("java.io.tmpdir")); String filename = artifactPath.getFileName().toString(); File file = new File(directory, filename); @@ -497,10 +586,18 @@ public File downloadSingleArtifactsFile(Object projectIdOrPath, Long jobId, Path * @return an InputStream to read the specified artifacts file from * @throws GitLabApiException if any exception occurs */ - public InputStream downloadSingleArtifactsFile(Object projectIdOrPath, Long jobId, Path artifactPath) throws GitLabApiException { + public InputStream downloadSingleArtifactsFile(Object projectIdOrPath, Long jobId, Path artifactPath) + throws GitLabApiException { String path = artifactPath.toString().replace("\\", "/"); - Response response = get(Response.Status.OK, getDefaultPerPageParam(), - "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "artifacts", path); + Response response = get( + Response.Status.OK, + getDefaultPerPageParam(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "jobs", + jobId, + "artifacts", + path); return (response.readEntity(InputStream.class)); } @@ -515,11 +612,17 @@ public InputStream downloadSingleArtifactsFile(Object projectIdOrPath, Long jobI * @return a String containing the specified job's trace * @throws GitLabApiException if any exception occurs during execution */ - public String getTrace(Object projectIdOrPath, Long jobId) throws GitLabApiException { - Response response = get(Response.Status.OK, getDefaultPerPageParam(), - "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "trace"); + public String getTrace(Object projectIdOrPath, Long jobId) throws GitLabApiException { + Response response = get( + Response.Status.OK, + getDefaultPerPageParam(), + "projects", + getProjectIdOrPath(projectIdOrPath), + "jobs", + jobId, + "trace"); return (response.readEntity(String.class)); - } + } /** * Cancel specified job in a project. @@ -532,9 +635,9 @@ public String getTrace(Object projectIdOrPath, Long jobId) throws GitLabApiExcep * @throws GitLabApiException if any exception occurs during execution * @deprecated replaced by {@link #cancelJob(Object, Long)} */ - @Deprecated + @Deprecated public Job cancleJob(Object projectIdOrPath, Long jobId) throws GitLabApiException { - return (cancelJob(projectIdOrPath, jobId)); + return (cancelJob(projectIdOrPath, jobId)); } /** @@ -549,7 +652,14 @@ public Job cancleJob(Object projectIdOrPath, Long jobId) throws GitLabApiExcepti */ public Job cancelJob(Object projectIdOrPath, Long jobId) throws GitLabApiException { GitLabApiForm formData = null; - Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "cancel"); + Response response = post( + Response.Status.CREATED, + formData, + "projects", + getProjectIdOrPath(projectIdOrPath), + "jobs", + jobId, + "cancel"); return (response.readEntity(Job.class)); } @@ -565,7 +675,8 @@ public Job cancelJob(Object projectIdOrPath, Long jobId) throws GitLabApiExcepti */ public Job retryJob(Object projectIdOrPath, Long jobId) throws GitLabApiException { GitLabApiForm formData = null; - Response response = post(Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "retry"); + Response response = + post(Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "retry"); return (response.readEntity(Job.class)); } @@ -581,7 +692,8 @@ public Job retryJob(Object projectIdOrPath, Long jobId) throws GitLabApiExceptio */ public Job eraseJob(Object projectIdOrPath, Long jobId) throws GitLabApiException { GitLabApiForm formData = null; - Response response = post(Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "erase"); + Response response = + post(Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "erase"); return (response.readEntity(Job.class)); } @@ -596,7 +708,7 @@ public Job eraseJob(Object projectIdOrPath, Long jobId) throws GitLabApiExceptio * @throws GitLabApiException if any exception occurs during execution */ public Job playJob(Object projectIdOrPath, Long jobId) throws GitLabApiException { - return playJob(projectIdOrPath, jobId, null); + return playJob(projectIdOrPath, jobId, null); } /** @@ -613,18 +725,23 @@ public Job playJob(Object projectIdOrPath, Long jobId) throws GitLabApiException * @return job instance which just played * @throws GitLabApiException if any exception occurs during execution */ - public Job playJob(Object projectIdOrPath, Long jobId, JobAttributes jobAttributes) - throws GitLabApiException { - Response response; - if (jobAttributes == null) { - GitLabApiForm formData = null; - response = post(Status.CREATED, formData, "projects", - getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "play"); - } else { - response = post(Status.CREATED, jobAttributes, "projects", - getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "play"); - } - return (response.readEntity(Job.class)); + public Job playJob(Object projectIdOrPath, Long jobId, JobAttributes jobAttributes) throws GitLabApiException { + Response response; + if (jobAttributes == null) { + GitLabApiForm formData = null; + response = post( + Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "play"); + } else { + response = post( + Status.CREATED, + jobAttributes, + "projects", + getProjectIdOrPath(projectIdOrPath), + "jobs", + jobId, + "play"); + } + return (response.readEntity(Job.class)); } /** @@ -638,8 +755,9 @@ public Job playJob(Object projectIdOrPath, Long jobId, JobAttributes jobAttribut * @throws GitLabApiException if any exception occurs during execution */ public Job keepArtifacts(Object projectIdOrPath, Long jobId) throws GitLabApiException { - GitLabApiForm formData = null; - Response response = post(Status.OK, formData, "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "keep"); + GitLabApiForm formData = null; + Response response = + post(Status.OK, formData, "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "keep"); return (response.readEntity(Job.class)); } diff --git a/src/main/java/org/gitlab4j/api/KeysApi.java b/src/main/java/org/gitlab4j/api/KeysApi.java index 29265ff81..2f2d653cd 100644 --- a/src/main/java/org/gitlab4j/api/KeysApi.java +++ b/src/main/java/org/gitlab4j/api/KeysApi.java @@ -1,11 +1,12 @@ package org.gitlab4j.api; -import org.gitlab4j.api.models.Key; +import java.util.Collections; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; -import java.util.Collections; + +import org.gitlab4j.api.models.Key; /** * See: diff --git a/src/main/java/org/gitlab4j/api/LabelsApi.java b/src/main/java/org/gitlab4j/api/LabelsApi.java index b8ba967f5..696214e9c 100644 --- a/src/main/java/org/gitlab4j/api/LabelsApi.java +++ b/src/main/java/org/gitlab4j/api/LabelsApi.java @@ -41,8 +41,8 @@ public List